Jump to content

How to send a packet with autoit?


Recommended Posts

Greetings,

Lately I been using a packet sniffer to receive and send packets to servers.

I was wondering how do I send the packet "0C 00 51 66 65 47 62 61 FF 0C AC 40"

to a server with the IP Address of 128.241.92.43 and port of 29200 using AutoIT

Here is my nooby failed attempt:

$Hex = "0C 00 51 66 65 47 62 61 FF 0C AC 40 "
 $g_IP = "128.241.92.43"
;~ ; Start The TCP Services :
;============================
TCPStartUp()
;~ ; Connect to "SOCKET" :
;=========================
$socket = TCPConnect( $g_IP, 29200 )
If $socket = -1 Then MsgBox (0,"TCP Services","Can't make connection")
TCPSend($socket,$Hex)
;~ ; Shutdown The TCP Services :
;===============================
TCPShutdown ( )

I searched around forums to get that attempt =)

Edited by BlazerV60
Link to comment
Share on other sites

Greetings,

Lately I been using a packet sniffer to receive and send packets to servers.

I was wondering how do I send the packet "0C 00 51 66 65 47 62 61 FF 0C AC 40"

to a server with the IP Address of 128.241.92.43 and port of 29200 using AutoIT

Here is my nooby failed attempt:

$Hex = "0C 00 51 66 65 47 62 61 FF 0C AC 40 "
 $g_IP = "128.241.92.43"
;~ ; Start The TCP Services :
;============================
TCPStartUp()
;~ ; Connect to "SOCKET" :
;=========================
$socket = TCPConnect( $g_IP, 29200 )
If $socket = -1 Then MsgBox (0,"TCP Services","Can't make connection")
TCPSend($socket,$Hex)
;~ ; Shutdown The TCP Services :
;===============================
TCPShutdown ( )

I searched around forums to get that attempt =)

So my Final piece of code should look like this

$packet= "0C00516665476261FF0CAC40"
 $g_IP = "128.241.92.43"
;~ ; Start The TCP Services :
;============================
TCPStartUp()
;~ ; Connect to "SOCKET" :
;=========================
$socket = TCPConnect( $g_IP, 29200 )
If $socket = -1 Then MsgBox (0,"TCP Services","Can't make connection")
TCPSend($socket,_HexToString($packet)) ;_HexToString is String.au3
;~ ; Shutdown The TCP Services :
;===============================
TCPShutdown ( )

I tried running that with the help of your info above and I get no errors at all and it successfully connects to the right ip/port but the packet isn't giving me any results. I know I have the right packet, does anyone know why the packet won't work right?

Link to comment
Share on other sites

How do you know the packet sent isn't getting you any results? Which is to say, what result are you expecting and how are you checking for that result?

Are you connected to this server in a secondary application and hoping that the packet sent from your script will have an impact in the secondary application? If so you would have to send that packet on the connection created with that application, not a new connection.

Just a thought, no idea on your code, if its not giving you any errors then it presumably works and you don't say how you're checking for your expected result?

Link to comment
Share on other sites

Are you connected to this server in a secondary application and hoping that the packet sent from your script will have an impact in the secondary application? If so you would have to send that packet on the connection created with that application, not a new connection.

Your exactly right, thats what I'm doing.

How do I send the packet on the connection created with that application?

Link to comment
Share on other sites

I don't know how to do that but maybe someone will post something to point you in the right direction.

I would assume you would need to create memory space in the secondary application and inject your own code that would be able to read/write from that clients tcp connections and interact with your own secondary application. This is just my guess.

Link to comment
Share on other sites

I don't know how to do that but maybe someone will post something to point you in the right direction.

I would assume you would need to create memory space in the secondary application and inject your own code that would be able to read/write from that clients tcp connections and interact with your own secondary application. This is just my guess.

The Ip address and port that I have in the code is the info for the server that I'm connecting to that I'm trying to send the packet to.

Link to comment
Share on other sites

The Ip address and port that I have in the code is the info for the server that I'm connecting to that I'm trying to send the packet to.

What has ben suggested is that the port the legit app is using to speak to the server, is the only one it will except packets from or act on. Since you cannot have 2 apps using the same port, you would have to use Autoit witchcraft to masquerade as the legit app.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

What has ben suggested is that the port the legit app is using to speak to the server, is the only one it will except packets from or act on. Since you cannot have 2 apps using the same port, you would have to use Autoit witchcraft to masquerade as the legit app.

Hmm that is true, my AutoIt program is trying to connect to a IP Address/port that is already being taken up by the original program. Which means that the server will only take packets from the original program that it was meant to receive packets from.

How do I make my AutoIt program seem like the original program? :blink: Or maybe there is another way to send packets to that server with my AutoIt program? Can I make my AutoIt program send packets to the Process ID of the program I want it to get sent to. Note: Process Id is the numbers in the task manager next to the program.

Link to comment
Share on other sites

server

TCPStartup()

HotKeySet("{Esc}", "_Close")

$ip = @IPAddress1;try $IPAddress2/3/4 if this doesn't work
$port = 29200

$listen = TCPListen($ip, $port)

While 1
    $accept = TCPAccept($listen)
    If $accept <> -1 Then
        ToolTip($accept & " has conncected")
        ExitLoop
    EndIf
WEnd

While 1
    $recv = TCPRecv($accept, 1024)
    If @error Then;connection lost
        ToolTip("lost connection between " & $accept)
    EndIf
    If $recv <> "" Then;if received something
        ToolTip("received this: '" & $recv & "'")
        Sleep(3000)
        _Close()
    EndIf
WEnd

Func _Close()
    TCPShutdown()
    Exit
EndFunc

user

TCPStartup()

HotKeySet("{Esc}", "_Close")

$ip = @IPAddress1;could be your "real" ip address (whatismyip.com). you will need to port forward if you have a router
$port = 29200

$connect = TCPConnect($ip, $port)
If @error Then
    ToolTip("could not connect to " & $ip)
    Sleep(1000)
    _Close()
EndIf

$data = "0C 00 51 66 65 47 62 61 FF 0C AC 40 "

TCPSend($connect, $data)

Sleep(3000)
_Close()

Func _Close()
    TCPShutdown()
    Exit
EndFunc
Link to comment
Share on other sites

server

TCPStartup()

HotKeySet("{Esc}", "_Close")

$ip = @IPAddress1;try $IPAddress2/3/4 if this doesn't work
$port = 29200

$listen = TCPListen($ip, $port)

While 1
    $accept = TCPAccept($listen)
    If $accept <> -1 Then
        ToolTip($accept & " has conncected")
        ExitLoop
    EndIf
WEnd

While 1
    $recv = TCPRecv($accept, 1024)
    If @error Then;connection lost
        ToolTip("lost connection between " & $accept)
    EndIf
    If $recv <> "" Then;if received something
        ToolTip("received this: '" & $recv & "'")
        Sleep(3000)
        _Close()
    EndIf
WEnd

Func _Close()
    TCPShutdown()
    Exit
EndFunc

user

TCPStartup()

HotKeySet("{Esc}", "_Close")

$ip = @IPAddress1;could be your "real" ip address (whatismyip.com). you will need to port forward if you have a router
$port = 29200

$connect = TCPConnect($ip, $port)
If @error Then
    ToolTip("could not connect to " & $ip)
    Sleep(1000)
    _Close()
EndIf

$data = "0C 00 51 66 65 47 62 61 FF 0C AC 40 "

TCPSend($connect, $data)

Sleep(3000)
_Close()

Func _Close()
    TCPShutdown()
    Exit
EndFunc

That looks like some code that will work :blink:.

The server I'm trying to connect to has an ip address and port. But I only see you include the port of the server in that code, do you need to include the ip address of that server too? Or do I only put my ip address in it?

Link to comment
Share on other sites

Use the second script if you'd like to send data to any server.

$ip should be the IP address of the server you want to connect to.

OO

So your first script is for me to receive data

and second script is for me to send data? :blink:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...