Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

scapy get packet destination port python

from scapy.all import *
from scapy.layers.inet import IP, TCP

pkts = rdpcap("path/to/pcap_file")
pkt1 = pkts[0]					# Get first packet
ip_hdr = pkt1[IP]
tcp_hdr = ip_hdr[TCP]

src_port = tcp_hdr.sport		# Get source port
dst_port = tcp_hdr.dport		# Get destination port
 
PREVIOUS NEXT
Tagged: #scapy #packet #destination #port #python
ADD COMMENT
Topic
Name
7+6 =