0
將不勝感激您的建議如何排除主機掃描nm.scan()內我有以下腳本,當我輸入範圍內完美:例如10.0.0.0/24如何排除主機從IP範圍內掃描nmap python腳本
import sys
import os
import subprocess
import csv
import nmap # import nmap.py module
try:
nm = nmap.PortScanner() # instantiate nmap.PortScanner object
except nmap.PortScannerError:
print('Nmap not found', sys.exc_info()[0])
sys.exit(0)
except:
print("Unexpected error:", sys.exc_info()[0])
sys.exit(0)
file = raw_input('\nEnter the name of the file where the scan will be saved/add .csv/: ')
ip_range = raw_input('\nEnter the IP range you want to scan/in the following foramt:x.x.x.x/mask: ')
nmap_arguments= raw_input('\nEnter the nmap arguments : ')
nm.scan(hosts=ip_range, arguments= nmap_arguments)
nm.command_line() # get command line used for the scan
nm.scaninfo() # get nmap scan informations {'tcp': {'services': '22-443', 'method'nect'}}
nm.all_hosts() # get all hosts that were scanned
if (len(sys.argv) > 1 and sys.argv[1]):
save_csv_data(nm.csv(), path=sys.argv[1])
else:
save_csv_data(nm.csv())
print "Completed!"
但例如,如果我要掃描的範圍,但不包括2級的主機,當我輸入:nm.scan(hosts='10.0.0.0/24 --exclude 10.0.0.1, 10.0.0.2, arguments= nmap_arguments)
- 它排除僅僅10.0.0.1但仍然掃描10.0.0.2.So底線是如何在nmap內部輸入IP部分()