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 ?
I developed this code to extract all protocols (transport and application) from a pcap file:


def find_proto(s):
def expand(x):
    while x.payload:
        x = x.payload
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

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

Forum Jump:

User Panel Messages

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