Skip to content

Commit

Permalink
created nmap_port_scanner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ninijay committed Oct 29, 2017
1 parent a787263 commit 3ef400d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scanners/nmap_port_scanner.py
Original file line number Diff line number Diff line change
@@ -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 <target host> -p <target port(s) separated by space>'))
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()

0 comments on commit 3ef400d

Please sign in to comment.