Advertisement
1lann

authclient.lua

May 20th, 2020
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local chan = 15432
  2.  
  3. local k = require("k")
  4. local secret = "secretword"
  5. local mod = peripheral.wrap("back")
  6.  
  7. local trusted = {
  8.     ["16714"] = true
  9. }
  10.  
  11. mod.open(chan)
  12.  
  13. while true do
  14.     local e, p1, p2, p3, p4, p5 = os.pullEvent()
  15.     if e == "modem_message" and p2 == chan and type(p4) == "string" and p4:sub(1, 10) == "authchall:" and p5 and p5 < 5 then
  16.         local computerID, epoch = p4:match("authchall:(%d+):(%d+)")
  17.         if computerID and trusted[tostring(computerID)] then
  18.             local response = "authresp:" .. k.sha256(p4 .. ":" .. secret .. ":" .. tostring(p5))
  19.             mod.transmit(chan, chan, response)
  20.             print("fulfilled challenge")
  21.         else
  22.             print("invalid challenge")
  23.         end
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement