EDN Admin
Well-known member
Hello, Ive been working on a project for a while on a program that functions like a remote administrator tool. I have many commands that go back and forth between the client and server via LAN. What I need help with is I need a line of code that allows
me to send and receive files via my Winsock connection, and no I am not going to use the socket commands that come with VB Studios, Winsock is much easier. Any ideas? Here is some of my example code:
<pre class="prettyprint lang-vb" style=" Private Sub Winsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Winsock1.DataArrival
Dim data As String = ""
Dim opt() As String
Winsock1.GetData(data)
If data = "Connection Request" Then Hand-Shake
On Error Resume Next
Winsock2.Close()
Winsock2.Connect(Winsock1.RemoteHostIP, 666)
End If
Me.Text = data
opt = Split(data, "^") Seperates commands
~~~~~~~~~~~~~~~~~~~~~~~COMMANDS~~~~~~~~~~~~~~~~~~~~~~~
Select Case opt(0)
Case "disable"
Form4.Show()
Case "exit"
Winsock2.SendData("Bye!")
Me.Close()
Case "whoami"
Winsock2.SendData("You are " & Winsock1.LocalHostName & " with the IP: " & Winsock1.LocalIP)
Case "c"
On Error GoTo h1
Shell("cmd.exe /c" & opt(1), opt(2))
GoTo b
Case "C"
On Error GoTo h1
Shell(opt(1))
GoTo b
h1:
Winsock2.SendData("Usage: c^command^show cmd window (int 1 or 0)")
Case "chat"
Form3.Show()
Case "gui"
Winsock2.SendData("Running Gui")
Case "nc"
On Error GoTo c
Shell("nc " & opt(1))
Winsock2.SendData("Running netcat.")
GoTo b
c:
Winsock2.SendData("Cant do that, I got an error.")
Case "refresh"
Winsock2.SendData("Refreshing as we speak...")
Form2.Show()
Me.Close()
Case "say"
Winsock2.SendData(opt(1))
Case "send file" <-------------------- HERE
Winsock2.SendFile(opt(1))
Case "shutdown"
On Error GoTo c
Shell("Shutdown" & opt(1))
Winsock2.SendData("Shutting down now.")
Case "shutdown -a"
Shell("Shutdown -a")
Winsock2.SendData("Shutting down should be stopped.")
Case "msgbox"
On Error GoTo a
MsgBox(opt(1), opt(2), opt(3))
GoTo b
a:
Winsock2.SendData("Thats not how it goes! Its: ")
Winsock2.SendData(" msgbox^bodytext^boxtype^title For example")
Winsock2.SendData(" msgbox^I read your email.^16^User")
b:
Case Else
Winsock2.SendData("Command not found.")
End Select
End Sub[/code]
<br/>
<br/>
View the full article
me to send and receive files via my Winsock connection, and no I am not going to use the socket commands that come with VB Studios, Winsock is much easier. Any ideas? Here is some of my example code:
<pre class="prettyprint lang-vb" style=" Private Sub Winsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Winsock1.DataArrival
Dim data As String = ""
Dim opt() As String
Winsock1.GetData(data)
If data = "Connection Request" Then Hand-Shake
On Error Resume Next
Winsock2.Close()
Winsock2.Connect(Winsock1.RemoteHostIP, 666)
End If
Me.Text = data
opt = Split(data, "^") Seperates commands
~~~~~~~~~~~~~~~~~~~~~~~COMMANDS~~~~~~~~~~~~~~~~~~~~~~~
Select Case opt(0)
Case "disable"
Form4.Show()
Case "exit"
Winsock2.SendData("Bye!")
Me.Close()
Case "whoami"
Winsock2.SendData("You are " & Winsock1.LocalHostName & " with the IP: " & Winsock1.LocalIP)
Case "c"
On Error GoTo h1
Shell("cmd.exe /c" & opt(1), opt(2))
GoTo b
Case "C"
On Error GoTo h1
Shell(opt(1))
GoTo b
h1:
Winsock2.SendData("Usage: c^command^show cmd window (int 1 or 0)")
Case "chat"
Form3.Show()
Case "gui"
Winsock2.SendData("Running Gui")
Case "nc"
On Error GoTo c
Shell("nc " & opt(1))
Winsock2.SendData("Running netcat.")
GoTo b
c:
Winsock2.SendData("Cant do that, I got an error.")
Case "refresh"
Winsock2.SendData("Refreshing as we speak...")
Form2.Show()
Me.Close()
Case "say"
Winsock2.SendData(opt(1))
Case "send file" <-------------------- HERE
Winsock2.SendFile(opt(1))
Case "shutdown"
On Error GoTo c
Shell("Shutdown" & opt(1))
Winsock2.SendData("Shutting down now.")
Case "shutdown -a"
Shell("Shutdown -a")
Winsock2.SendData("Shutting down should be stopped.")
Case "msgbox"
On Error GoTo a
MsgBox(opt(1), opt(2), opt(3))
GoTo b
a:
Winsock2.SendData("Thats not how it goes! Its: ")
Winsock2.SendData(" msgbox^bodytext^boxtype^title For example")
Winsock2.SendData(" msgbox^I read your email.^16^User")
b:
Case Else
Winsock2.SendData("Command not found.")
End Select
End Sub[/code]
<br/>
<br/>
View the full article