Reputation: 41
1. I have hierarchy of layers
dh = dpkt.dhcp.DHCP(udp.data)
I am trying to print a DHCP packet type how can I do it.( I didn't see any option to get it)
I tried print dh.opts
but not sure how can I decode it..?(my lack of experience with binary formats)
2. I saw few old examples from Jon Oberheide, he was able to print whole packet ethernet,IP or etc in almost readable format. for eg
>>> print eth
Ethernet(src='\x00\x1a\xa0kUf', dst='\x00\x13I\xae\x84,', data=IP(src='\xc0\xa8\n\n',
off=16384, dst='C\x17\x030', sum=25129, len=52, p=6, id=51105, data=TCP(seq=9632694,
off_x2=128, ack=3382015884, win=54, sum=65372, flags=17, dport=80, sport=56145)))
How can I print whole packet's data in readable format and then go layer by layer or data of perticular layer like I was trying
print dh //gives me unreadable(I believe binary formatted text)
Can you pls help me on this..Examples will be great
Upvotes: 1
Views: 668
Reputation: 686
when you are not in python REPL, you need to call the repr
function on the desired packet.
>> dh = dpkt.dhcp.DHCP(udp.data)
>> print repr(dh)
>>> DHCP(xid=15645, chaddr='\x00\x0b\x82\x01\xfcB', opts=[(53, '\x01'), (61, '\x01\x00\x0b\x82\x01\xfcB'), (50, '\x00\x00\x00\x00'), (55, '\x01\x03\x06*')], data='\x00\x00\x00\x00\x00\x00\x00')
Upvotes: 2