From 3ef400d4e7baceea04f059d4b9c3aec7c8e02e68 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 29 Oct 2017 18:54:45 +0100 Subject: [PATCH] created nmap_port_scanner.py --- scanners/nmap_port_scanner.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scanners/nmap_port_scanner.py diff --git a/scanners/nmap_port_scanner.py b/scanners/nmap_port_scanner.py new file mode 100644 index 0000000..8bb8775 --- /dev/null +++ b/scanners/nmap_port_scanner.py @@ -0,0 +1,21 @@ +import optparse +import nmap +def nmapScan(tgtHost, tgtPort): + nmScan = nmap.PortScanner() + nmScan.scan(tgtHost, tgtPort) + state = nmScan[tgtHost]['tcp'][int(tgtPort)]['state'] + print " [*] " + tgtHost + " tcp/" +tgtPort + " " + state +def main(): + parser = optparse.OptionParser(('usage %prog -H -p ')) + parser.add_option("-H", dest="tgtHost", type="string", help="specify tarhet host") + parser.add_option("-p", dest="tgtPort", type="string", help="specify target port(s) separated by space") + (options, args) = parser.parse_args() + tgtHost = str(options.tgtHost).strip() + tgtPorts = [s.strip() for s in str(options.tgtPort).split(',')] + if (tgtHost == None) | (tgtPorts[0] == None): + print parser.usage + exit(0) + for tgtPort in tgtPorts: + nmapScan(tgtHost, tgtPort.strip()) +if __name__ == "__main__": + main() \ No newline at end of file