blacklanternsecurity / nmappalyzer

A lightweight Python 3 Nmap wrapper that doesn't try too hard. Gracefully handles any Nmap command, providing access to all output types (normal, greppable, xml), plus JSON!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nmappalyzer

License Python Version Build Status

A lightweight Python 3 Nmap wrapper that doesn't try too hard. Gracefully handles any Nmap command, providing access to all output types (normal, greppable, xml), plus JSON!

Installation

NOTE: Nmap must be installed.

$ pip install nmappalyzer

Usage

  1. Start the scan and wait for it to finish
from nmappalyzer import NmapScan

#                target            Nmap args (optional)
scan = NmapScan('scanme.nmap.org', ['-Pn', '-F', '-T4' '-sV', '--script=banner'])
  1. Access information about the scan
scan.command
"/usr/bin/nmap -oA /tmp/rhw2r_q9 -Pn -F -T4 -sV --script=banner scanme.nmap.org"

# Terminal output
scan.stdout
# Terminal errors
scan.stderr

# Normal output
scan.results.output_nmap
# Greppable output
scan.results.output_gnmap
# XML output
scan.results.output_xml
# Parsed XML (lxml etree):
scan.results.etree
# Python dictionary (converted from xml)
scan.results.json
  1. Access information about the hosts
for host in scan:
    host.status
    host.address
    host.scripts
    host.hostnames
    host.open_ports
    host.closed_ports
    host.filtered_ports

    # Parsed XML (lxml etree)
    host.etree

    # Python dictionary (converted from xml)
    host.json

About

A lightweight Python 3 Nmap wrapper that doesn't try too hard. Gracefully handles any Nmap command, providing access to all output types (normal, greppable, xml), plus JSON!

License:GNU General Public License v3.0


Languages

Language:Python 100.0%