{"id":13774530,"url":"https://github.com/wangshub/hmpa-pi","last_synced_at":"2025-05-11T06:33:22.505Z","repository":{"id":91519471,"uuid":"167124935","full_name":"wangshub/hmpa-pi","owner":"wangshub","description":"📡 🔔 监听附近网络 Wi-Fi 设备，通过邮件和微信进行消息推送","archived":false,"fork":false,"pushed_at":"2019-01-25T03:15:40.000Z","size":998,"stargazers_count":189,"open_issues_count":0,"forks_count":29,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-08-03T17:11:06.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wangshub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-23T05:48:53.000Z","updated_at":"2024-07-31T02:56:55.000Z","dependencies_parsed_at":"2023-03-13T17:43:31.028Z","dependency_job_id":null,"html_url":"https://github.com/wangshub/hmpa-pi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangshub%2Fhmpa-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangshub%2Fhmpa-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangshub%2Fhmpa-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangshub%2Fhmpa-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangshub","download_url":"https://codeload.github.com/wangshub/hmpa-pi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225022183,"owners_count":17408578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:27.641Z","updated_at":"2024-11-17T09:31:00.010Z","avatar_url":"https://github.com/wangshub.png","language":"Python","funding_links":[],"categories":["\u003ca id=\"6fa0e0d1f898fba299b2566a33602841\"\u003e\u003c/a\u003eWireshark"],"sub_categories":[],"readme":"# hmpa-pi\n\n在树莓派上，利用 Wireshark 扫描附近网络 WiFi 设备，并对扫描结果通过邮件或者微信进行推送。\n\n临近春节回老家过年，家里没人，又不想安装摄像头监控，参考 [howmanypeoplearearound](https://github.com/schollz/howmanypeoplearearound) 写了一个监测脚本，当有手机或其它 Wi-Fi 设备在附近时，通过邮件或者微信提醒。\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"pics/raspberrypi.jpg\" width=\"50%\"/\u003e\n\u003c/p\u003e\n\n## 特性\n\n- [x] Wi-Fi 设备扫描\n- [x] 邮件提醒\n- [x] 微信提醒(Server 酱)\n- [ ] 陌生设备检测\n\n## 原理\n\n在 Wi-Fi 网络中，无线网卡是以广播模式发射信号的。当无线网卡将信息广播出去后，所有的设备都可以接收到该信息。将无线网卡设置为监听模式后，就可以捕获到该网卡接收范围的所有数据包。\n通过这些数据包，就可以扫描出附近 Wi-Fi 的网络内的设备与信号强度。\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./pics/monitor_mode.png\"/\u003e\n\u003c/p\u003e\n\n## 监听模式的网卡\n\n一些支持监听模式的网卡\n\n\u003e [wifi-adapter-that-supports-monitor-mode](https://github.com/schollz/howmanypeoplearearound#wifi-adapter-that-supports-monitor-mode)\n\n- [USB Rt3070 $14](https://www.amazon.com/gp/product/B00NAXX40C/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B00NAXX40C\u0026linkId=b72d3a481799c15e483ea93c551742f4)\n- [Panda PAU5 $14](https://www.amazon.com/gp/product/B00EQT0YK2/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B00EQT0YK2\u0026linkId=e5b954672d93f1e9ce9c9981331515c4)\n- [Panda PAU6 $15](https://www.amazon.com/gp/product/B00JDVRCI0/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B00JDVRCI0\u0026linkId=e73e93e020941cada0e64b92186a2546)\n- [Panda PAU9 $36](https://www.amazon.com/gp/product/B01LY35HGO/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B01LY35HGO\u0026linkId=e63f3beda9855abd59009d6173234918)\n- [Alfa AWUSO36NH $33](https://www.amazon.com/gp/product/B0035APGP6/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B0035APGP6\u0026linkId=b4e25ba82357ca6f1a33cb23941befb3)\n- [Alfa AWUS036NHA $40](https://www.amazon.com/gp/product/B004Y6MIXS/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B004Y6MIXS\u0026linkId=0277ca161967134a7f75dd7b3443bded)\n- [Alfa AWUS036NEH $40](https://www.amazon.com/gp/product/B0035OCVO6/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B0035OCVO6\u0026linkId=bd45697540120291a2f6e169dcf81b96)\n- [Sabrent NT-WGHU $15 (b/g) only](https://www.amazon.com/gp/product/B003EVO9U4/ref=as_li_tl?ie=UTF8\u0026tag=scholl-20\u0026camp=1789\u0026creative=9325\u0026linkCode=as2\u0026creativeASIN=B003EVO9U4\u0026linkId=06d4784d38b6bcef5957f3f6e74af8c8)\n\n## 软件安装\n\n### Mac\n\n```bash\n brew install wireshark\n brew cask install wireshark-chmodbpf\n```\n\n### Linux 或 Raspberry Pi\n\n```bash\nsudo apt-get install tshark\n\n# run as non-root\n\nsudo dpkg-reconfigure wireshark-common     (select YES)\nsudo usermod -a -G wireshark ${USER:-root}\nnewgrp wireshark\n```\n\n## 配置网卡\n\n- 如果是支持监听模式的网卡，可以直接运行\n\n- 如果刚好在使用 `rtl8188 usb Wi-Fi 网卡` + Raspberry Pi ，需要先卸载 `rtl8192` 驱动，再加载 `rtl8188` 驱动\n\n    ```bash\n    #!/usr/bin/env bash\n    uname -a\n    \n    # disable rtl8192 driver\n    sudo depmod 4.14.79-v7+\n    sudo rmmod 8192cu\n    sudo modprobe rtl8192cu\n    \n    # set RTL8188 monitor mode\n    sudo ifconfig wlan1 down\n    sudo iwconfig wlan1 mode monitor\n    sudo ifconfig wlan1 up\n    ```\n\n## 运行代码\n\n### 下载代码\n```bash\ngit clone https://github.com/wangshub/hmpa-pi.git \ncd hmpa-pi/ \u0026\u0026 pip install -r requirements.txt\n\n```\n\n### 编辑配置文件\n\n```bash\ncp config/config.py.example config/config.py\nvi config/config.py\n```\n\n参考配置\n\n```python\nadapter = 'wlan1'\n\nuse_email = True\nemail = {\"host\": \"smtp.163.com\",\n         \"port\": 465,\n         \"user\": \"xxxxxxx@163.com\",\n         \"password\": \"xxxxxxxxxx\",\n         \"to_user\": \"xxxxxxxx@xxxx.com\"}\n\nuse_wechat = True\nserverchan = {\"sckey\": \"xxxxxxxxxxxxxxxxxxxxx\"}\n\n\nknown_devices = {\"94:65:2d:xx:xx:xx\": \"my cellPhone\",\n                 \"dc:a4:ca:xx:xx:xx\": \"my Mac\",\n                 \"b8:27:eb:xx:xx:xx\": \"my raspberry\"}\n```\n\n### 运行\n\n```bash\npython main.py\n```\n\n## 消息推送\n\n- [Server 酱微信推送](http://sc.ftqq.com/3.version)，需要 Github 登录获取 `sckey`\n- yagmail 邮箱推送\n\n## 运行结果\n\n```text\n2019-01-24 07:37:01.211617 一共发现了 67 台设备\n\nKnown Devices:\n- my cellPhone\n- my raspberry\n- my mac\n\nAll Devices:\n- 00:e0:70:3e:xx:xx 14 DH TECHNOLOGY\n- 94:65:2d:91:xx:xx 14 OnePlus Technology (Shenzhen) Co., Ltd\n- dc:d9:16:7e:xx:xx -12 HUAWEI TECHNOLOGIES CO.,LTD\n- b8:27:eb:12:xx:xx -20 Raspberry Pi Foundation\n- 98:01:a7:eb:xx:xx -40 Apple, Inc.\n- 20:5d:47:44:xx:xx -44 vivo Mobile Communication Co., Ltd.\n- ac:b5:7d:5f:xx:xx -46 Liteon Technology Corporation\n- 04:03:d6:1f:xx:xx -47 Nintendo Co.,Ltd\n- d4:ee:07:55:xx:xx -48 HIWIFI Co., Ltd.\n- 44:6e:e5:63:xx:xx -51 HUAWEI TECHNOLOGIES CO.,LTD\n- 14:75:90:8d:xx:xx -51 TP-LINK TECHNOLOGIES CO.,LTD.\n- 34:96:72:1d:xx:xx -56 TP-LINK TECHNOLOGIES CO.,LTD.\n- d8:cb:8a:74:xx:xx -57 Micro-Star INTL CO., LTD.\n- 40:8d:5c:21:xx:xx -57 GIGA-BYTE TECHNOLOGY CO.,LTD.\n- 6c:59:40:25:xx:xx -58 SHENZHEN MERCURY COMMUNICATION TECHNOLOGIES CO.,LTD.\n\nMore ...\n```\n\n## TODO\n\n- [ ] 美化打印信息\n- [ ] 更优雅的参数配置\n- [ ] 当发现新设备时提醒\n- [ ] 绘图统计\n- [ ] 设备距离估计\n\n## 参考链接\n\n- [schollz / howmanypeoplearearound](https://github.com/schollz/howmanypeoplearearound)\n- [derv82 / wifite2](https://github.com/derv82/wifite2)\n- [第 3 章 监听 WiFi 网络](http://www.tup.tsinghua.edu.cn/upload/books/yz/067209-01.pdf)\n\n## License\n\n- MIT\n- 仅供学习和研究，切勿非法使用\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangshub%2Fhmpa-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangshub%2Fhmpa-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangshub%2Fhmpa-pi/lists"}