I. Description of the tool
Call Nmap library for port scanning
Second, demonstrate the use of the effect
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/8C/31/wKiom1hkumqAIUmwAASq5uUuz9s324.png "title=" Nmapscan.png "alt=" Wkiom1hkumqaiumwaasq5uuuz9s324.png "/>
Third, Code + Comments
Import nmapimport argparsedef nmapscan (Host, port): # Call Nmap's Portscanner class nm = nmap. Portscanner () # scan results = nm.scan using the scan method ( Host, str (Port)) state = results[' Scan '][host][' tcp '][port][' state '] print ("[+] {} tcp/{} {}". Format (host, port, state)) def Main (): parser = argparse. Argumentparser () parser.add_argument ('-h ', dest= ' Host ', help= "Host like: 192.168.3.1 ") parser.add_argument ('-P ', dest= ' Ports ', nargs= ' + ', type=int, help= "port like: 80 443 21") args = Parser.parse_args () host = args. Host ports = args. Ports &nbSp; for port in ports: nmapscan (Host, Port) if __name__ == ' __main__ ': main ()
This article is from the "Li Chunguang Technology blog" blog, make sure to keep this source http://lichunguang.blog.51cto.com/10274243/1887313
Python3 gadgets-combined with NMAP scan