Nishant Singh
Nishant Singh

Reputation: 3199

Passing a List of IP address to get port scanned in python (libnmap)

I am working on a python script which basically scans port on a IP address ,& I am using the libnmap library to do so , referring the docs at : https://libnmap.readthedocs.org/en/latest/process.html#purpose-of-libnmap-process

what i am hoping to do is read a external file which contains list of IP address to be scanned and pass each of the IP address as :

file_object = open(file_containg_ip_to_be_port_scanned, r)

    if __name__ == "__main__":
        report = do_scan("pass_ip_here", "-sV")
        if report:
            print_scan(report)

how can I achieve this ?

Upvotes: 0

Views: 1656

Answers (1)

vesche
vesche

Reputation: 1860

Looks like you want something like this:

with open('ip_list.txt') as f:
    for ip in f.read().splitlines():
        report = do_scan(ip, "-sV")
        if report:
            print_scan(report)

Upvotes: 1

Related Questions