2016-12-31 01:41:34 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -.- coding: utf-8 -.-
|
2017-03-11 11:02:12 +01:00
|
|
|
# scan.py
|
2017-03-26 20:28:13 +02:00
|
|
|
# authors: k4m4 & xdavidhu
|
2016-12-31 01:41:34 +01:00
|
|
|
|
2017-03-11 10:53:38 +01:00
|
|
|
def scanNetwork(network):
|
2017-04-01 12:01:51 +02:00
|
|
|
# Function for performing a network scan with nmap with the help of the python-nmap module
|
2017-03-11 10:53:38 +01:00
|
|
|
returnlist = []
|
|
|
|
import nmap
|
|
|
|
nm = nmap.PortScanner()
|
|
|
|
a = nm.scan(hosts=network, arguments='-sP')
|
2016-12-31 01:41:34 +01:00
|
|
|
|
2017-03-11 10:53:38 +01:00
|
|
|
for k, v in a['scan'].iteritems():
|
|
|
|
if str(v['status']['state']) == 'up':
|
|
|
|
try:
|
|
|
|
returnlist.append([str(v['addresses']['ipv4']), str(v['addresses']['mac'])])
|
|
|
|
except:
|
|
|
|
pass
|
2016-12-31 01:41:34 +01:00
|
|
|
|
2017-04-01 12:01:51 +02:00
|
|
|
# returnlist = hostsList array
|
2017-03-11 11:02:12 +01:00
|
|
|
return returnlist
|