📜 ⬆️ ⬇️

Open the doors remotely

image
In our office, some important doors open with "cards" - contactless RFID keys. The whole SKD business is called and is based on Orion software from Bolid. Once I thought: “It would be great to open the doors from a smartphone!”. Challenge accepted!



Step 1.
A quick inspection of the “Operational Task” and the “Database Administrator” (Orion software components) showed that non-human intervention in the operation of the system is not possible. At least in open sources about this says nothing. But there is the possibility of adding Management Scripts.
')
image

This allows us to perform some sequence of actions by pressing a key (or a combination of them). Already something. We add the script, assign it to the keys (Shift + W in my case), check (do not forget to do “Update DB in the Operational Task” in the Tools menu item) - it works!

Step 2.
The first step did not bring us much benefit. You can open the door only by pressing the desired key combination in the Operational Task. It remains only to go to the forehead: to emulate the pressing of buttons. Since the programmer from me is not very good, and I didn’t want to spend a lot of time on this, the choice of means for implementing this perversion fell on Processing. Write the code:

import processing.net.*; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; Robot robot; String HTTP_GET_REQUEST = "GET /"; String HTTP_HEADER = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"; Server s; Client c; String input; char keycode; void setup() { s = new Server(this, 8080); // start server on http-alt try { robot = new Robot(); } catch (AWTException e) { e.printStackTrace(); } } void draw() { //     c = s.available(); if (c != null) { input = c.readString(); input = input.substring(0, input.indexOf("\n")); //     if (input.indexOf(HTTP_GET_REQUEST) == 0) { c.write(HTTP_HEADER); input = input.substring(4,7); //       if(input.indexOf('q') > 0) keycode=KeyEvent.VK_Q; if(input.indexOf('w') > 0) keycode=KeyEvent.VK_W; if(input.indexOf('e') > 0) keycode=KeyEvent.VK_E; //   robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(keycode); //   robot.keyRelease(keycode); robot.keyRelease(KeyEvent.VK_SHIFT); c.stop(); //   } } } 


To be honest, I took the code from examples. I think everyone will understand what is happening there.
Whoever does not understand, I explain: we are listening to port 8080, we receive a request, we pull out the necessary parameter from it, we react adequately to it.
It turned out such a mini-server on the knee. You need to run it on the ACS server and it will do what it needs.

Step 3.
We already can not just open the door, but remotely. It remains to write a web-muzzle.

 <?PHP header("Content-Type: text/html; charset=windows-1251"); $act = $_REQUEST['act']; if(!$act) buttons(); //   if($act=='push') push(); //   function push(){ $btn = $_REQUEST['btn']; if($btn!='') { //    $fp = fopen("http://___:8080/".$btn, "r"); fclose($fp); } } function buttons() { //        JavaScript ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html><head> <script type="text/javascript"> function getXmlHttp(){ var xmlhttp; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } function btnClick(i) { //alert(i); var req = getXmlHttp(); req.open('GET', 'index.php?act=push&btn='+i, true); req.send(null); } </script> <button style="width: 100%; height: 50px;" onclick='btnClick("q")'></button><br><br> <button style="width: 100%; height: 50px;" onclick='btnClick("w")'>2 </button><br><br> <button style="width: 100%; height: 50px;" onclick='btnClick("e")'></button><br><br> </head></html> <?PHP } ?> 


VEB performance is chosen for greater versatility: you can run on any platform. Although you can write on the same processing and run on Android.

Summary.
Of course, this is a crutch. The system has many critical flaws. Doors are opened by the System Administrator, and not by an employee, which makes it impossible to keep track of working time and tracking an employee’s movement around the office. The keystroke emulator does not work while the user of the system under which it is running is not active. Of course, you can use it, but it was done in an hour.
If you have any suggestions for improving this project, I will be glad to hear.

Plans
Of course, first of all I would like to do without emulating keystrokes. I'll try to contact the Orion software developers, maybe they will go to the meeting.
Next, you can make authorization on the user's domain credentials to differentiate access rights, i.e. give everyone the opportunity to open only those doors that are supposed to be.

Source: https://habr.com/ru/post/196990/


All Articles