Questions tagged [dpkt]

A python library for fast, simple packet creation and parsing, with definitions for basic TCP/IP protocols.

85 questions
1
vote
1 answer

how to print DHCP message type in python using dpkt

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…
Manojcode
  • 41
  • 4
1
vote
1 answer

decoding DHCP Giaddr, Yiaddr, Ciaddr, siaddr fields with dpkt - python issue

Whenever I try to load Giaddr (or YIADDR Ciaddr, siaddr ) for any DHCP packet it prints random string of numbers. ( this happens for each n every packet I load) Am I doing something wrong or it's a bug in code? code dh =…
Manojcode
  • 41
  • 4
1
vote
0 answers

How could I find or calculate the throughput, delay, and packet loss rate of TCP flow from the pcap file, using Python?

How could I find or calculate the throughput, delay, and packet loss rate of TCP flow ? I want to do it from reading the pcap file , and using Python Now I use the dpkt module to caculate the throughput of TCP flow, accumulate the total length of…
cyminute
  • 11
  • 5
1
vote
1 answer

reading sent and received SYS and ACK packets with dpkt and python

I need to parse a .pcap file to detect possible SYS scans. I need to be able to display the IP address of any IP addresses that sent 3 times as many SYS packets as the number of SYS+ACK packets they received. Now I have a general idea of how to…
GGMU
  • 165
  • 1
  • 2
  • 13
1
vote
1 answer

convert dpkt byte strings containing random characters

I am using the dpkt python module to parse a pcap file. I'm looking deep enough into the packets that some of the data is represented as byte streams. I can convert from regular byte strings easily enough, however some of the byte strings appear…
Alex Hunter
  • 138
  • 2
  • 10
1
vote
2 answers

Can't find the test module in Anaconda Python

I cannot find the test module in my Anaconda's version of Python. Can anyone help me fix this. This module is used by the dpkt library that I am trying to use. Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46) [GCC 4.2.1…
Phani
  • 3,267
  • 4
  • 25
  • 50
1
vote
3 answers

Read IP addresses and TTL from DNS response with dpkt

I'm using dpkt for reading a pcap file. try: dns = dpkt.dns.DNS(udp.data) except: continue if dns.qr != dpkt.dns.DNS_R: continue if dns.opcode != dpkt.dns.DNS_QUERY: continue if dns.rcode !=…
Bob
  • 553
  • 1
  • 5
  • 10
1
vote
0 answers

Decode packet fields using dpkt package in python

I am trying to print the NTP fields using dpkt. It works well except that I couldn't get the output like the one I get from tcpdump. For instance, in the attached code, I couldn't print originate_time in human readable format. I tried functions in…
drk
  • 251
  • 1
  • 3
  • 11
1
vote
0 answers

pcap parsing with dpkt, python

i am relativly new to python and have a little project where i need to parse pcap and extract certain data. I am now stuck! What i need help with is how to parse de actual data content of the packet stream. What i want to do is to be able to, for…
Hypnol
  • 11
  • 4
0
votes
0 answers

Get sequence number from ICMP package

Could you tell me please, get more detailed information about the ICMP packet? Right now I'm using some code construction: import dpkt with open('icmp_yes.pcap', 'rb') as file: pcap_reader = dpkt.pcap.Reader(file) for timestamp, packet_data…
Alex Rebell
  • 465
  • 3
  • 15
0
votes
0 answers

Why can't I use dpkt.http.Response and dpkt.http.Request at the same time?

I am creating a tool to capture packets in python. I want to use pkt.http.Response and dpkt.http.Request together. The purpose is to detect erroneous packets and get the information from the pacap from Request to Response. However, Response is not…
Subin
  • 1
  • 2
0
votes
1 answer

Get Application layer Protocol in dpkt

I have to get the name of all the different protocols from PCAP files. Basically, I have to parse it. I researched a bit and was informed that dpkt is very efficient for this. I am writing the script in python and below is the code - def…
Mr.X
  • 59
  • 5
0
votes
1 answer

How to get payload from a packet with dpkt?

I am getting the payload of tcp packet using scapy easily : def handle_pkt(pkt): try : pay_load_tcp = pkt[IP].load except : pay_load_tcp = "" for packet in PcapReader(filename): if TCP in packet and packet[IP].dst ==…
Nagmat
  • 373
  • 4
  • 14
0
votes
1 answer

pcap parsing in python2.7

To carry on from this question.https://stackoverflow.com/questions/9330686/parsing-pcap-in-python-2-6 I'm now trying to perform print summary but still not sure what to include in my final argument before print summary. Please see the the code…
Mojo
  • 11
  • 2
0
votes
1 answer

'ValueError' object has no attribute '_render_traceback_'

While using dpkt to parser a UDP pcap file, got the following error message: with open('file.pcap', 'rb') as fopen: pcap = dpkt.pcap.Reader(fopen) for timestamp, buf in pcap: print (timestamp) ERROR:root:Internal Python error in the inspect…
Saige
  • 91
  • 2
  • 6