At this point, we will see a port scanner on a certain network segment. In the same way we do port-scanning with nmap, with scapy we could also perform a simple port-scanner that tells us for a specific host and a list of ports, whether they are open or closed.
Port-scanning and traceroute with scapy
Port-scanning with scapy
In the following example, we see that we have defined a analyze_port() function that has as parameters the host and port to analyze.
You can find the following code in the port_scan_scapy.py file:
from scapy.all import sr1, IP, TCP
OPEN_PORTS = []
def analyze_port(host, port):
"""
Function that determines the status of a port: Open / closed
:param host: target
:param port: port to test
:type...