Recently the entire Institute of the laboratory to the people to adopt a mobile phone Bluetooth check-in mechanism, everyone needs to install an app on the phone, and then manually click the check-in and leave button to count each person's daily work time, it is a anti-human design, in the spirit of just hacking for fun, ARP sniffing the mobile phone sent to the packet, learned that and the server is through the TCP communication, but also get the format of the packet, so started to write scripts, to achieve automatic registration.
The code is as follows, implemented with a PHP socket:
1<?PHP2 /**3 * 1. Generate the current time to determine which time period is in the morning, afternoon, evening4 *5 * 2. Generate random time based on time period judgment6 *7 * 3. Packet sending check-in data8 *9 * Ten */ One //function to generate random time ADate_default_timezone_set (' asia/chongqing '); - functionRand_time ($start _time,$end _time){ - the $start _time=Strtotime($start _time); - $end _time=Strtotime($end _time); - return Date(' Y-m-d h:i:s ',Mt_rand($start _time,$end _time)); - } + $curTime=Date("H:i:s");//Current Time - if($curTime>= "06:00:00" &&$curTime<= "09:30:59") + { A $startTime=Date("y-m-d"). " 06:00:00 "; at $endTime=Date("y-m-d"). " 08:30:59 "; - $signTime=rand_time ($startTime,$endTime); - } - Else if($curTime>= "09:31:00" &&$curTime<= "12:30:59") - { - $startTime=Date("y-m-d"). " 11:45:00 "; in $endTime=Date("y-m-d"). " 12:30:59 "; - $signTime=rand_time ($startTime,$endTime); to } + - if($curTime>= "13:30:00" &&$curTime<= "15:30:59") the { * $startTime=Date("y-m-d"). " 13:30:00 "; $ $endTime=Date("y-m-d"). " 14:30:59 ";Panax Notoginseng $signTime=rand_time ($startTime,$endTime); - } the Else if($curTime>= "15:31:00" &&$curTime<= "18:30:59") + { A $startTime=Date("y-m-d"). " 17:45:00 "; the $endTime=Date("y-m-d"). " 18:30:59 "; + $signTime=rand_time ($startTime,$endTime); - } $ if($curTime>= "19:30:00" &&$curTime<= "21:00:59") $ { - $startTime=Date("y-m-d"). " 19:30:00 "; - $endTime=Date("y-m-d"). " 20:00:59 "; the $signTime=rand_time ($startTime,$endTime); - }Wuyi Else if($curTime>= "21:01:00" &&$curTime<= "23:00:59") the { - $startTime=Date("y-m-d"). " 22:30:00 "; Wu $endTime=Date("y-m-d"). " 23:00:59 "; - $signTime=rand_time ($startTime,$endTime); About } $ $ssid=Rand(1,100); - $ssid="-".$ssid;//randomly generated signal strength - error_reporting(E_all); - Set_time_limit(0); A Echo"BlueTooth sign\n"; + the $port= 8***;//Play code here - $ip= "202.***.***.***";//Play code here $ $blueTooth=<<<Bluetoothinfo the Upload the24:**:* *:* *:* *:* * the $signTime the10:**:* *:* *:* *:* * - $ssid in Exit the the Bluetoothinfo; About $socket= Socket_create (Af_inet, Sock_stream,sol_tcp); the if($socket< 0) { the Echo"Socket_create () Failed:reason:". Socket_strerror ($socket) . "\ n"; the}Else { + Echo"Ok.\n"; - } the Bayi Echo"Try to connect"$ipPort$port' ... \ n '; the $result= Socket_connect ($socket,$ip,$port); the if($result< 0) { - Echo"Socket_connect () Failed.\nreason: ($result) " . Socket_strerror ($result) . "\ n"; -}Else { the Echo"Connection succeeded \ n"; the } the if(!socket_write ($socket,$blueTooth,strlen($blueTooth))) { the Echo"Socket_write () Failed:reason:". Socket_strerror ($socket) . "\ n"; -}Else { the Echo"Data sent successfully \ n"; the Echo"The content sent is: \ n$blueTooth"; the }94 $out= Socket_read ($socket, 20);//read the contents returned by the server, 20 bytes the if($out= = "Sbwzc\n") the { the die("Device not registered");98 } About if($out= = "Wsmdsmj\n") - {101 die("No scan to scanner, check failed, refactor packet");102 }103 if($out= = "Success\n")104 { the Echo"Sign-in success \ n";106 }107 Echo"Closing connection ... \ n";108Socket_close ($socket);109 Echo"Close success \ n"; the?>111
The Egg Ache Institute's bluetooth sign-in