DoctorSLO Posted February 16, 2009 Share Posted February 16, 2009 Hi. I want to send data back like this packet (from Wireshark). How can I do that? I tryed to send some Hex code, but its not work .... So how can I send data with TCPSend, and it must looks like this: from Wireshark: 0000 00 00 01 00 00 00 dc ef 20 00 01 00 08 00 45 00 ........ .....E. 0010 00 68 3d d6 40 00 37 06 02 49 59 92 d7 ca 59 8f .h=.@.7..IY...Y. 0020 78 85 34 19 11 09 90 dc 9a 8a ae f2 70 fd 50 18 x.4.........p.P. 0030 00 5c 6d 77 00 00 67 c6 69 73 51 ff 4a ec 29 cd .\mw..g.isQ.J.). 0040 ba ab f2 fb e3 46 7c c2 54 f8 1b e8 e7 8d 76 5a .....F|.T.....vZ 0050 2e 63 33 9f c9 9a 66 32 0d b7 31 58 a3 5a 25 5d .c3...f2..1X.Z%] 0060 05 17 58 e9 5e d4 ab b2 cd c6 9b b4 54 11 8f 9f ..X.^.......T... 0070 07 b0 42 fa 9f 6d ..B..m Here is code in autoit: TCPStartup() $Glavna = TCPListen("89.146.215.202", 13337, 100) While 1 $Povezan = TCPAccept($Glavna) If $Povezan >= 0 Then $Sprejem = TCPRecv($Povezan, 100000000) Sleep(500) TCPSend($Povezan, Hex("67c6697351ff4aec29cdbaabf2fbe3467cc254f81be8e78d765a2e63339fc99a66320db73158a35a255d051758e95ed4abb2cdc69bb454118f9f07b042fa9f6d")) TCPShutdown() Exit EndIf WEnd Link to comment Share on other sites More sharing options...
LarryDalooza Posted February 16, 2009 Share Posted February 16, 2009 can't think of what mechanism there is to go from hex to binary string... so I kicked this up... Global $a $a = Binary($a) $sHex = "000001000000dcef200001000800450000683dd6400037060249599" & _ "2d7ca598f78853419110990dc9a8aaef270fd5018005c6d77000067c66973" & _ "51ff4aec29cdbaabf2fbe3467cc254f81be8e78d765a2e63339fc99a66320" & _ "db73158a35a255d051758e95ed4abb2cdc69bb454118f9f07b042fa9f6d" While StringLen($sHex) $a &= Chr(Dec(StringLeft($sHex,2))) $sHex = StringTrimLeft($sHex,2) WEnd MsgBox(4096,"","Now TCPSend($Povezan,$a)") AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
trancexx Posted February 16, 2009 Share Posted February 16, 2009 From here:expandcollapse popupConsoleWrite(_BinaryToHexASCIIAddr("0x67c6697351ff4aec29cdbaabf2fbe3467cc254f81be8e78d765a2e63339fc99a66320db73158a35a255d051758e95ed4abb2cdc69bb454118f9f07b042fa9f6d") & @CRLF) Func _BinaryToHexASCIIAddr($bInput) $bInput = Binary($bInput) Local $tInput = DllStructCreate("byte[" & BinaryLen($bInput) & "]") DllStructSetData($tInput, 1, $bInput) Local $a_iCall = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword", 11, _ ; CRYPT_STRING_HEXASCIIADDR "ptr", 0, _ "dword*", 0) If @error Or Not $a_iCall[0] Then Return SetError(1, 0, "") EndIf Local $iSize = $a_iCall[5] Local $tOut = DllStructCreate("char[" & $iSize & "]") $a_iCall = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword", 11, _ "ptr", DllStructGetPtr($tOut), _ "dword*", $iSize) If @error Or Not $a_iCall[0] Then Return SetError(2, 0, "") EndIf Return SetError(0, 0, DllStructGetData($tOut, 1)) EndFunc ;==>_BinaryToHexASCIIAddr ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now