A small project that I wrote on the fly in order to identify and label the devices in my networks.
Please input network IP (press return for 192.168.1.1):
Scanning 192.168.1.1/24...
Known Devices
+-------------------+---------------+------------------------------+-------------------------------------------+-------------------+---------+
| MAC ADDRESS | IP | NAME IN NETWORK | NAME | LOCATION | ALLOWED |
+-------------------+---------------+------------------------------+-------------------------------------------+-------------------+---------+
| 00:00:00:00:00:00 | 192.168.1.102 | iphonex | iPhone X of John Appleseed | My Home | True |
| 00:00:00:00:00:01 | 192.168.1.103 | PC192-168-1-103 | Windows PC of my Neighbor | Neighbor's house | False |
+-------------------+---------------+------------------------------+-------------------------------------------+-------------------+---------+
Unknown Devices
+-------------------+---------------+-----------------+
| MAC ADDRESS | IP | NAME IN NETWORK |
+-------------------+---------------+-----------------+
| 00:00:00:00:00:02 | 192.168.1.104 | PC192-168-1-104 |
+-------------------+---------------+-----------------+
You can find a log file with all devices in "data/2007-01-09.log"
and a log file:
Log: 2007-01-09 09:41:00.000000
Mac Address: 00:00:00:00:00:00
Name in network: iphonex
Given name: iPhone X of John Appleseed
Allowed on network: True
Log: 2007-01-09 09:41:00.000001
Mac Address: 00:00:00:00:00:01
Name in network: PC192-168-1-103
Given name: Windows PC of my Neighbor
Allowed on network: False
Log: 2007-01-09 09:41:00.000002
Mac Address: 00:00:00:00:00:02
Name in network: PC192-168-1-104
Given name: None
Allowed on network: None
- clone or download the project and
cd
into the project folder - install virtualenv and create venv
pip3 install virtualenv
virtualenv -p python3 <venvname>
- activate venv
- Unix like:
source <venvname>/bin/activate
- Windows
\<venvname>\Scripts\activate.bat
- Unix like:
- install dependencies
brew install nmap
pip install -r requirements.txt
- or
pip install python-nmap getmac prettytable
- or
- run:
python main.py
- input network to scan: e.g.
192.168.1.1
Scanning could take a little while (around 20sec is normal). In addition, it may have to be run several times to get all devices.
You will find a <date>.log
in a data
directory with all devices found this day
- create json file:
data/devices.json
- Use the following format:
{
"00:00:00:00:00:00":
{
"type": "iPhone X",
"owner": "John Appleseed",
"location": "My Home",
"allowed": true
},
-
KEY is mac address
-
"type" is how the device should be called
-
"owner" is simply the user of the device
The device will be shown as e.g.
iPhone X of John Appleseed
-
"location" is the standard location e.g.
null
,"living room"
,"office"
etc.
This is a very small project that arose out of a quick need. So I keep it as simple as possible. If you are motivated to improve it, you can simply fork the project and make a pull request with your changes.
Code of Conduct: Be nice to everyone and have fun coding.