A simple TCP SYN port scanner built with Python and Scapy. This tool allows you to scan a target IP for open, closed, or filtered ports using TCP SYN packets.
- Scan a single port or a range of ports
- Customizable timeout for scanning
- Detailed port status reporting (open, closed, or filtered)
- Command-line interface with argument parsing
- Python 3.x
- Scapy library (
pip install scapy) - Administrator/root privileges (for sending raw packets)
- Clone this repository:
git clone https://github.com/siyannon/python_tcpscan/tcp-syn-port-scanner.git cd tcp-syn-port-scanner
Run the script with Python and specify the target IP and ports to scan. The script supports both single port scanning and port range scanning.
python tcpscan.py [-h] -ip IP [-p PORT | -r RANGE] [-t TIMEOUT]- -ip IP: Target IP address (e.g., 192.168.192.227) (required)
- -p PORT: Single port to scan (e.g., 80)
- -r RANGE: Port range to scan (e.g., 80-100)
- -t TIMEOUT: Timeout in seconds (default: 20)
- -h: Show help message Note: Either -p or -r must be specified, but not both.
python tcpscan.py -ip 192.168.192.227 -p 80 -t 10Output:
Scanning 192.168.192.227 with timeout 10s...
Port 80 is open
Scan completed.
python script.py -ip 192.168.192.227 -r 80-85 -t 15Output:
Scanning 192.168.192.227 with timeout 15s...
Port 80 is open
Port 81 is closed
Port 82 is closed or filtered (no response)
...
Scan completed.
python script.py -h- The script requires root/admin privileges to send raw packets via Scapy.
- Ensure the target IP is reachable within your network.
- Scanning large port ranges may take significant time; adjust the timeout as needed.
- Ports must be between 1 and 65535.


