问题描述:

Is it possible to start an nmap scan using python script that doesn't focus on available ports?

>>> import nmap

>>> nm = nmap.PortScanner()

>>> nm.scan('127.0.0.1', '22-443')

>>> nm.command_line()

'nmap -oX - -p 22-443 -sV 127.0.0.1'

This example requires a port, or a range of ports, to scan. With in a normal nmap scan from the linux terminal, it could be as simple as;

nmap -O -v <ip address/range>

Is this possible?

网友答案:

Pass whatever arguments you want:

nm.scan(hosts='<ip address/range>',arguments="-O -v")

Bear in mind fingerprinting will need root privileges.

If you are scanning a range of ip's PortScannerAsync might be useful:

import nmap

nm = nmap.PortScannerAsync()
def callback_result(host, scan_result):
    print '------------------'
    print host, scan_result

nm.scan('192.168.1.0/24', arguments="-O -v", callback=callback_result)
while nm.still_scanning():
    print("Waiting >>>")
    nm.wait(2)  
网友答案:

Have you ever tryed

>>> nm.scan('127.0.0.1')

? Because the ports argument is optional.

相关阅读:
Top