kickthemout/scan.py
2018-02-05 21:39:08 +02:00

26 lines
673 B
Python

#!/usr/bin/env python3
# -.- coding: utf-8 -.-
# scan.py
"""
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
def scanNetwork(network):
returnlist = []
nm = nmap.PortScanner()
a = nm.scan(hosts=network, arguments='-sn')
for k, v in a['scan'].items():
if str(v['status']['state']) == 'up':
try:
returnlist.append([str(v['addresses']['ipv4']), str(v['addresses']['mac'])])
except:
pass
return returnlist