Advertisement
BlueZero

BlueLock 2.0

Jun 18th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.60 KB | None | 0 0
  1. --[[
  2. Program Title: BlueLock
  3. Version: v2.0
  4. Author: BlueZero
  5. Platform: ComputerCraft
  6. --]]
  7.  
  8. os.pullEvent = os.pullEventRaw
  9. security = true
  10. maxTries = 4
  11. tries = 0
  12.  
  13. function splash()
  14.     shell.run("clear")
  15.     print("\n\n")
  16.     print([[
  17.         __________ .__                  
  18.         \______   \|  |   __ __   ____  
  19.          |    |  _/|  |  |  |  \_/ __ \
  20.          |    |   \|  |__|  |  /\  ___/
  21.          |______  /|____/|____/  \___  >
  22.         .____   \/                __ \/
  23.         |    |     ____    ____  |  | __
  24.         |    |    /  _ \ _/ ___\ |  |/ /
  25.         |    |___(  <_> )\  \___ |    <
  26.         |_______ \\____/  \___  >|__|_ \
  27.                 \/            \/      \/]])
  28.     sleep(2)
  29.     return blueLock()
  30. end
  31.  
  32. function blueLock()
  33.     gateKeeper()
  34.    
  35.     local hashFile = fs.open("bluelock-2.0/misc/hashpw", "r")
  36.     local hashRead = hashFile.readAll()
  37.     hashFile.close()
  38.    
  39.     credits = "be379a30f1aa05d130468f4818fc077ccd2a8b9c972cf5dc901eed1be8587ab8"
  40.     bluezero = "3937018735b580b5ea239c5ff656e7cc710cf8266c60c9caa6d7633d686b44c8"
  41.    
  42.     if userHash == hashRead then
  43.         return passCorrect()
  44.     end
  45.    
  46.     if userHash == credits then
  47.         shell.run("clear")
  48.         print("")
  49.         print([[
  50.     ___  _                 __               _    
  51.    / __\| | _   _   ___   / /   ___    ___ | | __
  52.   /__\//| || | | | / _ \ / /   / _ \  / __|| |/ /
  53.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  54.  \_____/|_| \|                      | \___||_|\_\
  55.     ___  _   |                      |       _    
  56.    / __\| | _|                      |  ___ | | __
  57.   /__\//| || |                      | / __|| |/ /
  58.  / \/  \| || |                      || (__ |   <
  59.  \_____/|_| \|                      | \___||_|\_\
  60.     ___  _   |                      |       _    
  61.    / __\| | _|                      |  ___ | | __
  62.   /__\//| || |                      | / __|| |/ /
  63.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  64.  \_____/|_| \__,_| \___|\____/ \___/  \___||_|\_\
  65.                                                 ]])
  66.         term.setCursorPos(15,7)
  67.         write("     Bluelock 2.0")
  68.         term.setCursorPos(15,9)
  69.         write(" Design & Programming")
  70.         term.setCursorPos(15,10)
  71.         write("       BlueZero")
  72.         term.setCursorPos(15,12)
  73.         write("      Hashbrowns")
  74.         term.setCursorPos(15,13)
  75.         write("     GravityScore")
  76.         sleep(3)
  77.         return blueLock()
  78.     end
  79.    
  80.     if userHash == bluezero then
  81.         print([[
  82. __/\\\___/\\\\\\\\\\\\\_____/\\\_        
  83.  _\/\\\__\/\\\/////////\\\__\/\\\_      
  84.   _\/\\\__\/\\\_______\/\\\__\/\\\_      
  85.    _\///___\/\\\\\\\\\\\\\\___\///__    
  86.     ________\/\\\/////////\\\________    
  87.      __/\\\__\/\\\_______\/\\\___/\\\_  
  88.       _\/\\\__\/\\\_______\/\\\__\/\\\_  
  89.        _\/\\\__\/\\\\\\\\\\\\\/___\/\\\_
  90.         _\///___\/////////////_____\///__
  91.          __/\\\___/\\\\\\\\\\\\\\\___/\\\_        
  92.           _\/\\\__\////////////\\\___\/\\\_      
  93.            _\/\\\____________/\\\/____\/\\\_      
  94.             _\///___________/\\\/______\///__    
  95.              ______________/\\\/______________    
  96.               __/\\\______/\\\/___________/\\\_  
  97.                _\/\\\____/\\\/____________\/\\\_  
  98.                 _\/\\\___/\\\\\\\\\\\\\\\__\/\\\_
  99.                  _\///___\///////////////___\///__]])
  100.         sleep(4)
  101.         return blueLock()
  102.     end
  103.        
  104.     if not (userHash == hashRead) or (userHash == credits) or (userHash == bluezero) then
  105.         if tries == maxTries -1 then
  106.             if security == true then
  107.                 osProtect()
  108.             end
  109.         else
  110.             tries = tries + 1
  111.             shell.run("clear")
  112.             print("")
  113.             print([[
  114.     ___  _                 __               _    
  115.    / __\| | _   _   ___   / /   ___    ___ | | __
  116.   /__\//| || | | | / _ \ / /   / _ \  / __|| |/ /
  117.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  118.  \_____/|_| \|                      | \___||_|\_\
  119.     ___  _   |                      |       _    
  120.    / __\| | _|                      |  ___ | | __
  121.   /__\//| || |                      | / __|| |/ /
  122.  / \/  \| || |                      || (__ |   <
  123.  \_____/|_| \|                      | \___||_|\_\
  124.     ___  _   |                      |       _    
  125.    / __\| | _|                      |  ___ | | __
  126.   /__\//| || |                      | / __|| |/ /
  127.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  128.  \_____/|_| \__,_| \___|\____/ \___/  \___||_|\_\
  129.                                                 ]])
  130.            
  131.             term.setCursorPos(15,8)
  132.             write("Incorrect Option")
  133.             term.setCursorPos(15,9)
  134.             write("or Password.")
  135.             term.setCursorPos(15,11)
  136.             write("Tries left: "..maxTries - tries)
  137.             sleep(2)
  138.             return blueLock()
  139.         end
  140.     end
  141. end
  142.  
  143. function gateKeeper()
  144.     shell.run("clear")
  145.     os.loadAPI("bluelock-2.0/apis/hash")
  146.     print("")
  147.     print([[
  148.     ___  _                 __               _    
  149.    / __\| | _   _   ___   / /   ___    ___ | | __
  150.   /__\//| || | | | / _ \ / /   / _ \  / __|| |/ /
  151.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  152.  \_____/|_| \|                      | \___||_|\_\
  153.     ___  _   |                      |       _    
  154.    / __\| | _|                      |  ___ | | __
  155.   /__\//| || |                      | / __|| |/ /
  156.  / \/  \| || |                      || (__ |   <
  157.  \_____/|_| \|                      | \___||_|\_\
  158.     ___  _   |                      |       _    
  159.    / __\| | _|                      |  ___ | | __
  160.   /__\//| || |                      | / __|| |/ /
  161.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  162.  \_____/|_| \__,_| \___|\____/ \___/  \___||_|\_\
  163.                                                 ]])
  164.     term.setCursorPos(15,7)
  165.     write("Bluelock 2.0 running ")
  166.     term.setCursorPos(15,8)
  167.     write("on computer: "..os.getComputerID())
  168.     term.setCursorPos(15,9)
  169.     write("OS: "..os.version())
  170.     term.setCursorPos(15,10)
  171.     write("To view credits")
  172.     term.setCursorPos(15,11)
  173.     write("type \"credits\".")
  174.     term.setCursorPos(15,13)
  175.     write("Password: ")
  176.     input = io.read()
  177.     userHash = hash.sha256(input)
  178.     shell.run("clear")
  179. end
  180.  
  181. function osProtect()
  182.     shell.run("clear")
  183.     print("")
  184.     print([[
  185.     ___  _                 __               _    
  186.    / __\| | _   _   ___   / /   ___    ___ | | __
  187.   /__\//| || | | | / _ \ / /   / _ \  / __|| |/ /
  188.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  189.  \_____/|_| \|                      | \___||_|\_\
  190.     ___  _   |                      |       _    
  191.    / __\| | _|                      |  ___ | | __
  192.   /__\//| || |                      | / __|| |/ /
  193.  / \/  \| || |                      || (__ |   <
  194.  \_____/|_| \|                      | \___||_|\_\
  195.     ___  _   |                      |       _    
  196.    / __\| | _|                      |  ___ | | __
  197.   /__\//| || |                      | / __|| |/ /
  198.  / \/  \| || |_| ||  __// /___| (_) || (__ |   <
  199.  \_____/|_| \__,_| \___|\____/ \___/  \___||_|\_\
  200.                                                 ]])
  201.     term.setCursorPos(15,8)
  202.     textutils.slowWrite("Too many failed", 50)
  203.     term.setCursorPos(15,9)
  204.     textutils.slowWrite("attempts.", 50)
  205.     sleep(2)
  206.     term.setCursorPos(15,11)
  207.     textutils.slowWrite("Good try, dumbass.", 50)
  208.     sleep(0.5)
  209.     os.shutdown()
  210. end
  211.  
  212. function passCorrect()
  213.     shell.run("clear")
  214.     print("\n\n")
  215.     print([[
  216.     _____                                    _
  217.    |  __ \                                  | |
  218.    | |__) |_ _ ___ _____      _____  _ __ __| |
  219.    |  ___/ _  / __/ __\ \ /\ / / _ \| '__/ _  |
  220.   | |  | (_| \__ \__ \\ V  V / (_) | | | (_| |
  221.   |_|   \__,_|___/___/ \_/\_/ \___/|_|  \__,_|
  222.       /\                     | |         | |  
  223.      /  \   ___ ___ ___ _ __ | |_ ___  __| |  
  224.     / /\ \ / __/ __/ _ \ '_ \| __/ _ \/ _  |  
  225.     / ____ \ (_| (_|  __/ |_) | ||  __/ (_| |  
  226.    /_/    \_\___\___\___| .__/ \__\___|\__,_|  
  227.                         | |                    
  228.                         |_|                    ]])
  229.     sleep(2)
  230.     shell.run("clear")
  231.     error()
  232. end
  233.  
  234. function newCheck()
  235.     shell.run("clear")
  236.    
  237.     if fs.exists("startup") then
  238.         local rf = fs.open("startup", "r")
  239.         local ef = fs.open("startup", "a")
  240.         lines = rf.readAll()
  241.         rf.close()
  242.        
  243.         while lines do
  244.             if lines and string.find(lines, 'shell.run("bluelock-2.0/bluelock")', 1, true) then
  245.                 return install()               
  246.             else
  247.                 print("Preparing for first time run.")
  248.                 sleep(1)
  249.                 print("\nStartup File Detected. Adding BlueLock to startup file.\n\nNote: If you have a custom sequence for your startup file BlueLock has been added to the end of the file.\n\nBe sure to place BlueLock's startup opperation in a more appropriate spot in your file.")
  250.                 ef.write([[shell.run("bluelock-2.0/bluelock")]].."\n")
  251.                 ef.close()
  252.                 sleep(10)
  253.                 return install()
  254.             end
  255.         end
  256.        
  257.     elseif not fs.exists("startup") then
  258.         local ef = fs.open("startup", "a")
  259.         print("Preparing for first time run.\n")
  260.         sleep(1)
  261.         print("Startup File Not Detected, creating Startup File.")
  262.         ef.write([[shell.run("bluelock-2.0/bluelock")]])
  263.         ef.close()
  264.         sleep(3)
  265.         return install()
  266.     end
  267. end
  268.  
  269. function install()
  270.    
  271.     if fs.exists("bluelock") then
  272.         shell.run("clear")
  273.         write("Installing BlueLock.\n")
  274.         sleep(1)
  275.         write("Creating BlueLock Directory... ")
  276.         fs.makeDir("bluelock-2.0")
  277.         sleep(0.5)
  278.         write("Done\n")
  279.         sleep(0.5)
  280.         write("Creating API Directory... ")
  281.         fs.makeDir("bluelock-2.0/apis")
  282.         sleep(0.5)
  283.         write("Done.\n")
  284.         sleep(0.5)
  285.         write("Creating Data Storage... ")
  286.         fs.makeDir("bluelock-2.0/misc")
  287.         sleep(0.5)
  288.         write("Done.\n")
  289.         sleep(0.5)
  290.         write("Moving BlueLock to BlueLock Directory... ")
  291.         fs.move("bluelock", "bluelock-2.0/bluelock")
  292.         sleep(0.5)
  293.         write("Done.\n")
  294.         sleep(0.5)
  295.         write("Downloading API.\n")
  296.         sleep(0.5)
  297.         local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("TDYrY85F"))
  298.        
  299.         if response then
  300.             sleep(0.5)
  301.             print("API Downloaded, Writing File.")
  302.            
  303.             local gotCode = response.readAll()
  304.             response.close()
  305.            
  306.             local hashFile = fs.open("hash", "w")
  307.             hashFile.write(gotCode)
  308.             hashFile.close()
  309.             sleep(0.5)
  310.             print("File Written Successfully.")
  311.         else
  312.             error("Could not download API.")
  313.         end
  314.         sleep(0.5)
  315.         write("Moving API to API Directory... ")
  316.         fs.move("hash", "bluelock-2.0/apis/hash")
  317.         sleep(0.5)
  318.         write("Done.\n")
  319.         sleep(0.5)
  320.         write("Downloading Misc Tools.\n")
  321.         sleep(0.5)
  322.         local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("D8ssqvAn"))
  323.        
  324.         if response then
  325.             sleep(0.5)
  326.             print("Tools downloaded, Writing File.")
  327.            
  328.             local gotCode = response.readAll()
  329.             response.close()
  330.            
  331.             local hashFile = fs.open("passchange", "w")
  332.             hashFile.write(gotCode)
  333.             hashFile.close()
  334.             sleep(0.5)
  335.             print("File Written Successfully.")
  336.         else
  337.             error("Could not download Misc Tools.")
  338.         end
  339.         sleep(0.5)
  340.         write("Moving Tools to Main Directory... ")
  341.         fs.move("passchange", "bluelock-2.0/misc/passchange")
  342.         sleep(0.5)
  343.         write("Done.\n")
  344.         sleep(2)
  345.         return createPassword()
  346.     else
  347.         return splash()
  348.     end
  349. end
  350.  
  351. function createPassword()
  352.  
  353.     if not fs.exists("bluelock-2.0/misc/hashpw") then
  354.    
  355.         local hash1 = ""
  356.         local hash2 = ""
  357.         os.loadAPI("bluelock-2.0/apis/hash")
  358.         sleep(2)
  359.         shell.run("clear")
  360.         print("Please enter your password.\n\nBe careful! Password is Case Sensitive!\n")
  361.         write("Password: ")
  362.         userInput = io.read()
  363.         hash1 = hash.sha256(userInput)
  364.         shell.run("clear")
  365.         print("Please enter your password again.\n")
  366.         write("Password: ")
  367.         userInput = io.read()
  368.         hash2 = hash.sha256(userInput)
  369.         shell.run("clear")
  370.    
  371.         if hash1 == hash2 then
  372.             local hFile = fs.open("bluelock-2.0/misc/hashpw", "w")
  373.             hFile.write(hash1)
  374.             hFile.close()
  375.             return splash()
  376.         else
  377.             print("Passwords don't match, please try again.")
  378.             fs.delete("bluelock-2.0/misc/hashpw")
  379.             return createPassword()
  380.         end
  381.     else
  382.         return splash()
  383.     end
  384. end
  385.        
  386. newCheck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement