Skip to content

Latest commit

 

History

History
101 lines (75 loc) · 3.15 KB

File metadata and controls

101 lines (75 loc) · 3.15 KB

Python Network Port Scanner & Service Banner Grabber

A lightweight, multi-port network reconnaissance script developed in Python. This tool performs TCP connection handshakes to detect open ports, extracts active service banners, and automatically writes audit logs to a CSV report.


📌 Project Overview

This project focuses on core networking fundamentals and security reconnaissance techniques:

  • TCP Socket Probing: Uses low-level IPv4 (AF_INET) and TCP (SOCK_STREAM) sockets to identify live host services.
  • Service Banner Grabbing: Transmits application-layer requests to extract service signatures (such as OpenSSH versions and HTTP daemon headers).
  • Fault-Tolerant Scanning: Configured socket timeouts prevent execution hangs on filtered or dropping ports, with error handling for DNS resolution failures and manual interruptions.
  • Automated Data Export: Formats and writes scan results directly into scan_results.csv using Python's built-in csv module.

🛠️ Technical Details

  • Language: Python 3.x
  • Core Libraries: socket, csv, datetime, sys (No third-party packages required)
  • Testing Target: scanme.nmap.org (Official, authorized public test target)

📂 Repository Structure

Python_Network_Scanner/
│
├── scanner.py          # Port scanner and banner grabbing source code
├── scan_results.csv    # Structured scan output file
└── README.md           # Project documentation

🚀 How to Run

  1. Clone the repository:
git clone [https://github.com/ameyrane07/Python_Network_Scanner.git](https://github.com/ameyrane07/Python_Network_Scanner.git)
cd Python_Network_Scanner
  1. Run the scanner:
python scanner.py

---

## 📊 Sample Execution & Output

### Terminal Output

```text
------------------------------------------------------------
Scanning target: scanme.nmap.org
Time started: 2026-08-29 11:34:00.000000
------------------------------------------------------------
[-] Port 21    : CLOSED
[+] Port 22    : OPEN | Service: SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
[-] Port 23    : CLOSED
[-] Port 25    : CLOSED
[-] Port 53    : CLOSED
[+] Port 80    : OPEN | Service: HTTP/1.1 200 OK
[-] Port 110   : CLOSED
[-] Port 139   : CLOSED
[-] Port 443   : CLOSED
[-] Port 445   : CLOSED
[-] Port 3306  : CLOSED
[-] Port 8080  : CLOSED
------------------------------------------------------------
Scan completed: 2026-08-29 11:34:15.000000
[+] Results saved successfully to scan_results.csv
------------------------------------------------------------

Exported Report (scan_results.csv)

Port,Status,Banner
21,CLOSED,N/A
22,OPEN,SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
23,CLOSED,N/A
25,CLOSED,N/A
53,CLOSED,N/A
80,OPEN,"HTTP/1.1 200 OK"
110,CLOSED,N/A
139,CLOSED,N/A
443,CLOSED,N/A
445,CLOSED,N/A
3306,CLOSED,N/A
8080,CLOSED,N/A

---

## ⚠️ Disclaimer

This tool was designed and tested exclusively against `scanme.nmap.org`, a designated service provided by the Nmap Project for testing custom scanners. Unauthorized port scanning against external infrastructure without explicit, prior authorization is unethical and strictly prohibited.