File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+ """
4+ @author: 闲欢
5+ """
6+ import os
7+ import easygui as g
8+ import time
9+
10+
11+ def get_macs():
12+ # 运行cmd控制窗口,输入“arp -a”,并将内容传递到res中
13+ res = os.popen("arp -a")
14+ # 读取res数据,转换为可读数据
15+ arps = res.read()
16+ print(arps)
17+
18+ # 将获得的counts中的数据根据“换行符”来进行分割切片
19+ result = arps.split('\n')
20+
21+ # 设一个空列表装ip
22+ ips = []
23+ # 设一个空列表装mac
24+ macs = []
25+
26+ # 遍历
27+ for i in range(1, len(result)):
28+ # 获得列表中第idx个数据
29+ line = result[i]
30+ if ('Internet' in line) | ('' == line) | ('接口' in line):
31+ continue
32+ # 根据“ ”进行切片
33+ line_split = line.split(" ")
34+ index = 0
35+ for l in line_split:
36+ if l != '':
37+ index += 1
38+ if index == 1:
39+ ips.append(l)
40+ elif index == 2:
41+ macs.append(l)
42+
43+ return ips, macs
44+
45+ # 老板的Mac地址
46+ bossMac = "01-00-5e-0b-14-01"
47+ sleep_time = 5
48+ while 1 == 1:
49+ time.sleep(sleep_time)
50+ ips, macs = get_macs()
51+ is_come = 0
52+ for mac in macs:
53+ if mac == bossMac:
54+ is_come = 2
55+ # 如果boss来了,就隔5分钟扫描一次
56+ sleep_time = 300
57+ # 提示报警
58+ choice = g.msgbox(msg="有内鬼,终止交易!", title="OMG")
59+ break
60+ if is_come == 0:
61+ # 如果boss走了,就隔5秒钟扫描一次
62+ sleep_time = 5
63+ g.msgbox(msg="一切正常!", title="OMG")
You can’t perform that action at this time.
0 commit comments