Files
Anthropic-Cybersecurity-Skills/skills/scanning-network-with-nmap-advanced/references/api-reference.md
T
mukul975 27c6414ca5 Add folder anatomy (scripts/agent.py + references/api-reference.md) for 648 cybersecurity skills
Complete skill folder anatomy across all cybersecurity skills:
- scripts/agent.py: 80-150 line Python agents using real libraries (impacket,
  boto3, azure-mgmt-*, kubernetes, pefile, yara, scapy, shodan, stix2, etc.)
- references/api-reference.md: real API documentation with method signatures
- LICENSE: MIT license for all skill folders
2026-03-10 21:02:12 +01:00

2.0 KiB

API Reference: Scanning Network with Nmap Advanced

python-nmap Library

Installation

pip install python-nmap

Requires Nmap binary installed on the system (nmap must be in PATH).

Core Classes

nmap.PortScanner()

Main scanner class wrapping the Nmap command-line tool.

Method Parameters Returns Description
scan() hosts, ports, arguments dict Execute Nmap scan with given arguments
all_hosts() - list[str] List of all scanned host IPs
nmap_version() - tuple Installed Nmap version
command_line() - str Nmap command that was executed

Scanner Result Access

scanner[host].state()              # Host state: 'up' or 'down'
scanner[host].all_protocols()      # ['tcp', 'udp']
scanner[host][proto].keys()        # List of port numbers
scanner[host][proto][port]         # Port info dict with keys: state, name, product, version
scanner[host].hostnames()          # [{'name': 'hostname', 'type': 'PTR'}]
scanner[host]['osmatch']           # OS detection results

Common Nmap Arguments

Argument Purpose
-sS TCP SYN scan (half-open, requires root)
-sV Service version detection
-sC Run default NSE scripts
-O OS fingerprinting
-sn Host discovery only (no port scan)
--script vuln Run vulnerability detection scripts
-T0 to -T5 Timing templates (paranoid to insane)
--min-rate N Minimum packets per second
-PE -PP -PS ICMP echo, timestamp, TCP SYN discovery probes
-oX file Output results in XML format

Output Parsing

scanner.csv()           # CSV-formatted scan results
scanner.scaninfo()      # Scan metadata (type, services scanned)
scanner.scanstats()     # Timing and host statistics

References