Python Forum
How to extract protocol from a pcap file ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to extract protocol from a pcap file ?
#1
I developed this code to extract all protocols (transport and application) from a pcap file:

load_layer('http')
load_layer('tls')
load_contrib("modbus")


def find_proto(s):
def expand(x):
    yield x.name
    while x.payload:
        x = x.payload
        yield x.name
if s[0]:
    proto = list(expand(s[0]))
    sProto = ["HTTP", "DNS", "ModbusADU",  "TLS", "TCP", "UDP", "FTP-DATA", "Raw"]
    for p in sProto:
        if p in proto:
            return p
    return "Unknown"
Here I limited the extract to "HTTP", "DNS", "ModbusADU", "TLS", "TCP", "UDP", "FTP-DATA", "Raw" but if I want to extract all the protocol like in wireshark
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can I use Python in ns3 simulator to create an IGP routing protocol? leemao 1 8,172 Jun-30-2021, 07:20 PM
Last Post: leemao
  Handle http protocol JohnnyCoffee 1 5,510 Jun-20-2021, 06:51 AM
Last Post: ndc85430
  Is there in 2018 a python3 library that implements the Internet Printing Protocol? AFoeee 1 4,077 Jun-07-2019, 08:51 AM
Last Post: heiner55
  no protocol header version error mjudhandoyo 2 6,321 Feb-03-2017, 10:35 PM
Last Post: nilamo
  accessing SOAP protocol page secured with cetrificad lopow 3 5,510 Jan-11-2017, 03:14 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020