Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Clear the screen and set up colors
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- -- Define the width and height of the screen
- local width, height = term.getSize()
- -- Function to center text on the screen
- local function centerText(y, text, textColor)
- local x = math.floor((width - #text) / 2)
- term.setCursorPos(x, y)
- term.setTextColor(textColor)
- term.write(text)
- end
- -- Display the initial message "Doggy OS Security Error!" at the top in white
- centerText(3, "Doggy OS Security Error!", colors.white)
- -- Function to show an error message with ASCII art
- local function showError(message)
- term.clear()
- -- ASCII art with yellow dog and ? eyes
- local dogArt = {
- " |\\_/| ",
- " | ? ? ",
- " | <> _ ",
- " | _/\\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___. ",
- "/_/_____/____/_______| "
- }
- local startLine = math.floor((height - #dogArt) / 2) - 2
- -- Display the dog ASCII art with yellow color and ? eyes
- term.setTextColor(colors.yellow)
- for i, line in ipairs(dogArt) do
- centerText(startLine + i, line, colors.yellow)
- end
- -- Display error message below the dog ASCII art in white
- term.setTextColor(colors.white)
- centerText(startLine + #dogArt + 2, "Error:", colors.white)
- centerText(startLine + #dogArt + 3, message, colors.white)
- -- Move "Please contact support." to the bottom in white
- centerText(height - 2, "Please contact support.", colors.white)
- end
- -- Function to request admin credentials
- local function requestAdminUnlock()
- term.clear()
- centerText(3, "System Locked!", colors.red)
- centerText(5, "Enter Admin Credentials to Unlock", colors.white)
- -- Get username and password
- term.setCursorPos(math.floor(width / 2) - 6, height // 2)
- term.write("Username: ")
- local username = read()
- term.setCursorPos(math.floor(width / 2) - 6, height // 2 + 1)
- term.write("Password: ")
- local password = read("*")
- -- Check if user has both password.txt and admin.txt
- local userDir = "/disk/users/" .. username
- local adminPath = fs.combine(userDir, "admin.txt")
- local passwordPath = fs.combine(userDir, "password.txt")
- if fs.exists(adminPath) and fs.exists(passwordPath) then
- local file = fs.open(passwordPath, "r")
- if file.readAll() == password then
- fs.delete("/boot.lock")
- term.clear()
- centerText(3, "System Unlocked", colors.green)
- sleep(1)
- return true
- end
- file.close()
- end
- centerText(height - 1, "Invalid Credentials or No Admin Privileges.", colors.red)
- sleep(2)
- return false
- end
- -- Function to check for boot.lock file
- local function checkBootLock()
- if fs.exists("/boot.lock") then
- while not requestAdminUnlock() do end
- end
- end
- -- Main function to initiate checks and continue boot process
- local function main()
- checkBootLock()
- -- Additional security checks...
- shell.run("/disk/boot/BIOS") -- Continue to boot
- end
- -- Start the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement