Passing parameters to an executable

Asked

Viewed 797 times

1

I have an application that is divided into two different executables.

The first executable is the brain of my application, in this executable, in which I named it STUB, will be all the main logic of the application with some additional and optional methods (some mandatory, however, variables), as hosts, ports, pop-ups, etc.

The second executable is exactly the part of the optional and the mandatory, in which I call it the UI, IE, the user will choose the options you want and from this UI, create the new executable.

Using my STUB as a *.exe base, I want my UI to re-write my STUB by setting user-defined options, thus creating a new executable that will work according to the options the user has chosen.

The only type of application I can remember to have such functionality are the Rats (Remote Administration Tools) and some Keyloggers, in which you can create a remote connection server to control a computer, and in this creation you can define several options (your ip, installation location, etc.). Connection servers are also generated from a *.exe base.

I took a random image from google to illustrate, in it, there is a customization window of a RAT (Note that the last tab is precisely the construction of *.exe with preset settings):

inserir a descrição da imagem aqui

@UPDATE: I don’t know if it helps but, by going through prehistoric codes I found a code on VB6 that does something similar. It takes one the STD.exe file that initially does nothing and on top of it creates another (RWSTD.exe) adding a Msgbox() when it starts. I have tried to research the function of these lines of code and try to replicate in C#, but without success. Look at the codes:

Customer UI:

Private Sub Command1_Click()

    Dim STD As String, RWSTD As String, MID As String, DEL As String
    DEL = "DELIMITADOR"

    Open App.Path & "\STD.exe" For Binary As #1
    STD = Space(LOF(1))
    Get #1, , STD
    Close #1

    If FileExists(App.Path & "\RWSTD.exe") Then
        Kill App.Path & "\RWSTD.exe"
    End If

    Open App.Path & "\RWSTD.exe" For Binary As #1
    RWSTD = Space(LOF(1))
    Get #1, , RWSTD
    Put #1, , STD & DEL & txtMsgBox.Text
    Close #1

End Sub

Private Sub Form_Load()
    If Not FileExists("STD.exe") Then
        Unload Me
    End If
End Sub

STB.exe:

Sub Starter()
    Dim DATA As String, DEL() As String, i As Long

    Open App.Path & "\" & App.EXEName & ".exe" For Binary As #1
    DATA = Space(LOF(1))
    Get #1, , DATA
    Close #1

    DEL() = Split(DATA, "DELIMITADOR")

    For i = 1 To UBound(DEL)
        If Not (DEL(i) = "MZ") Then
            MsgBox (DEL(i))
        End If
    Next
End Sub
  • I don’t even want to pass/recover files to another executable per run. What I wish to do and is written in the question is to rebuild my stub with some specific options, ie it would generate a new *.exe upon the stub, however, with the modifications that the user has made to the client.

  • A functional example of what I exactly want is the operation of a RAT (Remote Administration Tool), in it, there is a stub that originates all the created servers, however, you can customize the options and build a new executable whenever you want. Thus, we can take as an example an executable that will install on the Desktop and another on %appdata%, however, both were generated from the same base (stub).

  • Got it, I’ve seen something like that on the show deep freeze, from it you generate a executable that will be installed on the client machine

  • try to be a little clearer in the question, it is an interesting subject and if it is not clear enough, it will be closed. I will follow the question

  • I tried to explain as much as I could, I added the Rats part. Thanks for the help.

  • There are also some keyloggers that work like this. You have the main application, and generate a new executable with the options chosen by you. This executable, once installed on the client, will follow the information you determined by the main application. Just one more example to try to help explain.

  • I can’t explain more than that.

Show 4 more comments

1 answer

1


If you want to change string values that are inside the executable, you can do the following:

1) Convert the executable to an IL file (Intermediate language);
2) Search/replace the IL file.
3) Recompile the IL to generate the new executable.

The . NET SDK has the tool Ildasm.exe to make that conversion.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.