Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local shell = require("shell")
- local keyboard = require("keyboard")
- local computer = require("computer")
- local event = require("event")
- local io = require("io")
- u = io.open("/username.dat", "r")
- textu = u:read()
- u:close()
- us = io.open("/usernames.dat", "r")
- textus = us:read()
- us:close()
- ps = io.open("/passwords.dat", "r")
- textps = ps:read()
- ps:close()
- local dir = shell.getWorkingDirectory()
- local userHome = "/usr/home/" .. textu .. "/"
- function root()
- if dir ~= userHome and dir <= userHome then
- local needSuper = "true"
- print("This action requires root access.")
- end
- end
- function super()
- if needSuper == true then
- print("User: ")
- username = term.read()
- username = string.gsub(username, "\n", "")
- print("Password: ")
- password = term.read(nil, nil, nil, "")
- password = string.gsub(password, "\n", "")
- end
- if username == textus and password == textps then
- local superUser = "true"
- print("Logged in as Root.")
- os.sleep(1)
- os.setenv("PS1", "root" .. "@" .. textu .. "$ ")
- shell.setWorkingDirectory("/")
- else
- print("Login failed.")
- end
- end
- while true do
- root()
- if root == needSuper then
- super()
- end
- if superUser == true then
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement