开发者

Howto convert to string and read data from TCP packet

开发者 https://www.devze.com 2022-12-27 00:35 出处:网络
I used sharppcap to capture TCP packets. Now i wanna reconstruct HTTP packet from TCP packets but i don\'t know how. I read somewhere i can find star开发者_Go百科t of HTTP packet in TCP data... i trie

I used sharppcap to capture TCP packets. Now i wanna reconstruct HTTP packet from TCP packets but i don't know how. I read somewhere i can find star开发者_Go百科t of HTTP packet in TCP data... i tried to convert byte[] TCP data to string using this code: string s = System.Text.Encoding.UTF8.GetString(tcp_pack.Data); but the string isn't readable. like a binary file that is opened with notepad. is it because the data is encrypted or code is incorrect? how can i reconstruct HTTP packet from TCP packets?


try "Encoding.BigEndianUnicode.GetString(tcp_pack.Data)"


There is no easy way do to this because you'll need to reconstruct the TCP session in memory.

Essentially, if a message being sent is larger than one packet, it's broken up into multiple packets. Therefore, you'll need to capture those packets, arrange them in the right order, and reassemble the data manually.

If the message is short/simple and doesn't get broken up into multiple parts then you'll need to find out what format the payload is in. Try decoding in ASCII first.

0

精彩评论

暂无评论...
验证码 换一张
取 消