Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TNT Security 1.0
- function checkForFiles()
- password = fs.isDir("/etc/")
- if password == true then
- passwordFile = fs.open("/etc/shadow.passwd","r")
- password = passwordFile.readLine()
- passwordFile.close()
- return password
- else
- return false
- end
- end
- function setupPassword(iscolor)
- if iscolor then
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.blue)
- else
- term.clear()
- end
- print("Welcome to TNTSecurity 1.0")
- print("Press O to get started and X to uninstall")
- term.setCursorPos(5,10)
- print("O")
- term.setCursorPos(10,10)
- print("X")
- on = true
- while on do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x == 5 and y == 10 then
- on = false
- elseif x == 10 and y == 10 then
- uninstall()
- end
- end
- passwordNotSet = true
- while passwordNotSet do
- term.clear()
- term.setCursorPos(1,1)
- print("Enter a password")
- password1 = read("*")
- print("Enter the password again")
- password2 = read("*")
- if password1 == password2 then
- passwordNotSet = false
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Saving...")
- passwordfile = fs.open("etc/shadow.passwd","w")
- passwordfile.write(password1)
- passwordfile.close()
- os.reboot()
- end
- function uninstall()
- fs.delete("startup")
- os.reboot()
- end
- function login(iscolor,storedpassword)
- locked = true
- while locked do
- if iscolor then
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.blue)
- else
- term.clear()
- end
- term.setCursorPos(1,1)
- print("TNTSecurity 1.0")
- print("Enter Password")
- password = read("*")
- if password == storedpassword then
- term.clear()
- term.setCursorPos(1,1)
- print("Password Correct!")
- os.sleep(1)
- locked = false
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Password Incorrect!")
- os.sleep(1)
- end
- end
- end
- function init()
- iscolor = term.isColor()
- password = checkForFiles()
- if password == false then
- setupPassword(iscolor)
- else
- login(iscolor,password)
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment