Sign in to follow this  
Followers 0
Glyph

TCP Packet information and Hex

12 posts in this topic

#1 ·  Posted (edited)

I'm trying to send Hex("00"), but instead it screws up my whole packet and writes this:

"30 32 33 30 30 30 30 30 34 36 41 31 38 43 30 43 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 32 30 30 30 30 30 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 39 30 30 30 30 30 30 30 34 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 39 30 30 30 30 30 30 30 34 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 33 37 30 30 30 30 30 30 33 35 30 30 30 30 30 30 32 39 30 30 30 30 30 30 30 30 30 30 30 30 30 30 33 37 30 30 30 30 30 30 30 36 30 30 30 30 30 30 34 35 30 30 30 30 30 30 34 41 30 30 30 30 30 30 34 31 30 30 30 30 30 30 34 30 30 30 30 30 30 30 31 34 30 30 30 30 30 30 33 35 30 30 30 30 30 30 34 41 30 30 30 30 30 30 33 44 30 30 30 30 30 30 34 41 30 30 30 30 30 30 34 31 30 30 30 30 30 30 34 39 30 30 30 30 30 30 30 30 "

Instead of this:

TCPSend($ConnectedSocket,hex("FF",1)&hex("50",1)&hex("3A",1)&hex("00",1)&hex("00",1)&hex("00",1)&hex("00",1)&hex("00",1)&hex("36",1)&hex("38",1)&hex("58",1)&hex("49",1)&hex("56",1)&hex("44",1)&hex("32",1)&hex("44",1)& _ 
        Hex("0B")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("00")&Hex("2C")&Hex("01")&Hex("00")&Hex("00")& _ 
        Hex("09")&Hex("04")&Hex("00")&Hex("00")&Hex("09")&Hex("04")&Hex("00")&Hex("00")&Hex("55")&Hex("53")&Hex("41")&Hex("00")&Hex("55")&Hex("6E")&Hex("69")&Hex("74")& _ 
        Hex("65")&Hex("64")&Hex("20")&Hex("53")&Hex("74")&Hex("61")&Hex("74")&Hex("65")&Hex("73")&Hex("00"))
Edited by BackStabbed

tolle indicium

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The parameter for Hex is a number not a string so use Hex(0x0b) not Hex("0b").

The value of a string will be just the leading numbers so Hex("FF") evaluates to Hex(0) and the ACSII code for 0 is 30, Hex("50") evaluates to Hex(0x32) but you have specified 1 character so the result is 2 and the ASCII code for 2 is 32, so you get 30 32 ... as you showed.

If you are then just converting it all to a string you only need to say

"0B" & "00" & "00" & ....

However, you want to send the binary values for each byte so maybe this works

TCPSend($ConnectedSocket,Binary("0x" & "ff" & "50 &..."))

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This sends an hex packet:

$Hex = "AA 00 13 7E 1B 43 4F 4E 4E 45 43 54 45 44 20 53 45 52 56 45 52 0A "
$Str = StringSplit($Hex," ")
$Hex = ''
For $x = 1 to $Str[0]
    If $Str[$x] Then
        $Hex &= Chr((Dec($Str[$x])))
    EndIf
Next
MsgBox(0, "", "Click OK to start, make sure you have a packet scanner ready!")
$ReturnTCPStartup = TCPStartup()
$IP = TCPNameToIP("www.google.com")
$Socket = TCPConnect($IP,80)
TCPSend($Socket,$Hex)
MsgBox(0, "", "IP: " & $IP & @CRLF & "TCPStartup return: " & $ReturnTCPStartup & @CRLF & "Connected: "  & $Socket & @CRLF & "Message: " & $Hex)

Share this post


Link to post
Share on other sites

This sends an hex packet:

$Hex = "AA 00 13 7E 1B 43 4F 4E 4E 45 43 54 45 44 20 53 45 52 56 45 52 0A "
$Str = StringSplit($Hex," ")
$Hex = ''
For $x = 1 to $Str[0]
    If $Str[$x] Then
        $Hex &= Chr((Dec($Str[$x])))
    EndIf
Next

You had me worried that my post was wrong so I tried this

$aHex = "AA 00 13 7E 1B 43 4F 4E 4E 45 43 54 45 44 20 53 45 52 56 45 52 0A "
$Str = StringSplit($aHex," ")
$Hex = ''
For $x = 1 to $Str[0]
    If $Str[$x] Then
        $Hex &= Chr((Dec($Str[$x])))
    EndIf
Next
;compare $Hex to method in  previous post
$Ahex = stringreplace($Ahex,' ','')
if $hex = binary("0x" & $Ahex) then consolewrite("same thing")

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

TCPSend($ConnectedSocket,hex(0xFF,1)&hex(0x50,1)&hex(0x3A,1)&hex(0x00,1)&hex(0x00,1)&hex(0x00,1)&hex(0x00,1)&hex(0x00,1)&hex(0x36,1)&hex(0x38,1)&hex(0x58,1)&hex(0x49,1)&hex(0x56,1)&hex(0x44,1)&hex(0x32,1)&hex(0x44,1)& _ 
        Hex(0x0B,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x2C,1)&Hex(0x01,1)&Hex(0x00,1)&Hex(0x00,1)& _ 
        Hex(0x09,1)&Hex(0x04,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x09,1)&Hex(0x04,1)&Hex(0x00,1)&Hex(0x00,1)&Hex(0x55,1)&Hex(0x53,1)&Hex(0x41,1)&Hex(0x00,1)&Hex(0x55,1)&Hex(0x6E,1)&Hex(0x69,1)&Hex(0x74,1)& _ 
        Hex(0x65,1)&Hex(0x64,1)&Hex(0x20,1)&Hex(0x53,1)&Hex(0x74,1)&Hex(0x61,1)&Hex(0x74,1)&Hex(0x65,1)&Hex(0x73,1)&Hex(0x00,1))

Still sends:

46 30 41 30 30 30 30 30 36 38 38 39 36 34 32 34 42 30 30 30 30 30 30 30 30 30 30 30 43 31 30 30 39 34 30 30 39 34 30 30 35 33 31 30 35 45 39 34 35 34 30 33 34 31 34 35 33 30


tolle indicium

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

TCPSend($ConnectedSocket,hex(0xFF,1)&....0x74,1)&Hex(0x61,1)&Hex(0x74,1)&Hex(0x65,1)&Hex(0x73,1)&Hex(0x00,1))

Still sends:

46 30 41 30 30 30 30 30 36 38 38 39 36 34 32 34 42 30 30 30 30 30 30 30 30 30 30 30 43 31 30 30 39 34 30 30 39 34 30 30 35 33 31 30 35 45 39 34 35 34 30 33 34 31 34 35 33 30

[\quote]

I explained in my earlier post why it doesn't work so have another look at what I said. Hex(0xFF,1) is "F" and the code for F is 46. Hex(0x50) is "50" but Hex(ox50,1) is "0" and the code for 0 is 30 and so on.

There was a way to deal with sending the data in my post and in Manadar's post so why not try one of them?

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This sends an hex packet:

$Hex = "AA 00 13 7E 1B 43 4F 4E 4E 45 43 54 45 44 20 53 45 52 56 45 52 0A "
$Str = StringSplit($Hex," ")
$Hex = ''
For $x = 1 to $Str[0]
    If $Str[$x] Then
        $Hex &= Chr((Dec($Str[$x])))
    EndIf
Next
MsgBox(0, "", "Click OK to start, make sure you have a packet scanner ready!")
$ReturnTCPStartup = TCPStartup()
$IP = TCPNameToIP("www.google.com")
$Socket = TCPConnect($IP,80)
TCPSend($Socket,$Hex)
MsgBox(0, "", "IP: " & $IP & @CRLF & "TCPStartup return: " & $ReturnTCPStartup & @CRLF & "Connected: "  & $Socket & @CRLF & "Message: " & $Hex)
Thank's for that great hex packet sender, it's very useful...

PS: search & found.... Thank you Manadar ^^


[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

interesting... i wonder why not use :

$bin="0xAA00137E1B434F4E4E4543544544205345525645520A"
MsgBox(0, "", "Click OK to start, make sure you have a packet scanner ready!")
$ReturnTCPStartup = TCPStartup()
$IP = TCPNameToIP("www.google.com")
$Socket = TCPConnect($IP,80)
TCPSend($Socket,$bin)
MsgBox(0, "", "IP: " & $IP & @CRLF & "TCPStartup return: " & $ReturnTCPStartup & @CRLF & "Connected: "  & $Socket & @CRLF & "Message: " & $bin)oÝ÷ Ù©ÝÓ4jÆâªòË"^¶µ«­¢+Ù    ¥¹Éå5¥ À°Ð¤(í½È½ÈáµÁ±ÁáÌ)  ¥¹Éå5¥ ÁáÌ°Ä°Ä¤í¤¡Áɽ±´Ý¡É¤¹Ñ¼µ­Á­ÐÝ¥Ñ ¥¹Éäѵ¹Õ±±ä¹¥¤¥¸ÌäíÐÕÍÑ¡¥Ì¥Ðݽձ©ÕÍн¹Í¥ÉÌÍÑÉ¥¹)áµÁ±è(ÀÌØíÑÍÐôÁáÌ(ÀÌØí¹Õ±°õ  ¥¹Éä À¤)5Í   ½à À°ÅÕ½ÐìÄÅÕ½Ðì°ÀÌØíÑÍеÀìÀÌØí¹Õ±°¤(ÀÌØíÑÍÐÈõ  ¥¹Éä ÀÌØíÑÍФ)5Í   ½à À°ÅÕ½ÐìÈÅÕ½Ðì°ÀÌØíÑÍÐȵÀìÀÌØí¹Õ±°¤(ÀÌØíÑáÐÌõ    ¥¹Éå5¥ ÀÌØíÑÍаİĤ)5Í    ½à À°ÅÕ½ÐìÌÅÕ½Ðì°ÀÌØíÑáÐ̵ÀìÀÌØí¹Õ±°¤(í½¹±äÑ¡Ñ¡¥É¥Ì½ÉÉÐ褥å½Ô½¹±ä¹Áá̹¹½ÐÁáÌÀÀÀÀÀ
Edited by Xand3r

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

i really don't know much about binary and hex stuff's but i think the code from Manadar is convert the RAW Hex to string...

but now i have another question's , it's better to open my own POST to ask someone there :)

Edited by Basicz

[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Share this post


Link to post
Share on other sites

... but know i have another question's , it's better to open my own POST to ask someone there :)

This has never been answered for this forum. You can do whatever you wish - short of going far off topic (hijacking).

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

This has never been answered for this forum. You can do whatever you wish - short of going far off topic (hijacking).

don't understand what you mean *SORRY* :)


[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Share this post


Link to post
Share on other sites

... it's better to open my own POST to ask someone there

Sorry. I see now that I was not clear.

I was saying that you can open your own post or continue in this thread if your question is somewhat related.

When I asked, "Which would the forum mods prefer - post to an old thread or make a new one."

The answer was, "Either way".

I personally do not care, but I've seen people ask members why they posted to an old thread... even when the new post was related to the old thread.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0