With Python script, you can monitor nearby network devices?

Posted by oliverw92 on Mon, 07 Feb 2022 08:37:20 +0100


  • Wi Fi device scanning
  • Email reminder
  • Wechat reminder (Server sauce)
  • Strange equipment detection


In Wi Fi networks, the wireless network card transmits signals in broadcast mode. When the wireless network card broadcasts the information, all devices can receive the information. After the wireless network card is set to the monitoring mode, all data packets within the receiving range of the network card can be captured. Through these packets, you can scan the devices and signal strength in the nearby Wi Fi network.

Network card in monitoring mode

Some network cards that support listening mode


Software installation


brew install wireshark
 brew cask install wireshark-chmodbpf

Linux or Raspberry Pi

sudo apt-get install tshark

# run as non-root

sudo dpkg-reconfigure wireshark-common     (select YES)
sudo usermod -a -G wireshark ${USER:-root}
newgrp wireshark

Configure network card

  • If it is a network card that supports listening mode, it can be run directly
  • If it happens to be Rtl8192 + Raspberry Pi, you need to unload the rtl8192 driver first, and then load the RTL8188 driver
#!/usr/bin/env bash
uname -a

# disable rtl8192 driver
sudo depmod 4.14.79-v7+
sudo rmmod 8192cu
sudo modprobe rtl8192cu

# set RTL8188 monitor mode
sudo ifconfig wlan1 down
sudo iwconfig wlan1 mode monitor
sudo ifconfig wlan1 up

Run code

Download code

git clone https://github.com/wangshub/hmpa-pi.git
cd hmpa-pi/ && pip install -r requirements.txt

Edit profile

cp config/config.py.example config/config.py
vi config/config.py

Reference configuration

adapter = 'wlan1'

use_email = True
email = {"host": "smtp.163.com",
         "port": 465,
         "user": "xxxxxxx@163.com",
         "password": "xxxxxxxxxx",
         "to_user": "xxxxxxxx@xxxx.com"}

use_wechat = True
serverchan = {"sckey": "xxxxxxxxxxxxxxxxxxxxx"}

known_devices = {"94:65:2d:xx:xx:xx": "my cellPhone",
                 "dc:a4:ca:xx:xx:xx": "my Mac",
                 "b8:27:eb:xx:xx:xx": "my raspberry"}


python main.py

Operation results

2019-01-24 07:37:01.211617 A total of 67 devices were found

Known Devices:
- my cellPhone
- my raspberry
- my mac

All Devices:
- 00:e0:70:3e:xx:xx 14 DH TECHNOLOGY
- 94:65:2d:91:xx:xx 14 OnePlus Technology (Shenzhen) Co., Ltd
- dc:d9:16:7e:xx:xx -12 HUAWEI TECHNOLOGIES CO.,LTD
- b8:27:eb:12:xx:xx -20 Raspberry Pi Foundation
- 98:01:a7:eb:xx:xx -40 Apple, Inc.
- 20:5d:47:44:xx:xx -44 vivo Mobile Communication Co., Ltd.
- ac:b5:7d:5f:xx:xx -46 Liteon Technology Corporation
- 04:03:d6:1f:xx:xx -47 Nintendo Co.,Ltd
- d4:ee:07:55:xx:xx -48 HIWIFI Co., Ltd.
- 44:6e:e5:63:xx:xx -51 HUAWEI TECHNOLOGIES CO.,LTD
- 14:75:90:8d:xx:xx -51 TP-LINK TECHNOLOGIES CO.,LTD.
- 34:96:72:1d:xx:xx -56 TP-LINK TECHNOLOGIES CO.,LTD.
- d8:cb:8a:74:xx:xx -57 Micro-Star INTL CO., LTD.
- 40:8d:5c:21:xx:xx -57 GIGA-BYTE TECHNOLOGY CO.,LTD.

More ...


  • Beautify printed information
  • More elegant parameter configuration
  • Alert when a new device is found
  • Drawing statistics
  • Equipment distance estimation

"Python experience sharing"

It's good to learn Python well, whether in employment or sideline, but to learn python, you still need to have a learning plan. Finally, I'll share a full set of Python learning materials for free to give some help to those who want to learn Python!

1, Python learning routes in all directions

All directions of Python is to sort out the commonly used technical points of Python and form a summary of knowledge points in various fields. Its purpose is that you can find corresponding learning resources according to the above knowledge points to ensure that you learn more comprehensively.

2, Learning software

If a worker wants to do well, he must sharpen his tools first. The commonly used development software for learning Python is here, which saves you a lot of time.

3, Getting started video

When we watch videos, we can't just move our eyes and brain without hands. The more scientific learning method is to use them after understanding. At this time, the hand training project is very suitable.

4, Actual combat cases

Optical theory is useless. We should learn to knock together and practice, so as to apply what we have learned to practice. At this time, we can make some practical cases to learn.

5, Interview materials

We must learn Python in order to find a high paying job. The following interview questions are the latest interview materials from front-line Internet manufacturers such as Alibaba, Tencent and byte, and Alibaba boss has given authoritative answers. After brushing this set of interview materials, I believe everyone can find a satisfactory job.

This complete set of Python learning materials has been uploaded to CSDN
If you need it, you can scan the official authentication QR code of CSDN below on wechat and get it for free [guarantee 100% free].

Topics: Python network Programmer