Advertisement
AlexApProd

MagReader security

Mar 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. local event = require("event")
  2. local component = require("component")
  3. local term = require("term")
  4. pass = "password"
  5. local off = true
  6. local master = "MasterKey"
  7. local wait = 2000
  8. local i = 0
  9. local j = 0
  10. local k = 8
  11. local PWL = 2
  12. screen_main = "b67d7322-50b6-4b93-8459-4e03192ce966"
  13.  
  14.  whiteList= {
  15.  "AlexApProd",
  16.  "Orange_Apple"
  17.  }
  18.  
  19.  doors = {
  20.  "9ef75fe3-20c8-4bd3-8fb0-42b6002762f0",
  21.  "aca1f68a-2527-4d29-be5f-d873ab247fa5",
  22.  "3ac6844a-babd-4461-a0bc-d4c6bb80dc44",
  23.  "4b821dd1-b956-4252-b0da-6ee8c3f91403",
  24.  "52be3fbe-5c22-40d7-8827-6fa5f0e5d29b",
  25.  "308bb094-36de-4b6a-9580-bfcf1fd996e1",
  26.  "0e61f90e-8882-4530-8c19-6031d6eb347e",
  27.  "f89d08d6-6ad6-4b8e-86b7-f8fbf5bb2695"
  28. }
  29.  
  30.  reader = {
  31.  "00b4d264-a022-4cb6-b51f-d75baa693ef3",
  32.  "6549e4c7-8491-4d5a-aa12-360f9e4904c8",
  33.  "0e7634ec-9420-4e45-8be9-8841ea54a5fa",
  34.  "dcbec41e-7855-46e3-a433-40e40179469d",
  35.  "242224b3-f525-44f4-b175-959d214c092e",
  36.  "3c66955c-d647-465f-81e6-4c04f929a638",
  37.  "cad08827-cd3f-48a3-8ae9-9c56b1efbee6",
  38.  "32e8c885-33ab-4102-96dd-31351de96761"
  39. }
  40.  
  41.  name = {
  42.  "Applied Energetics серверная ",
  43.  "Энергохранилище",
  44.  "Переработка руд",
  45.  "Open Computers серверная",
  46.  "Главный вход",
  47.  "Трансформаторная",
  48.  "Комната Thermal Expansion",
  49.  "Крафтильня"
  50.  }
  51.  
  52.  screen = {
  53.  "f5021187-7b71-4460-af86-0cf9ed6391c4",
  54.  "caef9da9-a38b-4ffb-9411-ec46f9c002ab",
  55.  "1de72f20-e4a8-4b8e-a63e-3a2d3232fcb5",
  56.  "0846cd1b-4e71-4c3d-af92-2aef90be2935",
  57.  "fc7bdb3a-63a4-4175-9533-b8b14b964a09",
  58.  "ce24c293-ed7e-472e-92ca-f8c7568de498",
  59.  "26ac90a6-435d-4190-a1c0-d25519c612b8",
  60.  "acda089c-c74f-4660-861b-9d1fb0f35fb2"
  61. }
  62.  
  63. function sleep(ms)
  64.  local z = os.clock() * 1000
  65.  while os.clock() * 1000 - z < ms do end
  66. end
  67.  
  68. for i=1,k do
  69.  component.invoke(doors[i],"setPassword","",pass)
  70.  component.invoke(doors[i],"close",pass)
  71. end
  72.  
  73.  term.clear()
  74.  
  75. while off do
  76.  _,adress,pName,data = event.pull("magData")
  77.  
  78.  if data == master then
  79.   off = false
  80.   for i=1,k do
  81.    component.invoke(doors[i],"open",pass)
  82.   end
  83.   print("Система безопастности отключена: " ..pName)
  84.  end
  85.  for j=1,PWL do
  86.   if pName == whiteList[j] then
  87.   j=PWL+1
  88.   for i=0, k do
  89.    if reader[i] == adress then
  90.     if data ~= "3"  and i<3 then
  91.      component.setPrimary("screen",screen[i])
  92.      print("Недостаточный уровень доступа")
  93.      component.setPrimary("screen",screen_main)
  94.      print(pName.." открыл " .. name[i])
  95.     else
  96.      component.invoke(doors[i],"open",pass)
  97.      component.setPrimary("screen",screen[i])
  98.      print("Доступ разрешен")
  99.      component.setPrimary("screen",screen_main)
  100.      print(pName.." открыл " .. name[i])
  101.      sleep(wait)
  102.      component.invoke(doors[i],"close",pass)
  103.     end
  104.    end  
  105.   end
  106.   end
  107.   end
  108.  if j==PWL then
  109.    for i=0, k do
  110.    if reader[i] == adress then
  111.     component.setPrimary("screen",screen[i])
  112.      print("Вы отсутствуете в WhiteList")
  113.      component.setPrimary("screen",screen_main)
  114.      print(pName.." открыл " .. name[i])
  115.    end
  116.   end
  117.   end
  118.  j=0
  119.  i=0
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement