Advertisement
SirSheepe

Lock [Security]

Oct 18th, 2018 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.40 KB | None | 0 0
  1. local POS_DIST = ({...})[1] -- Data persistence
  2.  
  3. if POS_DIST then
  4.     settings.set("DISTANCE_THRESHOLD", POS_DIST)
  5.     settings.save(".settings")
  6. end
  7.  
  8. ---
  9.  
  10. do -- Installing sheepelibs due to dependancies
  11.     if fs.exists("sheepelibs") then
  12.         for _, api in pairs(fs.list("sheepelibs")) do
  13.             local name = api:match("(%w+)%.lua")
  14.             if name then
  15.                 os.unloadAPI("sheepelibs/"..api)
  16.             end
  17.         end
  18.  
  19.         fs.delete("sheepelibs")
  20.         fs.delete("sheepelibs.lua")
  21.         os.reboot()
  22.     end
  23.  
  24.     local con = http.get("https://pastebin.com/raw/X43Ldruq")
  25.  
  26.     if con then
  27.         local source = con.readAll()
  28.         con.close()
  29.  
  30.         local func, err = load(source, "X43Ldruq", "t", _ENV)
  31.  
  32.         if not func then
  33.             printError(err)
  34.             return
  35.         end
  36.  
  37.         local success, msg = pcall(func, "true")
  38.  
  39.         if not success then
  40.             printError(msg)
  41.             return
  42.         end
  43.     end
  44. end
  45.  
  46. ---
  47.  
  48. local DISTANCE_THRESHOLD = settings.get("DISTANCE_THRESHOLD") or 4
  49.  
  50. local SERVER_KEY = "c071136ae9fc8b0ecbdb3534434192e9232675b3053f06d37aa8adb014916e63"
  51.  
  52. local POCKET_TO = 10172
  53. local POCKET_FROM = 19741
  54.  
  55. local SERVER_TO = 41718
  56. local SERVER_FROM = 15133
  57.  
  58. local modem = peripheral.find("modem")
  59. local monitor = peripheral.find("monitor")
  60.  
  61. modem.open(POCKET_FROM)
  62. modem.open(POCKET_TO)
  63.  
  64. modem.open(SERVER_FROM)
  65.  
  66. while true do
  67.     local event, arg0, arg1, arg2, arg3, arg4 = os.pullEvent()
  68.  
  69.     if event == "modem_message" then
  70.         if arg1 == POCKET_FROM and arg2 == POCKET_TO and arg4 <= DISTANCE_THRESHOLD and type(arg3) == "string" then
  71.             modem.transmit(SERVER_TO, SERVER_FROM, Encryption.Encrypt(arg3, SERVER_KEY)) -- Pass the message on to the server
  72.         elseif arg1 == SERVER_FROM and arg2 == SERVER_TO and type(arg3) == "string" and SERVER_KEY == Encryption.Decrypt(arg3, SERVER_KEY) then -- REDO LATER, NOT SECURE
  73.             local oldDisplay = term.redirect(monitor)
  74.             local x, y = term.getSize()
  75.             paintutils.drawFilledBox(1, 1, x, y, colors.lime)
  76.             term.redirect(oldDisplay)
  77.         elseif arg4 > DISTANCE_THRESHOLD then
  78.             local oldDisplay = term.redirect(monitor)
  79.             local x, y = term.getSize()
  80.             paintutils.drawFilledBox(1, 1, x, y, colors.red)
  81.             term.redirect(oldDisplay)
  82.         end
  83.     end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement