Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI('/.apis/sha')
- local passHashHandle = fs.open('/SecuritySystem/.passhash','r')
- local passHash = passHashHandle.readAll()
- passHashHandle.close()
- local w,h = term.getSize()
- local logo = paintutils.loadImage("/SecuritySystem/logo")
- local logoFile = fs.open("/SecuritySystem/logo",'r')
- local lines = {}
- for i in string.gmatch(logoFile.readAll(),"[^\n]+") do table.insert(lines, i) end
- local imgWidth = 0
- for i=1,#lines do if lines[i]:len()>imgWidth then imgWidth = lines[i]:len() end end
- local imgHeight = #lines
- logoFile.close()
- function getPass()
- local inTerm = window.create(term.current(),w/2-6,h/2,13,1,true)
- local oldTerm = term.redirect(inTerm)
- term.setBackgroundColor(2^7)
- term.write(" ")
- term.setCursorPos(1,1)
- local _,out = pcall(read,"*")
- term.redirect(oldTerm)
- term.clear()
- term.setCursorPos(1,1)
- return out
- end
- term.clear()
- if h > (imgHeight+4) then
- paintutils.drawImage(logo,math.ceil((w-imgWidth)/2),4)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(math.ceil((w-string.len(os.version()))/2),1)
- print(os.version())
- term.setCursorPos(math.ceil((w-7)/2),2)
- print("Loading")
- else
- term.setCursorPos(math.ceil((w-string.len(os.version()))/2),h/2-1)
- print(os.version())
- term.setCursorPos(math.ceil((w-7)/2),h/2+1)
- print("Loading")
- end
- pcall(sleep,3)
- term.clear()
- while true do
- term.setCursorPos(math.ceil((w-15)/2),h/2-2)
- term.write("Enter Password:")
- local input = getPass()
- term.setBackgroundColor(colors.black)
- if sha.sha256(input) == passHash then
- term.setCursorPos(math.ceil((w-8)/2),h/2)
- term.write("Correct!")
- pcall(sleep,2)
- break
- else
- term.setCursorPos(math.ceil((w-10)/2),h/2)
- term.write("Incorrect!")
- pcall(sleep,2)
- end
- end
- os.unloadAPI("/.apis/sha")
- term.clear()
- term.setCursorPos(1,1)
- local version
- local webH = http.get("http://pastebin.com/raw.php?i=1PM7BAGH")
- if webH then version = webH.readAll() end
- webH.close()
- if version~="3" then
- print("SecuritySystem appears to be outdated. Do you wish to update? [Y/N] ")
- local _,key = os.pullEvent("key")
- sleep(0)
- if key==21 then
- shell.run("pastebin run E5VeZu7G")
- end
- end
- if fs.exists("/SecuritySystem/startup") then
- shell.run("/SecuritySystem/startup")
- else
- if term.isColor() then term.setTextColor(colors.yellow) end
- print(os.version())
- end
Advertisement
Add Comment
Please, Sign In to add comment