As a migrant worker, especially in 996, 007, apart from cooking, nothing is more exciting than occasional idleness at work and fishing in the pond.
What fish can the average person touch? Chat, Weibo, WeChat circle of friends, games, fictions, stock funds and so on.
What is the biggest obstacle to fish? Of course, the contractor (boss) hates to beat the workers to work 24 hours without interruption.
However, people's energy is limited, they can only concentrate on working for a few hours a day, and other times need to be adjusted by fishing is limited, so as long as we don't get caught by the contractors, it is quite a pleasant thing.
To do this, I wrote a tool in Python, BOSS, to monitor my boss and reduce the chance that fish will be found.
thinking
We know that each computer or mobile phone has a fixed Mac address, and our company has several AP's in the office area. Everyone's mobile phone connects to the nearest AP, so in theory if I know the Mac address of my boss's mobile phone, and then scan all the Mac addresses of my LAN, if the Mac address of my boss's mobile phone appears, Then the boss is probably near me, so fishing is more dangerous at this time; If there is no Mac address for the employer, the employer may be farther away from me and it is safer to fish at this time.
Based on the above ideas, all I have to do is get the Mac address of my boss's mobile phone, and then keep polling all Mac addresses in the LAN. Once I find the Mac address of my boss's mobile phone, I will work honestly. Once the boss's Mac address disappears, I can fish.
Realization
Get the owner's mobile Mac address
How do I get my boss's mobile Mac address?
A lot of people will probably feel useless when they hear this! You can't steal your boss's mobile phone and go inside to set it up.
There is no way out. If you are willing to use your mind, you can do a lot!
My approach is this. When other colleagues are not moving, when the boss comes in, save the Mac address information of the LAN once, and when the boss is walking, save it again, and then compare to find out the Mac address of the boss's mobile phone. To ensure accuracy, try a few more times.
Get all Mac addresses
First, use the ipconfig/all command to find the current segment:
The second step uses the polling command to ping the IP within the segment one by one, which is to set up the ARP table. The commands are as follows:
for /L %i IN (1,1,254) DO ping -w 1 -n 1 192.168.1.%iOf these, 192.168.1.%i is the segment to be queried.
The third step is to use the arp command to query all Mac addresses:
arp -aAfter running, you will see similar results:
If you're interested in learning python, you can join this QQ group: 347304177 We're learning together, and you can download a variety of Python tutorials and video recordings yourself.
code implementation
The ideas have been validated and the preparations have been made. The next step is the code implementation.
First, let's write a way to get all Mac addresses on the LAN based on the above ideas.
def get_macs(): # Run the cmd control window, enter "arp-a", and pass the content to res res = os.popen("arp -a") # Read res data and convert it to readable data arps = res.read() print(arps) # Slice the obtained counts according to the line break result = arps.split('\n') # Set an empty list to load ip ips = [] # Set an empty list to load the mac macs = [] # ergodic for i in range(1, len(result)): # Get the idx data in the list line = result[i] if ('Internet' in line) | ('' == line) | ('Interface' in line): continue # Slice according to "" line_split = line.split(" ") index = 0 for l in line_split: if l != '': index += 1 if index == 1: ips.append(l) elif index == 2: macs.append(l) return ips, macs
Then, write a periodic poll.
# The boss's Mac address bossMac = "01-00-5e-0b-14-01" sleep_time = 5 while 1 == 1: time.sleep(sleep_time) ips, macs = get_macs() is_come = 0 for mac in macs: if mac == bossMac: is_come = 2 # If boss comes, scan every five minutes sleep_time = 300 # Alert choice = g.msgbox(msg="End the deal, ghost!", title="OMG") break if is_come == 0: # If boss goes away, scan every five seconds sleep_time = 5 g.msgbox(msg="Business as usual!", title="OMG")
I'm here to set it up: If the boss appears, poll every five minutes, because if the boss is there, concentrate on your work and don't think about fishing too often. If the boss has left, poll every 5 seconds. It is better to have frequent warnings when fishing!
Run the program and when the boss comes, the warning window looks like this:
When the boss disappeared, the pop-up window was like this:
summary
Of course, if the boss doesn't start WiFi, this method will not work. Or the boss came over, but the phone responded slowly and didn't switch to AP over here, which could be dangerous. So don't rely entirely on this gadget, and watch your surroundings occasionally when you fish.