Linx Guest Status: 
Add Rep
0
|
Posted: Fri Jun 30, 2006 2:14 pm Post subject: Basic VB Trojan Part 2 - Client Design & Source |
|
|
Welcome to part 2. Our server is all designed and the client is all that’s left before you have the basis for a “Network Administration Tool”
Right now to design and code the client. The client is the utility that communicates with the server to perform remote tasks on the target machine. Now you can make it look as snazzy and high tech as you want but if you don’t code it right then what is the point huh?
So weve established in the last tutorial that the client and server will both need a winsock control to establish a connection over the network, so open up a new VB standard exe project and put a winsock control in there and call it “WS_Client”.
We need to be able to enter a desired IP address to connect to the machine so add a text field and label it “txtip”. We are also going to need a connect button, so add a button and call it “cmdconnection”. This will enable us to send a request to connect. We are also going to need a text field to specify the port number. Insert a text field and call it “txtport”.
Now you can arrange these in whatever fashion you like to make it look aesthetically pleasing.
Now for the initial code. The code to connect will be run when you click the connect button so the following code is inserted.
Private Sub CMDCONNECTION_Click()
If cmdconnection.Caption = "Connect" Then
WS_Client.Close
WS_Client.RemoteHost = txtip.Text
WS_Client.RemotePort = txtport.Text
WS_Client.Connect
cmdconnection.Caption = "Disconnect"
Else
WS_Client.Close
Me.Caption = "Not connected"
cmdconnection.Caption = "Connect"
End If
End Sub
EXPLANATION (What are you telling the computer to do):
When cmdconnection button is clicked
If on the button it says “Connect” then
I want you to close all current connections
Set the remote host IP with the value in txtip
Set the remote port number with the value of txtport
Then attempt to connect
HOWEVER IF THESE CONDITIONS ARE NOT MET
Close all connections
Make the form state its not connected at the top
Change the caption on the connection button to “Connect”
That’s the code in a nutshell to connect to a remote host.
You may want to add a little bit of code like:
Private Sub WS_Client _Connect()
Me.Caption = "Connected"
End Sub
Which will basically change the title of the window to “Connected” when a connection is established.
Now when we were making the server we coded in a function so that when we send a bit of data that says “hellomessage” it triggers a response from the server local to the target.
So we need a button for this one. Make another button and call it “cmdhello”. The code for this button is listed below.
Private Sub CMDHELLO_Click()
On Error GoTo ErrorAlarm
WS_Client.SendData "hellomessage"
Exit Sub
ErrorAlarm:
MsgBox "You are not connected, please connect first"
End Sub
EXPLANATION (What are you telling the computer to do?):
When I click on the cmdhello button I want you to perform the following
By the way if there is an error skip all of this and go to ErrorAlarm.
I want to send data “hellomessage” over the current connection
That’s all I want you to do
If however there was an error this is what I want you to do
Bring up a message box and tell me "You are not connected, please connect first"
That’s all
Done and dusted, your client and server are now fully functional.
If you have any inspiring ideas to add to this, please feel free to post them. Im putting together a team to design a network administration tool alongside my virus studies.
If you have any questions please do mail me my contacts at the bottom of this post.
Best of luck, Jah bless and all other pleasantries
Linx
|
|