Sign in to follow this  
Followers 0
twitchyliquid64

Getting the first four bytes from a packet of variable length?

4 posts in this topic

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



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.

:x


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

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.

:x

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

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)

:x


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

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