sockets - C# Getting packet data -
I am trying to write a script that can snap the HTTP header. So far I have got socket at 80 port and starts getting the packets, but I can not get them in the string form. All the outputs are "e" consistently, I have changed the byte first and some data is coming in, but the current code is unable to convert the bytes to string. Is there another way to decode a byte that will give the proper string?
byte [] input = bitconverter.getbytes (1); Byte [] buffer = new byte [4096]; Socket S = New Socket (Address Family.Inter Network, SocketType.Raw, Protocol Type .IP); S.Bind (new IPPD (IPAddress.Parse (strIP), 80)); S.IOControl (IOControlCode.ReceiveAll, input, tap); Int bytes; Bytes = S. Reception (buffer); While (bytes> 0) {log (systemtext.excoding.assici.getstring (buffer, 0, bytes)); Bytes = S. Reception (buffer); }
when you use the raw socket Sniffing, you are receiving Internet Protocol (IP) packets that begin with each IP packet This header is usually 20 bytes long, but it can be longer than that. Header for the transport layer after the IP header, for example, (TCP) header or (UDP) header, the data you are looking for after this header, i.e., HTTP, so when you are parsing the data, You must first leave the IP header and the transport layer header.
Comments
Post a Comment