Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fold OS Boot
- -- Secure the OS
- --os.pullEvent = os.pullEventRaw
- settings.set("shell.allow_disk_startup", false)
- settings.save(".settings")
- local dir = ""
- local ts = term.setCursorPos
- local tc = term.clear
- local tw = term.write
- local tb = term.setBackgroundColor
- local ttc = term.setTextColor
- -- Add ons from pastebin
- local Malte_encrypt = "4rcQd7LC"
- local Fold_desktop = "THjECK1U"
- local Crypto = "cEHfermh"
- local Fold_FileManager = "PKptLR02"
- ------------
- -- Install add ons
- if fs.exists( "/encrypt" ) then
- os.loadAPI( "/encrypt")
- else
- tc()
- ts(1,1)
- tb(colors.black)
- ttc(colors.white)
- tw("Installing: Malte_Encrypt")
- sleep(1)
- ts(1,3)
- shell.run("pastebin get "..Malte_encrypt.." encrypt")
- os.loadAPI( "/encrypt")
- end
- if fs.exists( "/crypto" ) then
- os.loadAPI( "/crypto")
- else
- tc()
- ts(1,1)
- tb(colors.black)
- ttc(colors.white)
- tw("Installing: Crypto")
- sleep(1)
- ts(1,3)
- shell.run("pastebin get "..Crypto.." crypto")
- os.loadAPI( "/crypto")
- end
- os.loadAPI( "/desktop")
- if fs.exists( "/desktop" ) then
- os.loadAPI( "/desktop")
- else
- tc()
- ts(1,1)
- tb(colors.black)
- ttc(colors.white)
- tw("Installing: FoldOS Desktop")
- sleep(1)
- ts(1,3)
- shell.run("pastebin get "..Fold_desktop.." desktop")
- os.loadAPI( "/desktop")
- end
- if fs.exists( "/FileManager" ) then
- os.loadAPI( "/FileManager")
- else
- tc()
- ts(1,1)
- tb(colors.black)
- ttc(colors.white)
- tw("Installing: FoldOS FileManager")
- sleep(1)
- ts(1,3)
- shell.run("pastebin get "..Fold_FileManager.." FileManager")
- end
- ---------------------
- local Booting = true
- local start = {}
- start["register"] = {}
- start["register"]["x1"] = 3
- start["register"]["x2"] = 49
- start["register"]["y1"] = 3
- start["register"]["y2"] = 17
- start["register"]["color"] = colors.white
- start["noUsr"] = {}
- start["noUsr"]["text"] = "Would you like to create a profile?"
- start["noUsr"]["len"] = start["noUsr"]["text"]:len()
- start["noUsr"]["x"] = ( ( start["register"]["x2"] - start["register"]["x1"] ) / 2 ) - ( start["noUsr"]["len"] / 2 ) +4
- start["noUsr"]["y"] = 4
- start["noUsr"]["color"] = colors.white
- start["box"] = {}
- start["box"]["color"] = colors.black
- start["box"]["x1"] = start["noUsr"]["x"]-1
- start["box"]["y1"] = start["noUsr"]["y"]-1
- start["box"]["x2"] = start["noUsr"]["x"] + start["noUsr"]["len"]
- start["box"]["y2"] = start["noUsr"]["y"]+1
- ----------------
- start["create"] = {}
- start["create"]["text"] = "Create a profile"
- start["create"]["len"] = start["create"]["text"]:len()
- start["create"]["x"] = ( ( start["register"]["x2"] - start["register"]["x1"] ) / 2 ) - ( start["create"]["len"] / 2 ) +4
- start["create"]["y"] = 4
- start["create"]["color"] = colors.white
- start["login"] = {}
- start["login"]["text"] = "Login"
- start["login"]["len"] = start["login"]["text"]:len()
- start["login"]["x"] = ( ( start["register"]["x2"] - start["register"]["x1"] ) / 2 ) - ( start["login"]["len"] / 2 ) +4
- start["login"]["y"] = 4
- start["login"]["color"] = colors.white
- start["box2"] = {}
- start["box2"]["color"] = colors.black
- start["box2"]["x1"] = start["create"]["x"]-1
- start["box2"]["y1"] = start["create"]["y"]-1
- start["box2"]["x2"] = start["create"]["x"] + start["create"]["len"]
- start["box2"]["y2"] = start["create"]["y"]+1
- start["box3"] = {}
- start["box3"]["color"] = colors.black
- start["box3"]["x1"] = start["login"]["x"]-1
- start["box3"]["y1"] = start["login"]["y"]-1
- start["box3"]["x2"] = start["login"]["x"] + start["login"]["len"]
- start["box3"]["y2"] = start["login"]["y"]+1
- ----------------
- start["yes"] = {}
- start["yes"]["text"] = "Yes"
- start["yes"]["len"] = start["yes"]["text"]:len()
- start["yes"]["x1"] = 50 / 2 - start["yes"]["len"]
- start["yes"]["y1"] = 8
- start["yes"]["x2"] = 50 / 2 + start["yes"]["len"]
- start["yes"]["y2"] = start["yes"]["y1"] + 2
- start["yes"]["color"] = colors.green
- start["yes"]["pressed"] = false
- start["no"] = {}
- start["no"]["text"] = "No, uninstall"
- start["no"]["len"] = start["no"]["text"]:len()
- start["no"]["x1"] = 50 / 2 - start["no"]["len"]
- start["no"]["y1"] = 13
- start["no"]["x2"] = 50 / 2 + start["no"]["len"]
- start["no"]["y2"] = start["no"]["y1"] + 2
- start["no"]["color"] = colors.red
- start["no"]["pressed"] = false
- start["username"] = {}
- start["username"]["text"] = " Username:"
- start["username"]["len"] = start["username"]["text"]:len()
- start["username"]["x1"] = start["register"]["x1"] + 1
- start["username"]["y1"] = start["register"]["y1"] + 4
- start["username"]["x2"] = start["username"]["text"]:len() + start["username"]["x1"]
- start["username"]["y2"] = start["username"]["y1"] + 2
- start["username"]["color"] = colors.black
- start["password"] = {}
- start["password"]["text"] = " Password:"
- start["password"]["len"] = start["password"]["text"]:len()
- start["password"]["x1"] = start["register"]["x1"] + 1
- start["password"]["y1"] = start["register"]["y1"] + 8
- start["password"]["x2"] = start["password"]["text"]:len() + start["password"]["x1"]
- start["password"]["y2"] = start["password"]["y1"] + 2
- start["password"]["color"] = colors.black
- start["input1"] = {}
- start["input1"]["add"] = 12
- start["input1"]["x1"] = start["username"]["x1"] + start["input1"]["add"]
- start["input1"]["y1"] = start["username"]["y1"]
- start["input1"]["x2"] = start["input1"]["add"] + start["username"]["x2"] + 22
- start["input1"]["y2"] = start["username"]["y2"]
- start["input1"]["color"] = colors.black
- start["input2"] = {}
- start["input2"]["add"] = 12
- start["input2"]["x1"] = start["password"]["x1"] + start["input1"]["add"]
- start["input2"]["y1"] = start["password"]["y1"]
- start["input2"]["x2"] = start["input2"]["add"] + start["password"]["x2"] + 22
- start["input2"]["y2"] = start["password"]["y2"]
- start["input2"]["color"] = colors.black
- local waittime = 0.07
- local psw = {}
- function create() -- Creates a profile
- paintutils.drawFilledBox(start["register"]["x1"], start["register"]["y1"], start["register"]["x2"], start["register"]["y2"], start["register"]["color"])
- paintutils.drawFilledBox(start["box2"]["x1"], start["box2"]["y1"], start["box2"]["x2"], start["box2"]["y2"], start["box2"]["color"] )
- ts(start["create"]["x"], start["create"]["y"])
- ttc(start["create"]["color"])
- tw(start["create"]["text"])
- --------------- Make a name and password field
- paintutils.drawFilledBox(start["username"]["x1"], start["username"]["y1"], start["username"]["x2"], start["username"]["y2"], start["username"]["color"] )
- ts(start["username"]["x1"], start["username"]["y1"]+1)
- tw(start["username"]["text"])
- paintutils.drawFilledBox(start["password"]["x1"], start["password"]["y1"], start["password"]["x2"], start["password"]["y2"], start["password"]["color"] )
- ts(start["password"]["x1"], start["password"]["y1"]+1)
- tw(start["password"]["text"])
- paintutils.drawFilledBox(start["input1"]["x1"], start["input1"]["y1"], start["input1"]["x2"] , start["input1"]["y2"], start["input1"]["color"])
- paintutils.drawFilledBox(start["input2"]["x1"], start["input2"]["y1"], start["input2"]["x2"] , start["input2"]["y2"], start["input2"]["color"])
- ts(start["input1"]["x1"] + 1, start["input1"]["y1"] + 1)
- local iUser = read()
- ts(start["input2"]["x1"] + 1, start["input2"]["y1"] + 1)
- local iPsw = read()
- local userDir = fs.makeDir( dir.."/user" )
- local file = fs.open( dir.."/user/username", "w")
- file.writeLine(iUser)
- file.close()
- local file = fs.open( "/user/password", "w")
- iPsw = crypto.toBinary(iPsw)
- iPsw = encrypt.encrypt(iPsw, "key") -- Encrypt's the string using Malte's encrypting software
- if iPsw == nil or iPsw == "" then
- uninstall()
- else
- file.writeLine(iPsw)
- file.close()
- end
- os.reboot()
- end
- function drawYes(var)
- local old = start["yes"]["color"]
- if var then
- start["yes"]["color"] = colors.black
- end
- paintutils.drawFilledBox(start["yes"]["x1"], start["yes"]["y1"], start["yes"]["x2"], start["yes"]["y2"], start["yes"]["color"])
- ts(start["yes"]["x1"] + start["yes"]["len"] / 2 + 1, start["yes"]["y1"] +1)
- tw(start["yes"]["text"])
- start["yes"]["color"] = old
- end
- function drawNo(var)
- local old = start["no"]["color"]
- if var then
- start["no"]["color"] = colors.black
- end
- paintutils.drawFilledBox(start["no"]["x1"], start["no"]["y1"], start["no"]["x2"], start["no"]["y2"], start["no"]["color"])
- ts(start["no"]["x1"] + start["no"]["len"] / 2 + 1, start["no"]["y1"] +1)
- tw(start["no"]["text"])
- start["no"]["color"] = old
- end
- function uninstall()
- fs.delete( "/user")
- fs.delete( "/encrypt")
- fs.delete( "/desktop")
- fs.delete( "/startup")
- fs.delete( "/files" )
- fs.delete( "/filesystem" )
- os.reboot()
- end
- function login()
- tb(colors.blue)
- tc()
- paintutils.drawFilledBox(start["register"]["x1"], start["register"]["y1"], start["register"]["x2"], start["register"]["y2"], start["register"]["color"])
- paintutils.drawFilledBox(start["box3"]["x1"], start["box3"]["y1"], start["box3"]["x2"], start["box3"]["y2"], start["box3"]["color"] )
- ts(start["login"]["x"], start["login"]["y"])
- ttc(start["login"]["color"])
- tw(start["login"]["text"])
- paintutils.drawFilledBox(start["username"]["x1"], start["username"]["y1"], start["username"]["x2"], start["username"]["y2"], start["username"]["color"] )
- ts(start["username"]["x1"], start["username"]["y1"]+1)
- tw(start["username"]["text"])
- paintutils.drawFilledBox(start["password"]["x1"], start["password"]["y1"], start["password"]["x2"], start["password"]["y2"], start["password"]["color"] )
- ts(start["password"]["x1"], start["password"]["y1"]+1)
- tw(start["password"]["text"])
- paintutils.drawFilledBox(start["input1"]["x1"], start["input1"]["y1"], start["input1"]["x2"] , start["input1"]["y2"], start["input1"]["color"])
- paintutils.drawFilledBox(start["input2"]["x1"], start["input2"]["y1"], start["input2"]["x2"] , start["input2"]["y2"], start["input2"]["color"])
- ts(start["input1"]["x1"] + 1, start["input1"]["y1"] + 1)
- local iUser = read()
- ts(start["input2"]["x1"] + 1, start["input2"]["y1"] + 1)
- local iPsw = read("*")
- local file = fs.open("/user/username", "r")
- local realUsr = file.readLine()
- file.close()
- local file = fs.open("/user/password", "r")
- local realPsw = file.readLine()
- file.close()
- realPsw = encrypt.decrypt(realPsw, "key") -- Decrypt's the string using Malte's encrypting software
- realPsw = crypto.fromBinary(realPsw)
- if iUser == realUsr and iPsw == realPsw then
- -- Logged succesfully in!
- desktop.launch()
- else
- login()
- end
- end
- function boot()
- if start["yes"]["pressed"] then
- Booting = false
- end
- if start["no"]["pressed"] then
- Booting = false
- end
- ts(1,2)
- tb(colors.blue)
- tc()
- local file = fs.exists("/user")
- if file and Booting then
- login()
- Booting = false
- else
- paintutils.drawFilledBox(start["register"]["x1"], start["register"]["y1"], start["register"]["x2"], start["register"]["y2"], start["register"]["color"])
- paintutils.drawFilledBox(start["box"]["x1"], start["box"]["y1"], start["box"]["x2"], start["box"]["y2"], start["box"]["color"] )
- ts(start["noUsr"]["x"], start["noUsr"]["y"])
- ttc(start["noUsr"]["color"])
- tw(start["noUsr"]["text"])
- ts(1,1)
- drawYes()
- drawNo()
- ts(1,1)
- end
- if Booting then
- if file then
- else
- local event, button, x, y = os.pullEvent( "mouse_click" )
- if x >= start["yes"]["x1"] and x <= start["yes"]["x2"] and y >= start["yes"]["y1"] and y <= start["yes"]["y2"] then
- drawYes(true)
- start["yes"]["pressed"] = true
- elseif x >= start["no"]["x1"] and x <= start["no"]["x2"] and y >= start["no"]["y1"] and y <= start["no"]["y2"] then
- drawNo(true)
- start["no"]["pressed"] = true
- elseif x == 1 and y == 1 then
- os.reboot()
- end
- sleep(waittime)
- boot()
- end
- else
- if start["yes"]["pressed"] then
- start["yes"]["pressed"] = false
- Booting = false
- create()
- end
- if start["no"]["pressed"] then
- start["no"]["pressed"] = false
- Booting = false
- uninstall()
- end
- end
- end
- boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement