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 features and save as CSV for ARP data by DPKT. may any one can have better suggestion or code for how to extract all features by DPKT and save as CSV. Thank you.
def arp_analys(filename):
with open("../data/" + filename + ".pcap", 'rb') as f:
pcap = dpkt.pcap.Reader(f)
requests = []
replies = []
for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
# If the packet is not arp
if eth.type != 2054:
continue
try:
arp = eth.arp
except Exception as e:
continue
packet_time = datetime.datetime.utcfromtimestamp(ts).strftime("%m/%d/%Y,%H:%M:%S")
src = dpkt.socket.inet_ntoa(arp.spa)
tgt = dpkt.socket.inet_ntoa(arp.tpa)
# Src and Dest MAC
from src.arpbasic import mac_addr
s_mac = mac_addr(eth.src)
d_mac = mac_addr(eth.dst)