Advertisement
sethxi

PCAuth Installer

Apr 11th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. args = { ... }
  2.  
  3. if not args[1] then
  4. print("Usage:\n"
  5. .. "install <password>")
  6. return
  7. end
  8.  
  9. function hash(str)
  10. local s = 0
  11. local p = ""
  12.  
  13. for c in str:gmatch(".") do
  14. s = s + string.byte(c)
  15. end
  16.  
  17. s = bit.bxor(65432895, s)
  18.  
  19. while s > 0 do
  20. p = p .. string.char(s % 94 + 33)
  21. s = bit.brshift(s, 1)
  22. end
  23.  
  24. return string.sub(p, 1, p:len() - 1)
  25. end
  26.  
  27. local f = fs.open("/lock", "w")
  28. f.write([[local password = "]] .. hash(args[1]) .. [["
  29. os.pullEvent = os.pullEventRaw
  30.  
  31. function hash(str)
  32. local s = 0
  33. local p = ""
  34.  
  35. for c in str:gmatch(".") do
  36. s = s + string.byte(c)
  37. end
  38.  
  39. s = bit.bxor(65432895, s)
  40.  
  41. while s > 0 do
  42. p = p .. string.char(s % 94 + 33)
  43. s = bit.brshift(s, 1)
  44. end
  45.  
  46. return string.sub(p, 1, p:len() - 1)
  47. end
  48.  
  49. while true do
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. if term.isColor() then term.setTextColor(colors.blue) end
  53. term.write("Liquid Obsidian's Authenticator v")
  54. if term.isColor() then term.setTextColor(colors.purple) end
  55. term.write("2.0")
  56. if term.isColor() then term.setTextColor(colors.orange) end
  57. for i = 0, i < 2 do print("") end
  58. term.write("Enter Password: ")
  59. local input = read("*")
  60. if hash(input) == password then
  61. term.clear()
  62. term.setCursorPos(1,1)
  63. printWithFormat("&5Access Granted!\n")
  64. return
  65. else
  66. printWithFormat("&1Access Denied!")
  67. sleep(2)
  68. end
  69. end]])
  70. f.close()
  71.  
  72. f = fs.open("/startup", "w")
  73. f.write("shell.run('lock')")
  74. f.close()
  75.  
  76. term.clear()
  77. term.setCursorPos(1, 1)
  78.  
  79. local hiddenPassword = ""
  80. for i = 1, args[1]:len() do
  81. hiddenPassword = hiddenPassword .. "*"
  82. end
  83.  
  84. term.setTextColor(colors.green)
  85. print("Auth installed with password " .. hiddenPassword .. "!")
  86.  
  87. sleep(1.5)
  88.  
  89. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement