TNT_Nolan

TNTSecurity

Apr 19th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. -- TNT Security 1.0
  2.  
  3. function checkForFiles()
  4. password = fs.isDir("/etc/")
  5. if password == true then
  6. passwordFile = fs.open("/etc/shadow.passwd","r")
  7. password = passwordFile.readLine()
  8. passwordFile.close()
  9. return password
  10. else
  11. return false
  12. end
  13. end
  14.  
  15. function setupPassword(iscolor)
  16. if iscolor then
  17. term.setBackgroundColor(colors.white)
  18. term.clear()
  19. term.setTextColor(colors.blue)
  20. else
  21. term.clear()
  22. end
  23. print("Welcome to TNTSecurity 1.0")
  24. print("Press O to get started and X to uninstall")
  25. term.setCursorPos(5,10)
  26. print("O")
  27. term.setCursorPos(10,10)
  28. print("X")
  29. on = true
  30. while on do
  31. local event, button, x, y = os.pullEvent("mouse_click")
  32. if x == 5 and y == 10 then
  33. on = false
  34. elseif x == 10 and y == 10 then
  35. uninstall()
  36. end
  37. end
  38. passwordNotSet = true
  39. while passwordNotSet do
  40. term.clear()
  41. term.setCursorPos(1,1)
  42. print("Enter a password")
  43. password1 = read("*")
  44. print("Enter the password again")
  45. password2 = read("*")
  46. if password1 == password2 then
  47. passwordNotSet = false
  48. end
  49. end
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. print("Saving...")
  53. passwordfile = fs.open("etc/shadow.passwd","w")
  54. passwordfile.write(password1)
  55. passwordfile.close()
  56. os.reboot()
  57. end
  58.  
  59. function uninstall()
  60. fs.delete("startup")
  61. os.reboot()
  62. end
  63.  
  64. function login(iscolor,storedpassword)
  65. locked = true
  66. while locked do
  67. if iscolor then
  68. term.setBackgroundColor(colors.white)
  69. term.clear()
  70. term.setTextColor(colors.blue)
  71. else
  72. term.clear()
  73. end
  74. term.setCursorPos(1,1)
  75. print("TNTSecurity 1.0")
  76. print("Enter Password")
  77. password = read("*")
  78. if password == storedpassword then
  79. term.clear()
  80. term.setCursorPos(1,1)
  81. print("Password Correct!")
  82. os.sleep(1)
  83. locked = false
  84. else
  85. term.clear()
  86. term.setCursorPos(1,1)
  87. print("Password Incorrect!")
  88. os.sleep(1)
  89. end
  90. end
  91. end
  92.  
  93. function init()
  94. iscolor = term.isColor()
  95. password = checkForFiles()
  96. if password == false then
  97. setupPassword(iscolor)
  98. else
  99. login(iscolor,password)
  100. end
  101. end
  102.  
  103. init()
Advertisement
Add Comment
Please, Sign In to add comment