Build a 12-Line Python Smart Attendance System Using MAC Address Sniffing
Learn how to create a practical employee smart‑check‑in tool with just 12 lines of Python code by capturing mobile MAC addresses via a USB Wi‑Fi adapter, using scapy and pandas on Ubuntu, and automatically logging attendance without expensive hardware.
This article demonstrates building a simple employee smart‑check‑in tool using Python in just 12 lines of code.
Step 1: Overall Idea
Leverage the fact that modern employees always carry smartphones; by capturing their MAC addresses via a USB Wi‑Fi adapter in monitor mode (range ~20‑30 m), we can determine who is present at work.
Step 2: Required Environment
Ubuntu, Python 3, a USB Wi‑Fi adapter that supports monitor mode, and the scapy and pandas libraries (installable via pip).
Step 3: Preparation
Install Python 3 and an IDE (e.g., PyCharm) on Ubuntu, then open a terminal in the Python bin directory.
Store employee information, including their phone MAC addresses, in a spreadsheet.
Enable monitor mode on the Wi‑Fi adapter and start packet sniffing; the adapter must support monitor mode.
Step 4: Python Implementation
1. Use pandas to read the spreadsheet and extract the list of MAC addresses.
2. Use scapy to sniff Wi‑Fi probe request packets, filtering with packet.haslayer(Dot11ProbeReq) to capture only client‑initiated requests.
Because modern phones randomize their MAC addresses unless they have previously connected to a Wi‑Fi network, employees must connect to the office Wi‑Fi first so their real MAC can be captured.
The script runs continuously, printing detected MAC addresses and matching them against the employee list to log attendance.
Security tip: Disable Wi‑Fi on phones when not in use to prevent unintended MAC address exposure.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
