twitchyliquid64 23 Posted January 15, 2011 Hi all, I have a TCP packet of variable length coming in. I need a way to get the first four bytes of the message, and bytes 8-12 and whatnot. separataly, so they can be interpreted separately. http://capnbry.net/gnutella/protocol.php And after that, I need a way to recreate the packets. I heard that I can use bitAND and bit shifting, but how would I actually do this? Thanks in advance. Hypoz ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Share this post Link to post Share on other sites
PsaltyDS 39 Posted January 15, 2011 What form do you have the TCP packet in? Post a short demo script that gets the packets in the first place, then you can get help in manipulating it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
twitchyliquid64 23 Posted January 15, 2011 What form do you have the TCP packet in? Post a short demo script that gets the packets in the first place, then you can get help in manipulating it. I don't think I have been consise enough. The data contained in the TCP packet could just be obtained with$data = TCPRecv( $sock, 1024)as usual.I would hold the data in a variable as above, and the data needs to be split into bytes from there. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Share this post Link to post Share on other sites
PsaltyDS 39 Posted January 15, 2011 Then it's just BinaryMid(): $data = Binary("0xFEDCBA9876543210") ; Simulated TCP binary data $binFirst = BinaryMid($data, 1, 4) $binLast = BinaryMid($data, BinaryLen($data) - 3, 4) MsgBox(64, "Results", "First four bytes = " & $binFirst & @CRLF & _ "Last four bytes = " & $binLast) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites