Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51746

How do I deal with packet data

Newsgroups comp.lang.python
Date 2013-08-01 10:37 -0700
Message-ID <48c837f0-3626-48cd-8d9c-255e2c4ed797@googlegroups.com> (permalink)
Subject How do I deal with packet data
From Pacopag <chris.pagnutti@gmail.com>

Show all headers | View raw


Hi.

I have the hex stream of a packet that a program sent over the network.  Now I want to view the data in the packet.  I'm pretty sure the data was just a string (or at least contains a string), but when I decode it I just get gibberish.

For example, the packet is sent something like this

import socket

s = socket.socket()
s.connect(hostname,port)
data = "HeresAStringToSend"
s.send(data)
# I'm not worried about receiving yet.  
# I just want to know the anatomy of a sent packet.


Then I use a packet sniffer to look at the packet that was sent; this is just a string of hex.  Then I isolate the data part of the packet.  Let's say the data part of the hex string is in a variable called hexdata.

If I do,

print hexdata.decode("hex")

all I get is gibberish.  Looking at the individual bytes in the hex data, they map to strange or invalid ascii codes (e.g. less than 32 or greater than 127).

I'm new to all this socket/packet stuff, so I don't really know what the s.send(data) method does to the data before sending it.

Any help or insight would be great.  Thanks.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How do I deal with packet data Pacopag <chris.pagnutti@gmail.com> - 2013-08-01 10:37 -0700
  Re: How do I deal with packet data Dave Angel <davea@davea.name> - 2013-08-01 19:42 +0000

csiph-web