2018-02-05 20:39:08 +01:00
|
|
|
#!/usr/bin/env python3
|
2016-12-31 01:41:34 +01:00
|
|
|
# -.- coding: utf-8 -.-
|
2017-03-11 11:02:12 +01:00
|
|
|
# scan.py
|
2016-12-31 01:41:34 +01:00
|
|
|
|
2018-02-05 20:39:08 +01:00
|
|
|
"""
|
|
|
|
Copyright (C) 2017-18 Nikolaos Kamarinakis (nikolaskam@gmail.com) & David Schütz (xdavid@protonmail.com)
|
|
|
|
See License at nikolaskama.me (https://nikolaskama.me/kickthemoutproject)
|
|
|
|
"""
|
|
|
|
|
|
|
|
import nmap
|
|
|
|
|
|
|
|
# perform a network scan with nmap
|
2017-03-11 10:53:38 +01:00
|
|
|
def scanNetwork(network):
|
|
|
|
returnlist = []
|
|
|
|
nm = nmap.PortScanner()
|
2018-02-05 20:39:08 +01:00
|
|
|
a = nm.scan(hosts=network, arguments='-sn')
|
2016-12-31 01:41:34 +01:00
|
|
|
|
2018-02-05 20:39:08 +01:00
|
|
|
for k, v in a['scan'].items():
|
2017-03-11 10:53:38 +01:00
|
|
|
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-03-11 11:02:12 +01:00
|
|
|
return returnlist
|