diff options
| author | jerome <jerome@xlinfo.fr> | 2025-10-14 00:36:03 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-10-14 00:36:03 +0200 |
| commit | 07754820563e5e039cd1d5fc6cc10db480a22fee (patch) | |
| tree | 11496a82f2b41248ff8c6a0d410be8e6aed3e05b /tools/nmapscanner.py | |
| parent | 08a3900aa70b1d5809b2c5334ed3866117ac3286 (diff) | |
| download | python-07754820563e5e039cd1d5fc6cc10db480a22fee.tar.gz python-07754820563e5e039cd1d5fc6cc10db480a22fee.zip | |
organisation
Diffstat (limited to 'tools/nmapscanner.py')
| -rw-r--r-- | tools/nmapscanner.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/nmapscanner.py b/tools/nmapscanner.py new file mode 100644 index 0000000..5cd0659 --- /dev/null +++ b/tools/nmapscanner.py @@ -0,0 +1,34 @@ +import sys +import nmap + +def nmscan(hosts,ports,arguments='-sV'): + nm = nmap.PortScanner() + nm.scan(hosts,ports,arguments) + + + 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 : {}\tState : {}\tService : {} ({} - {})".format(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","53","-sU -sV") en sudo... +# nmscan("192.168.2.0/24","22") + +if __name__ == "__main__" : + try: + if len(sys.argv) > 3: + nmscan(sys.argv[1],sys.argv[2],sys.argv[3]) + else: + nmscan(sys.argv[1],sys.argv[2]) + except: + print(f"{sys.argv[0]} demande un ou plusieurs hôtes, une liste de ports, et des arguments optionnels") + |
