Skip to main content

Overview

The Scanner module (modules/scanner.py) provides comprehensive network reconnaissance capabilities using Nmap. It handles TCP/UDP port scanning, operating system fingerprinting, service detection, and version enumeration.

Scanner Class

The Scanner class is defined at scanner.py:13 and serves as the main interface for network scanning operations.

Initialization

scanner.py:14-24
string
required
Target IP address or domain name to scan

Key Methods

validate_target()

Validates that the target IP or domain is reachable before scanning.
scanner.py:26-35

detect_os()

Detects the target’s operating system using Nmap’s OS fingerprinting or TTL analysis.
scanner.py:37-79
OS detection requires root/sudo privileges for Nmap’s advanced fingerprinting features.
Detection Methods:
  1. Nmap OS Fingerprinting (-O flag): Most accurate, requires sudo
  2. TTL Analysis (fallback): Less accurate but works without elevated privileges

scan_all_ports()

Performs comprehensive TCP and UDP port scanning with service version detection.
scanner.py:81-140
Scan Phases:
1

Phase 1: TCP Scanning

Scans top 1000 TCP ports with service version detection using -sS -sV -T4 -Pn --top-ports 1000
2

Phase 2: UDP Scanning

Scans top 20 UDP ports using -sU -Pn --top-ports 20 for faster execution
Port Data Structure:

enumerate_services()

Extracts detailed service information from discovered open ports.
scanner.py:142-160

run_full_scan()

Orchestrates the complete scanning workflow.
scanner.py:180-195

Usage Example

Nmap Arguments

The Scanner module uses these Nmap arguments:

Output Format

Performance

  • Top 1000 ports: ~30-60 seconds
  • Top 20 UDP ports: ~10-20 seconds
  • Full scan (all 65535 ports): 5-15 minutes
Use -T4 timing for faster scans on reliable networks. For stealthy scans, use -T2 or -T3.

Error Handling

The Scanner module handles these common errors:
Returns None if target cannot be resolved or reached. Check network connectivity and DNS resolution.
Nmap requires sudo for SYN scans (-sS) and OS detection (-O). Run with sudo python3 main.py -t <target>.
Increase timeout in config.json or reduce number of ports scanned.

CLI Options

Command-line flags for scanner configuration

Configuration

Scanner settings in config.json

Troubleshooting

Solving permission and Nmap issues

Basic Scan Guide

Step-by-step scanning tutorial