Advertisement
SirSheepe

Server [Security]

Oct 18th, 2018 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.47 KB | None | 0 0
  1. do -- Installing sheepelibs due to dependancies
  2.     if fs.exists("sheepelibs") then
  3.         for _, api in pairs(fs.list("sheepelibs")) do
  4.             local name = api:match("(%w+)%.lua")
  5.             if name then
  6.                 os.unloadAPI("sheepelibs/"..api)
  7.             end
  8.         end
  9.  
  10.         fs.delete("sheepelibs")
  11.         fs.delete("sheepelibs.lua")
  12.         os.reboot()
  13.     end
  14.  
  15.     local con = http.get("https://pastebin.com/raw/X43Ldruq")
  16.  
  17.     if con then
  18.         local source = con.readAll()
  19.         con.close()
  20.  
  21.         local func, err = load(source, "X43Ldruq", "t", _ENV)
  22.  
  23.         if not func then
  24.             printError(err)
  25.             return
  26.         end
  27.  
  28.         local success, msg = pcall(func, "true")
  29.  
  30.         if not success then
  31.             printError(msg)
  32.             return
  33.         end
  34.     end
  35. end
  36.  
  37. Encryption.DefineFactors({
  38.     0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  39.     0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  40.     0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  41.     0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  42.     0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  43.     0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  44.     0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  45.     0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  46.     0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  47.     0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  48.     0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  49.     0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  50.     0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  51.     0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  52.     0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  53.     0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  54. })
  55.  
  56. local INTERNAL_KEY = "10279171dda627442404d64f68134c38fb130b33166e1a00230ba6bdc057a175"
  57. local SERVER_KEY = "c071136ae9fc8b0ecbdb3534434192e9232675b3053f06d37aa8adb014916e63"
  58. local LOCK_KEY = "ab73f7cc67ea1bc27f4667d6a29c44066045605069b468f3e42395cbae3eb31e"
  59.  
  60. local SEEDBASE = Encryption.SHA256(tostring(0x766a0abbf0fc19dc))
  61. local MASTER_SEED = tonumber(SEEDBASE:gsub("%l", ""))
  62.  
  63. local DECODE_KEY = Encryption.Encrypt(SEEDBASE, INTERNAL_KEY)
  64.  
  65. math.randomseed(MASTER_SEED)
  66.  
  67. local BYTECODE = ""
  68.  
  69. for byteCount = 1, 2 ^ 12 do
  70.     local byte = ""
  71.     for bitCount = 1, 8 do
  72.         byte = byte .. math.random(0, 1)
  73.     end
  74.     BYTECODE = BYTECODE .. byte
  75. end
  76.  
  77. local INTERNAL_PASS = Encryption.SHA256(BYTECODE)
  78. print(INTERNAL_PASS)
  79.  
  80. local modem = peripheral.find("modem")
  81.  
  82. local POCKET_TO = 10172
  83. local SERVER_TO = 41718
  84. local SERVER_FROM = 15133
  85.  
  86. modem.open(POCKET_TO)
  87. modem.open(SERVER_TO)
  88. modem.open(SERVER_FROM)
  89.  
  90. local KEY_DISTRIBUTION = os.startTimer(2)
  91.  
  92. while true do
  93.     local event, arg0, arg1, arg2, arg3, arg4 = os.pullEvent()
  94.  
  95.     if event == "modem_message" then
  96.         if arg1 == SERVER_TO and arg2 == SERVER_FROM and type(arg3) == "string" then
  97.             local SERVER_CODE = arg3
  98.             local LOCK_CODE = Encryption.Decrypt(SERVER_CODE, SERVER_KEY)
  99.             local POCKET_PASS = Encryption.Decrypt(LOCK_CODE, LOCK_KEY)
  100.  
  101.             if POCKET_PASS == INTERNAL_PASS then -- AY SUCCESS
  102.                 print("YEET")
  103.                 modem.transmit(SERVER_FROM, SERVER_TO, Encryption.Encrypt(SERVER_KEY, SERVER_KEY)) -- REDO LATER, NOT SECURE
  104.             end
  105.         end
  106.     elseif event == "timer" and arg0 == KEY_DISTRIBUTION then
  107.         modem.transmit(POCKET_TO, SERVER_FROM, DECODE_KEY)
  108.         KEY_DISTRIBUTION = os.startTimer(1)
  109.     end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement