AndreSoYeah

installer

Nov 22nd, 2014
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. --# WaliLogin by Andre A. Walia (walia6)
  2. --# liscensed under CreativeCommons Attribution.
  3. --# You may distribute,remix, tweak, and build
  4. --# upon my work, even commercially, as long as
  5. --# you credit me by my First, middle initial, and last name.
  6. characters = {'a','b','c','d','e','f','1','2','3','4','5','6','7','8','9','0'}
  7. function genSalt()
  8.     toReturn=''
  9.     for xx=1,64 do
  10.         toReturn=toReturn..characters[math.random(1,#characters)]
  11.     end
  12.     return toReturn
  13. end
  14. local codes = {
  15.   ["APIS/walCrypt"] = "efeJSTH9",
  16.   ["APIS/sha256"] = "tBStqhvU",
  17.   ["startup"] = "kNJ6sFHd",
  18.   ["addUser"] = "1Tf3CjWS",
  19.   [".shell"] = "WrH70miG"
  20. }
  21. re = http.get("http://www.pastebin.com/raw.php?i=GQ1JmtNq").readLine()
  22. local function get(name,code)
  23.   if code then
  24.     local r=http.get("http://www.pastebin.com/raw.php?i="..code)
  25.     if fs.exists(name) then
  26.       error(name.." already exists")
  27.     end
  28.     local cont = {}
  29.     a = r.readAll()
  30.     local prog = fs.open(name,"w")
  31.     prog.writeLine(a)
  32.     prog.flush()
  33.     prog.close()
  34.     return true
  35.   else
  36.     error("No code?")
  37.     return false
  38.   end
  39. end
  40. print()
  41. print("Would you like to install walia6's login? y/n")
  42. local a = true
  43. while a do
  44.   event,char = os.pullEvent("char")
  45.   if string.upper(char) == "N" or string.upper(char) == "Y" then
  46.     k=string.upper(char)
  47.     a=false
  48.   end
  49. end
  50. if k == "Y" then
  51.   for k,v in pairs(codes) do
  52.     if fs.exists(k) then
  53.       fs.delete(k)
  54.     end
  55.     get(k,v)
  56.   end
  57.  
  58.   --get("walCrypt",codes["walCrypt"])
  59.   --get("startup",codes["startup"])
  60.   os.loadAPI("APIS/sha256")
  61.   print()
  62.   write("Username: ")
  63.   user = read()
  64.   while true do
  65.     print()
  66.     write("Password: ")
  67.     pass = read("*")
  68.     write("Enter password again: ")
  69.     if read("*") == pass then
  70.       if fs.exists("loginSettings") then
  71.         fs.delete("loginSettings")
  72.       end
  73.       shell.run("mkdir loginSettings")
  74.       if fs.exists("loginSettings/version") then
  75.         fs.delete("loginSettings/version")
  76.       end
  77.       ff=fs.open("loginSettings/version","w")
  78.       ff.writeLine(re)
  79.       ff.flush()
  80.       ff.close()
  81.       info={}
  82.       info[user] = {}
  83.       info[user]['salt'] = genSalt()
  84.       info[user]['hash'] = sha256.sha256(pass..(info[user]['salt']))
  85.       infoFile=fs.open('accounts','w')
  86.       infoFile.writeLine(textutils.serialize(info))
  87.       infoFile.close()
  88.       info=nil
  89.       break
  90.     else
  91.       print("password do not match")
  92.     end
  93.   end
  94.   os.reboot()
  95. end
Advertisement
Add Comment
Please, Sign In to add comment