how to exclude Hosts from IP range from scanning inside nmap python script -


would appreciate advice how exclude hosts scanning inside nm.scan().i have following script works when enter range : example 10.0.0.0/24

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 name of file scan saved/add .csv/: ') ip_range = raw_input('\nenter ip range want scan/in following foramt:x.x.x.x/mask: ') nmap_arguments= raw_input('\nenter nmap arguments : ') nm.scan(hosts=ip_range, arguments= nmap_arguments) nm.command_line()                   # command line used scan nm.scaninfo()                       # nmap scan informations {'tcp': {'services': '22-443', 'method'nect'}} nm.all_hosts()                      # hosts scanned   if (len(sys.argv) > 1 , sys.argv[1]):     save_csv_data(nm.csv(), path=sys.argv[1]) else:     save_csv_data(nm.csv())  print "completed!" 

but example if want scan range exclude 2 hosts , when enter :nm.scan(hosts='10.0.0.0/24 --exclude 10.0.0.1, 10.0.0.2, arguments= nmap_arguments) - excludes 10.0.0.1 still scanning 10.0.0.2.so bottom line how enter ip part inside nmap()

i got it.needed put arguments first:

nm.scan(arguments='-st --open --exclude x.x.x.x,x.x.x.x',hosts='x.x.x.0/24') 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -