From 400248ddaa963b1191c3fc31b9e2e202d92dcdd1 Mon Sep 17 00:00:00 2001 From: jerome Date: Sat, 14 Jun 2025 16:06:30 +0200 Subject: nmapscanner --- nmapscanner.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nmapscanner.py (limited to 'nmapscanner.py') diff --git a/nmapscanner.py b/nmapscanner.py new file mode 100644 index 0000000..75fd6b9 --- /dev/null +++ b/nmapscanner.py @@ -0,0 +1,30 @@ +import sys +import nmap + +def nmscan(hosts,ports): + nm = nmap.PortScanner() + nm.scan(hosts,ports) + #nm.scan(hosts,arguments=ports) + + for host in nm.all_hosts(): + print('----------------------------------------------------') + print('Host : %s (%s)' % (host, nm[host].hostname())) + print('State : %s' % nm[host].state()) + for proto in nm[host].all_protocols(): + print('----------') + print('Protocol : %s' % proto) + + lport = nm[host][proto].keys() + #lport.sort() + for port in lport: + print("Port : %s\tState : %s\tService : %s (%s - %s)" % (port, nm[host][proto][port]['state'], nm[host][proto][port]['name'], nm[host][proto][port]['product'], nm[host][proto][port]['version'])) + +#nmscan("xlinfo.fr","22-443") +#nmscan("xlinfo.fr", "-p22-443 -sV") + +if __name__ == "__main__" : + try: + nmscan(sys.argv[1],sys.argv[2]) + except: + print(f"{sys.argv[0]} demande un hôte et une liste de ports en arguments") + -- cgit v1.2.3