Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local diskLabel = "CC:Unlock"
- local fileName = "default.code"
- local password = "admin"
- local useDefault = ...
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- if not useDefault then
- print("Type disk label: (Default: '"..diskLabel.."')")
- local input = read()
- if (input == "") then input = diskLabel end
- diskLabel = input
- term.clear()
- term.setCursorPos(1,1)
- print("(Default: '"..fileName.."')")
- print("Type filename containing password:")
- local input = read()
- if (input == "") then input = fileName end
- fileName = input
- term.clear()
- term.setCursorPos(1,1)
- print("(Default: '"..password.."')")
- print("Type password to unlock computer:")
- local input = read()
- if (input == "") then input = password end
- password = input
- end
- local startup = [[
- local fileName = "]]..fileName..[["
- local password = "]]..password..[["
- local oldPullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("This computer have been locked.")
- local drive
- while true do
- for _, device in pairs(peripheral.getNames()) do
- if peripheral.getType(device) == "monitor" then
- local monitor = peripheral.wrap(device)
- monitor.setBackgroundColor(colors.cyan)
- monitor.setTextColor(colors.black)
- monitor.setTextScale(0.5)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Lockdown")
- end
- if peripheral.getType(device) == "drive" then
- drive = peripheral.wrap(device)
- if (drive.getDiskLabel() == "]]..diskLabel..[[") then
- local file = drive.getMountPath().."/"..fileName
- if fs.exists(file) then
- local reader = fs.open(file, "r")
- if reader then
- local content = reader.readAll()
- if content == password then
- -- Unlock device
- if fs.exists("startup") then fs.delete("startup") end
- if fs.exists("startup_old.lua") then
- if fs.exists("startup.lua") then fs.delete("startup.lua") end
- fs.move("startup_old.lua", "startup.lua")
- end
- if fs.exists("diskName") then
- local reader = fs.open("diskName", "r")
- local content = reader.readAll()
- reader.close()
- os.setComputerLabel(content)
- fs.delete("diskName")
- else
- os.setComputerLabel()
- end
- os.pullEvent = oldPullEvent
- for _, device in pairs(peripheral.getNames()) do
- if peripheral.getType(device) == "monitor" then
- local monitor = peripheral.wrap(device)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.setTextScale(1)
- monitor.clear()
- monitor.setCursorPos(1,1)
- end
- end
- os.reboot()
- end
- end
- end
- end
- end
- end
- os.sleep(1)
- end
- ]]
- if fs.exists("startup") then
- if fs.exists("startup_old") then fs.delete("startup_old") end
- fs.move("startup", "startup_old.lua")
- end
- if fs.exists("startup.lua") then
- if fs.exists("startup_old.lua") then fs.delete("startup_old.lua") end
- fs.move("startup.lua", "startup_old.lua")
- end
- if fs.exists("diskName") then
- fs.delete("diskName")
- end
- local h
- local label = os.getComputerLabel()
- if label then
- h = fs.open("diskName", "w")
- h.write(label)
- h.close()
- end
- h = fs.open("startup", "w")
- h.write(startup)
- h.close()
- os.setComputerLabel("Lockdown") -- Makes sure you keep the files
- os.reboot() -- Reboots into lockdown
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement