Created
November 18, 2024 08:44
-
-
Save gedsic/1407350c138096eec574ba0f5641b12b to your computer and use it in GitHub Desktop.
Python and Scapy - Get list of all TCP destination ports occuring in a pcap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scapy.all import * | |
| from natsort import natsorted | |
| packets = rdpcap('in.pcap') | |
| result = [] | |
| for packet in packets: | |
| if TCP in packet: | |
| tcpport = str(packet[TCP].dport) | |
| if tcpport not in result: | |
| result.append(tcpport) | |
| result = natsorted(result) | |
| print('\n'.join(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment