How to get packet.tcp.payload and packet.http.data as string?

Ashish Jha

The return value for these attributes are in hex format seperated by ':' Eg : 70:79:f6:2e: something like this. When I am trying to decode it to plain string ( human readable ) it doesn't work. What encoding is being used? I tried various different methods like codecs.decode(), binascii.unhexlify(), bytes.fromhex() also different encodings ASCII and UTF-8. Nothing worked, any help is appreciated. I am using python 3.6

cwahls

Thanks for your question! I believe you're wanting to read the payload in chunks of two hex places. The functions you tried are not able to parse the : delimiter out-of-the-box. Something like splitting the string by the : delimiter, converting their values to human-readable characters, and joining the "list" to a string should do the trick.

hex_string = '70:79:f6:2e'

hex_split = hex_string.split(':')
hex_as_chars = map(lambda hex: chr(int(hex, 16)), hex_split)

human_readable = ''.join(hex_as_chars)
print(human_readable)

Is this what you have in mind?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get ICMP packet payload

From Dev

Capture the data and payload in a packet

From Dev

Send TCP SYN packet with payload

From Dev

Parsing a TCP Packet data

From Dev

Print TCP Packet Data

From Dev

Filter tcp packet payload length in tcpdump

From Dev

How to understand a packet is TCP CLOSE packet with sharPcap

From Dev

WinDivert - Modify packet data/payload contents

From Dev

How to intercept packet on TCP layer in kernel to analyze data?

From Dev

Does TCP verify data all at once or as a packet by packet verification?

From Dev

HTTP GET packet sniffer in Scapy

From Dev

C TCP Socket - Get packet destination name

From Dev

What does it mean to get such a high TCP packet

From Dev

scapy. adding urgent data to TCP packet

From Dev

How to safely separate packet data?

From Dev

how to add the option scaling to the tcp packet with scapy

From Dev

How to extract Raw of TCP packet using Scapy

From Dev

How to verify if a packet in Scapy has a TCP layer

From Dev

Golang server, how to receive TCP JSON packet?

From Dev

How to fake the source-port of a TCP packet?

From Dev

How the system identifies the received packet is TCP or UDP?

From Dev

How to receive a TCP packet over the internet

From Dev

How to receive a TCP packet over the internet

From Dev

C/C++: replace specific(matching) string in a HTTP header (in a TCP packet)

From Dev

How to get data back from ICMP Time Exceeded packet?

From Dev

Zlib Inflate data from http packet

From Dev

Creating TCP packet with POX

From Dev

reassembly of tcp packet

From Dev

Send TCP packet in PHP