Questions tagged [dpkt]

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

85 questions
0
votes
1 answer

Check if packet contains Ethernet layer or a Raw IP packet using DPKT python

I have a some pcap files that I need to extract some information from, those packets are mixed, some are Raw IP and others contains ethernet frames. I need to conditionally check for the type of packet before parsing as the packets with ethernet…
ma7555
  • 362
  • 5
  • 17
0
votes
1 answer

How can I extract packets from txt file?

I have a file as trace.txt which consists of packets and I want to extract each packet from it. The file as follows: IP (tos 0x0, ttl 64, id 42387, offset 0, flags [none], proto UDP (17), length 364) 10.30.23.135.17500 > 255.255.255.255.17500:…
Fragrance
  • 44
  • 7
0
votes
1 answer

Why am I getting ModuleNotFoundError: No module named 'dpkt'?

When I run import dpkt It gives ModuleNotFoundError: No module named 'dpkt' But I already installed dpkt. install dpkt cmd Does anyone know how I can fix this? I am using window10, python3.
0
votes
0 answers

Python Regex, Match the last ip octet

i'm trying to match the last octet of an ip address but it doesn't work. import dpkt import socket import re def show_http_ip_info(pcap): for (ts, buf) in pcap: try: eth = dpkt.ethernet.Ethernet(buf) ip =…
mrdos01
  • 13
  • 8
0
votes
2 answers

Python2 and Python3 DPKT appears to return different output formats

The DPKT library says it supports Python3 now, but it has different behavior when I use it in Python 2.x vs 3.x. Although, both are incorrect it appears. For example, in Python 2.x, the example given here with open('test.pcap') as f: pcap =…
trueCamelType
  • 2,198
  • 5
  • 39
  • 76
0
votes
1 answer

Issue accessing/iterating complex dictionary objects in python

So I'd like to preface this with I'm brand new to python...I'm trying to access values from a complex object. When using a for loop in a for loop I keep getting errors like... TypeError: object does not support assignment or AtributeError: 'str'…
ѺȐeallү
  • 2,887
  • 3
  • 22
  • 34
0
votes
1 answer

Create a python script that counts the amount of packets to reach a website using tcpdump?

Let's say that I run: tcpdump -w 0001.pcap -i eth0 and during the capture I'm visting stackoverflow and then I cancel the capture. This gives me a .pcap file with all the captured data and the packets for visiting stackoverflow. I'm trying to create…
grabbhalf
  • 61
  • 1
  • 1
  • 7
0
votes
1 answer

How to count Duplicate IP in a Column in CSV by Python

I have program for extract PCAP ARP src_ip and Dest_IP and save in CSV file. i need code how to count Number of Times Src_IP is request to dest_ip (Example 192.168.0.1 src_IP try to connected 10 times with Dest_ip). so how to count duplicates IP in…
delwar.naist
  • 51
  • 1
  • 12
0
votes
1 answer

Extract all protocols data from PCAP by Python DPKT and Save as CSV

Team, I would like to extract No_of_ARP_Request, No_of_TCP_SYN, Number_UDP_138, NBNS, MDNS, IGMP, ICMP data Src_MAC_Address, Dest_MAC_Address, Src_Port, Dest_Port etc features from wireshark pcap file. This is to inform, I have already extracted…
delwar.naist
  • 51
  • 1
  • 12
0
votes
1 answer

how do i use the timestamp from the header of a live capture in dpkt writer?

I'm having some trouble with a packet capture utility that I am writing. I'm currently using pcapy to open a live bytestream and dpkt to decode the packets. I want to also write the packets to a .pcap file, which workse with the dpkt.Writer…
psi
  • 1
  • 2
0
votes
0 answers

Parsing interface details from .pcap file in python

I have a .pcap file and I am trying to extract the interface and its admin status from this output. Which python module should I use? I have tried pypcapfile and had no luck figuring it out. I also tried dpkt but I am not able to use the correct…
Prarthana Shedge
  • 135
  • 1
  • 3
  • 11
0
votes
1 answer

how to parse a pcap with 802.11 as protocol

I am using dpkt to parse packets sniffed by Wireshark. Here is my code: for ts,buf in pcap: try: eth=dpkt.ethernet.Ethernet(buf) except(dpkt.dpkt.NeedData,dpkt.dpkt.UnpackError): continue However, it seems that eth class…
0
votes
2 answers

Filter pcap pap protocol without pyshark

I want to access data in pap packets, currently i'm using pyshark with the following code import pyshark,sys cap = pyshark.FileCapture('test.pcap',display_filter='ppp && not ppp.length') for packet in cap: if…
MOHAMMAD RASIM
  • 335
  • 1
  • 6
  • 14
0
votes
1 answer

Grabbing multiple IPs from a PCAP file using dpkt

I'm new to Python, and the dpkt module, and need some help. I've done as much research on this subject as I possibly could but to no avail. My manager wants me to create a program that parses PCAP files and writes IP addresses regardless of traffic…
kat
  • 13
  • 4
0
votes
1 answer

Use IP or TCP packet length to analyze how much data transferred

I am pretty new to network traffic. I am trying to get the size of data transferred every second in the internet traffic. I downloaded one pcap file, and I'm using tcpdump to analyze it. By running tcpdump -tttt -v -r sample.pcap I get some…
W. Yang
  • 49
  • 8