Advertisement
AssortedBrunoz

radar program

Dec 19th, 2024 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.37 KB | None | 0 0
  1. local allChars = {}
  2. local id = os.getComputerID()
  3. local modem = peripheral.find("modem")
  4. local version = 1.001
  5. if tonumber(http.get("https://pastebin.com/raw/Hc0khPmm").readAll()) ~= version then
  6.     fs.delete(shell.getRunningProgram())
  7.     shell.run("pastebin get JaH9yL2t startup.lua")
  8.     print("rebooting, update successful")
  9.     shell.run("reboot")
  10. end
  11. if not fs.exists("DiscoHook") then
  12.     shell.run("wget https://raw.githubusercontent.com/banana-boye/DiscoHook/refs/heads/main/DiscoHook.lua DiscoHook")
  13. end
  14. if not fs.exists("stringtools") then
  15.     shell.run("wget https://raw.githubusercontent.com/banana-boye/CC_stringtools/refs/heads/main/stringtools.lua stringtools")
  16. end
  17. require("stringtools")()
  18. local DiscoHook = require("DiscoHook")
  19. local storage = DiscoHook.create("https://discord.com/api/webhooks/1316102809002836059/B_2l6RncV-J8dUwXGSHl7r2v0f0o1K5sXi8ckZO45cK8pczq6_vaL7ELbn8gn3RJLEvE")
  20. local webhook = DiscoHook.create("https://discord.com/api/webhooks/1311085399506161724/IkZxlJe0Mb_rl4H0i3arnXhwQzzsmBYloZhpcAYBFN6uL4H0vyNp1V1kLsGSNej1DwZS")
  21.  
  22. for i = 0, 255 do
  23.     allChars[i] = string.char(i)
  24. end
  25.  
  26. local function encrypt(message)
  27.     message = string.fracture(textutils.serialise(message))
  28.     local new = ""
  29.     for _, char in pairs(message) do
  30.         for _idx, _char in ipairs(allChars) do
  31.             if char == _char then
  32.                 new = new..allChars[(_idx+id)%#allChars]
  33.             end
  34.         end
  35.     end
  36.     return new.."_"..id
  37. end
  38.  
  39. local function decrypt(message)
  40.     message = string.fracture(message)
  41.     local unlockId = ""
  42.     for i = #message, 1, -1 do
  43.         if message[i] ~= "_" then
  44.             unlockId = unlockId..message[i]
  45.         else
  46.             for j = i, #message do
  47.                 message[j] = nil
  48.             end
  49.             break
  50.         end
  51.     end
  52. ---@diagnostic disable-next-line: cast-local-type
  53.     unlockId = tonumber(string.reverse(unlockId))
  54.     local new = ""
  55.     for _, char in pairs(message) do
  56.         for _idx, _char in ipairs(allChars) do
  57.             if char == _char then
  58.                 new = new..allChars[(_idx-unlockId)%#allChars]
  59.             end
  60.         end
  61.     end
  62.     return textutils.unserialise(new)
  63. end
  64.  
  65. local function awaitMessage(channel, timeOut, condition)
  66.     local toReturn = {}
  67.     parallel.waitForAny(function()
  68.         repeat
  69.             os.sleep(1)
  70.             timeOut = timeOut - 1
  71.         until timeOut <= 0
  72.         toReturn = {false}
  73.     end, function()
  74.         while next(toReturn) == nil do
  75.             local received = table.pack(os.pullEvent("modem_message"))
  76.             if received[3] == channel then
  77.                 received[5] = decrypt(received[5])
  78.                 if condition(received) then
  79.                     toReturn = {true, received}
  80.                 else
  81.                     toReturn = {false}
  82.                 end
  83.             end
  84.         end
  85.     end)
  86.     return table.unpack(toReturn)
  87. end
  88.  
  89. local tries = 3
  90. local safe = false
  91. modem.open(37173)
  92. while not safe do
  93.     repeat
  94.         modem.transmit(37073, 37173, encrypt({
  95.             lookingForType = "phone",
  96.             operation = "radarCheck",
  97.             connector = "pc",
  98.             sender = id
  99.         }))
  100.         local success, _ = awaitMessage(37173,10, function(received)
  101.             local message = received[5]
  102.             if received[6] <= 512 and message.operation == "radarResponse" and message.connector == "phone" and message.lookingFor == id then
  103.                 return true
  104.             else
  105.                 return false
  106.             end
  107.         end)
  108.         if success then
  109.             safe = true
  110.             break
  111.         end
  112.  
  113.         tries = tries - 1
  114.     until tries <= 0
  115.     pcall(function()
  116.         if not safe then
  117.             local onlineStorage = textutils.unserialise(storage:getMessage("1319420827849981952").content)
  118.     ---@diagnostic disable-next-line: param-type-mismatch
  119.             onlineStorage[os.getComputerLabel()] = os.time(os.date("!*t"))
  120.             storage:editMessage("1319420827849981952", textutils.serialise(onlineStorage))
  121.             local message = "# NSP RADAR SYSTEM\n"
  122.             for label, time in pairs(onlineStorage) do
  123.                 message = message..label..": ACTIVATED AT <t:"..time..":D> <t:"..time..":T> [ping here]\n"
  124.             end
  125.  
  126.             webhook:editMessage("1311086115981365330", message)
  127.         end
  128.    end)
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement