View Full Version : Have you checked out nmap lib for python ?

05-23-2011, 04:35 PM
I hope the python enthusiastics have already checked out this. If not check out
the nmap lib for python you can write python programs for doing the nmap scans and
processing the results.


python-nmap 0.2.2
This is a python class to use nmap and access scan results from python3


python-nmap is a python library which helps in using nmap port scanner.
It allows to easilly manipulate nmap scan results and will be a perfect
tool for systems administrators who want to automatize scanning task
and reports. It also supports nmap script outputs.

Typical usage looks like::

#!/usr/bin/env python
import nmap # import nmap.py module
nm = nmap.PortScanner() # instantiate nmap.PortScanner object
nm.scan('', '22-443') # scan host, ports from 22 to 443
nm.command_line() # get command line used for the scan : nmap -oX - -p 22-443
nm.scaninfo() # get nmap scan informations {'tcp': {'services': '22-443', 'method': 'connect'}}
nm.all_hosts() # get all hosts that were scanned
nm[''].hostname() # get hostname for host
nm[''].state() # get state of host (up|down|unknown|skipped)
nm[''].all_protocols() # get all scanned protocols ['tcp', 'udp'] in (ip|tcp|udp|sctp)
nm['']['tcp'].keys() # get all ports for tcp protocol
nm[''].all_tcp() # get all ports for tcp protocol (sorted version)
nm[''].all_udp() # get all ports for udp protocol (sorted version)
nm[''].all_ip() # get all ports for ip protocol (sorted version)
nm[''].all_sctp() # get all ports for sctp protocol (sorted version)
nm[''].has_tcp(22) # is there any information for port 22/tcp on host
nm['']['tcp'][22] # get infos about port 22 in tcp on host
nm[''].tcp(22) # get infos about port 22 in tcp on host
nm['']['tcp'][22]['state'] # get state of port 22/tcp on host (open

05-23-2011, 04:57 PM
i have some ideas based on that .... lets see when i can do something about it...

it is really interesting tough... python giving more reasons for hackers to fall in love with it....

lets hisss guys