Skip to content

About

Built a Python-based Network Security Scanner to practice TCP/IP networking, socket programming, and security-focused automation. The project can scan a specified port range, identify open ports, associate common ports with services such as SMB, MSRPC, SSH, HTTP/HTTPS, MySQL and RDP, and generate a security scan report.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🔐 Network Security Scanner

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 was 127.0.0.1 (localhost).


🚀 Features

  • 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

🛠️ Technologies Used

  • Python
  • TCP/IP
  • Socket Programming
  • Multithreading
  • Queue-based concurrency
  • File handling

Python modules

socket
threading
queue
time

All modules used by the scanner are part of Python's standard library.


🧠 How It Works

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.


🔎 Service Detection

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.


⚡ Concurrent Scanning

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.


📊 Example Output

============================================================
              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.

▶️ Installation & Usage

1. Clone the repository

git clone https://github.com/YOUR-USERNAME/Network-Security-Scanner.git

2. Navigate into the project

cd Network-Security-Scanner

3. Run the scanner

python port_checker.py

4. Enter the target

Example:

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

🔐 Security Considerations

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.


📚 What I Learned

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

🔮 Future Improvements

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

👨‍💻 Author

Garvit Raj

This project is part of my hands-on cybersecurity learning journey, focused on developing practical skills in Python, networking, and defensive security.

About

Built a Python-based Network Security Scanner to practice TCP/IP networking, socket programming, and security-focused automation. The project can scan a specified port range, identify open ports, associate common ports with services such as SMB, MSRPC, SSH, HTTP/HTTPS, MySQL and RDP, and generate a security scan report.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages