A Python-based TCP network security scanner designed to identify open ports, detect common services, and generate a basic security assessment report for authorized systems.
This project was built as part of my cybersecurity learning journey to understand how network reconnaissance and port scanning work at a practical level.
⚠️ Authorized Use Only: Only scan systems you own or have explicit permission to test. The default learning target used during development was127.0.0.1(localhost).
- TCP port scanning using Python sockets
- Custom target IP and port range
- Input validation for IP addresses and ports
- Concurrent scanning using multiple worker threads
- Queue-based task distribution
- Thread synchronization using locks
- Configurable socket timeout
- Detection of common network services
- Basic security context for detected services
- Scan statistics
- Automated text-based scan report
- Python
- TCP/IP
- Socket Programming
- Multithreading
- Queue-based concurrency
- File handling
socket
threading
queue
time
All modules used by the scanner are part of Python's standard library.
The scanner follows this basic workflow:
Target IP
↓
Validate Input
↓
Create Port Queue
↓
10 Worker Threads
↓
TCP Connection Attempt
↓
Open / Closed
↓
Service Identification
↓
Security Context
↓
Statistics
↓
Security Report
For each port, the scanner attempts to establish a TCP connection.
If the connection succeeds, the port is considered open.
The scanner then checks the port against a database of commonly associated services.
The scanner currently identifies common services associated with ports such as:
| Port | Service |
|---|---|
| 21 | FTP |
| 22 | SSH |
| 25 | SMTP |
| 53 | DNS |
| 80 | HTTP |
| 110 | POP3 |
| 135 | MSRPC |
| 143 | IMAP |
| 443 | HTTPS |
| 3306 | MySQL |
| 3389 | RDP |
| 445 | SMB |
Service detection is based on common port assignments and does not guarantee that a particular service or version is actually running on the port.
The initial version of the scanner performed port checks sequentially.
A 401-port localhost scan initially took approximately:
400 seconds
After implementing concurrent scanning with 10 worker threads, the same test completed in approximately:
8 seconds
This demonstrated the performance benefits of concurrency for network I/O operations.
============================================================
NETWORK SECURITY SCANNER
============================================================
Target : 127.0.0.1
Port range : 100-500
Threads : 10
Scanning...
[OPEN] Port 135 → MSRPC
[OPEN] Port 445 → SMB
------------------------------------------------------------
Ports scanned : 401
Open ports : 2
Closed ports : 399
Scan time : 8.31 seconds
------------------------------------------------------------
OPEN PORT DETAILS
------------------------------------------------------------
Port : 135
Service : MSRPC
Description : Microsoft Remote Procedure Call
Security : Verify that RPC exposure is required and appropriately restricted.
------------------------------------------------------------
Port : 445
Service : SMB
Description : Server Message Block
Security : Verify that file-sharing access is required and appropriately restricted.
------------------------------------------------------------
Report saved to: scan_report.txt
Scan complete.
git clone https://github.com/YOUR-USERNAME/Network-Security-Scanner.gitcd Network-Security-Scannerpython port_checker.pyExample:
Enter target IP: 127.0.0.1
Enter starting port: 100
Enter ending port: 500
The scanner will display the results and generate:
scan_report.txt
An open port does not automatically indicate a vulnerability.
This project focuses on:
- Network reconnaissance
- Port discovery
- Basic service classification
- Security awareness
Further vulnerability assessment would require additional authorized testing and evidence.
Through this project, I gained practical experience with:
- TCP/IP networking fundamentals
- Python socket programming
- TCP port scanning
- Network service identification
- Input validation
- Exception handling
- Multithreading
- Thread synchronization
- Queue-based task management
- Performance optimization
- Security reporting
Possible future versions could include:
- Banner grabbing
- More accurate service detection
- Configurable thread count
- CSV/JSON reporting
- Logging
- Scan progress indicators
- IPv6 support
- Better error classification
- Integration with a security dashboard
Garvit Raj
This project is part of my hands-on cybersecurity learning journey, focused on developing practical skills in Python, networking, and defensive security.