Skip to main content
Project Security Projects Advanced

Advanced Network Scanner

Jason J. Boderebe
4 min tutorial
#network-scanner #python #security #reconnaissance #assessment

Advanced Network Scanner

A comprehensive network scanning and security assessment tool built in Python. This tool provides both basic and advanced network scanning capabilities with a focus on security analysis and network mapping.

Features

Basic Scanning:

  • TCP/UDP port scanning
  • Service version detection
  • Basic vulnerability checks
  • Network host discovery

Advanced Features:

  • OS fingerprinting
  • Stealth scanning (SYN, FIN, XMAS)
  • Custom payload injection
  • Banner grabbing
  • Network topology mapping
  • SSL/TLS analysis

Installation

# Clone the repository
git clone https://github.com/boderebesec/network-scanner.git

# Navigate to directory
cd network-scanner

# Create virtual environment
python -m venv venv

# Activate virtual environment
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows

# Install requirements
pip install -r requirements.txt

## Usage

```bash
# Basic port scan
python main.py example(.)com -p 1-100

# Advanced scan with OS detection
python main.py example(.)com -p 1-1000 --os-detect

# Stealth SYN scan with SSL analysis
python main.py example(.)com -p 1-443 -s SYN --ssl-analyze

Project Structure

network_scanner/
├── src/
│   ├── scanners/          # Basic scanning modules
│   ├── advanced/          # Advanced scanning features
│   └── utils/             # Utility functions
├── tests/                 # Test suites
├── requirements.txt       # Project dependencies
└── main.py                # Main execution file

Requirements

  • Python 3.8+
  • scapy>=2.4.5
  • cryptography>=3.4.7
  • python-nmap>=0.7.1
  • requests>=2.26.0

Example Code

import argparse
from src.scanners.port_scanner import AdvancedPortScanner
from src.advanced.os_detector import OSDetector
from src.advanced.ssl_analyzer import SSLAnalyzer

def main():
    """
    Main function to run the Advanced Network Scanner.
    """
    parser = argparse.ArgumentParser(description='Advanced Network Scanner')
    parser.add_argument('target', help='Target host to scan')
    parser.add_argument('-p', '--ports', help='Port range (e.g., 1-100)', default='1-1000')
    parser.add_argument('-s', '--scan-type', help='Scan type (TCP/SYN/FIN)', default='TCP')
    parser.add_argument('--os-detect', action='store_true', help='Enable OS detection')
    parser.add_argument('--ssl-analyze', action='store_true', help='Analyze SSL/TLS')
    args = parser.parse_args()

    scanner = AdvancedPortScanner(args.target)
    scanner.set_scan_type(args.scan_type)

    if args.os_detect:
        os_detector = OSDetector(args.target)
        print(f"OS Detection: {os_detector.get_ttl_guess()}")

    if args.ssl_analyze:
        ssl_analyzer = SSLAnalyzer(args.target)
        print("SSL/TLS Analysis:", ssl_analyzer.analyze_ssl())

    start_port, end_port = map(int, args.ports.split('-'))
    open_ports = scanner.scan_range(start_port, end_port)
    
    print(f"\nOpen ports on {args.target}:")
    for port in open_ports:
        print(f"Port {port} is open")

if __name__ == "__main__":
    main()

Usage Examples

  • Basic Scan:

    python main.py example.com -p 1-100
  • Advanced Scan with OS Detection:

    python main.py example.com -p 1-1000 --os-detect
  • Stealth SYN Scan with SSL Analysis:

    python main.py example.com -p 1-443 -s SYN --ssl-analyze
  • Custom Payload Injection:

    from src.advanced.payload_injector import PayloadInjector
    injector = PayloadInjector("example(.)com", 80)
    payload = "GET / HTTP/1.1\r\nHost: example(.)com\r\n\r\n"
    response = injector.inject_payload(payload)
    print(response)
  • Service Detection:

    from src.scanners.service_detector import ServiceDetector
    detector = ServiceDetector("example(.)com")
    common_ports = [80, 443, 22, 21, 25]
    services = detector.detect_services(common_ports)
    for port, service in services.items():
        print(f"Port {port}: {service}")
  • Vulnerability Scanning:

    from src.scanners.vulnerability_scanner import VulnerabilityScanner
    scanner = VulnerabilityScanner("example(.)com")
    vulnerabilities = scanner.scan()
    for vulnerability in vulnerabilities:
        print(vulnerability)
  • Stealth Scanning:

    from src.advanced.stealth_scanner import StealthScanner
    scanner = StealthScanner("example(.)com")
    common_ports = [80, 443, 22, 21, 25]
    results = scanner.scan_ports(common_ports)
    for port, status in results.items():
        print(f"Port {port}: {status}")

Security Notice

This tool is intended for authorized security testing only. Unauthorized scanning of networks or systems may be illegal. Always obtain proper permissions before conducting any security assessments.