Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# WaliLogin by Andre A. Walia (walia6)
- --# liscensed under CreativeCommons Attribution.
- --# You may distribute,remix, tweak, and build
- --# upon my work, even commercially, as long as
- --# you credit me by my First, middle initial, and last name.
- old=os.pullEvent
- infoFile=fs.open('accounts','r')
- info=textutils.unserialize(infoFile.readAll())
- infoFile.close()
- bgColor=colors.lightGray -- change this to any color you want
- wait=1.5
- os.pullEvent=os.pullEventRaw
- os.loadAPI("APIS/walCrypt")
- os.loadAPI("APIS/sha256")
- response = http.get("http://www.pastebin.com/raw.php?i=GQ1JmtNq").readAll()
- function invalid(txt,st,col)
- term.setCursorPos(1,1)
- term.setTextColor(col)
- term.setBackgroundColor(colors.blue)
- sX,sY=term.getSize()
- for u=1,sX do
- write(" ")
- end
- term.setCursorPos(st,1)
- write(txt)
- term.setTextColor(colors.black)
- end
- function updateScreen()
- term.setBackgroundColor(bgColor)
- term.clear()
- --term.setCursorPos(1,1)
- --term.setBackgroundColor(colors.blue)
- --sX,sY=term.getSize()
- --for co=1,sX do
- --write(" ")
- --end
- invalid("Auto-Updater",20,colors.red)
- term.setCursorPos(6,7)
- term.setTextColor(colors.black)
- term.setBackgroundColor(bgColor)
- write("Would you like to update Walia6's Login?")
- --sleep(1)
- term.setCursorPos(11,9)
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.black)
- write("Okay")
- term.setCursorPos(17,9)
- term.setBackgroundColor(colors.blue)
- write("Don't ask me again")
- term.setCursorPos(37,9)
- term.setBackgroundColor(colors.red)
- write("Nope")
- while true do
- _,b,x,y=os.pullEvent("mouse_click")
- if b==1 then
- if y==9 then
- if x>10 and x<15 then
- if fs.exists("loginSettings/version") then
- hh=fs.open("loginSettings/version","r")
- version = tonumber(hh.readLine())
- hh.close()
- else
- version = 0
- end
- if tonumber(response) > version then
- re=http.get("http://www.pastebin.com/raw.php?i=fJxygMPi").readAll()
- if fs.exists("update") then
- fs.delete("update")
- end
- hhg=fs.open("update","w")
- hhg.writeLine(re)
- hhg.flush()
- hhg.close()
- term.setTextColor(colors.black)
- term.setBackgroundColor(bgColor)
- term.clear()
- invalid("Notice",23,colors.black)
- term.setCursorPos(9,9)
- term.setTextColor(colors.black)
- term.setBackgroundColor(cgColor)
- write("Please run update after logging in.")
- sleep(3)
- break
- end
- elseif x>16 and x<35 then
- gg=fs.open("loginSettings/noUpdate","w")
- gg.writeLine(" ")
- gg.flush()
- gg.close()
- break
- elseif x>36 and x<41 then
- break
- end
- end
- end
- end
- sleep(3)
- end
- function main()
- if fs.exists("loginSettings/version") then
- yy=fs.open("loginSettings/version","r")
- vee=yy.readLine()
- yy.close()
- if tonumber(vee) ~= tonumber(response) then
- if not fs.exists("loginSettings/noUpdate") then
- updateScreen()
- end
- end
- else
- if not fs.exists("loginSettings/noUpdate") then
- updateScreen()
- end
- end
- d=true
- while d do
- term.setBackgroundColor(bgColor)
- term.clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- sX,sY=term.getSize()
- for i=1,sX*2 do
- write(" ")
- end
- term.setCursorPos(19,1)
- term.setTextColor(colors.black)
- print("Please login: ")
- term.setBackgroundColor(bgColor)
- term.setCursorPos(15,9)
- term.setTextColor(colors.blue)
- write("Username: ")
- term.setBackgroundColor(colors.gray)
- write(" ")
- term.setCursorPos(15,11)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(bgColor)
- write("Password: ")
- term.setBackgroundColor(colors.gray)
- write(" ")
- term.setCursorPos(26,9)
- term.setTextColor(colors.cyan)
- inUser = read()
- term.setCursorPos(26,11)
- inPass = read("*")
- if info[inUser] then
- if info[inUser]['hash'] == sha256.sha256(inPass..info[inUser]['salt']) then
- d=false
- else
- invalid("Invalid login",19,colors.red)
- sleep(wait)
- end
- else
- invalid("Invalid login",19,colors.red)
- sleep(wait)
- end
- end
- invalid("Valid login",20,colors.green)
- sleep(wait)
- os.pullEvent = old
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- curUser=inUser
- us=fs.open("loginSettings/curUser","w")
- us.writeLine(curUser)
- us.flush()
- us.close()
- for k,v in pairs(fs.list('APIS/')) do
- os.loadAPI('APIS/'..v)
- end
- shell.run(".shell")
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment