Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MIT License
- Copyright © 2016 Chickenbreadlp
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- ]]
- local function unfoldkey(keyinput)
- math.randomseed(tonumber(keyinput, 36))
- y = {}
- z = {}
- for i=1, 16 do
- y[i] = math.random(0, 0xFF)
- z[i] = math.random(0, 0xFF)
- end
- math.randomseed(math.random())
- return y, z
- end
- local function encrypt(dir)
- if dir == nil then dir = "" end
- local ListFiles = fs.list(dir)
- for _, file in ipairs(ListFiles) do
- if fs.isDir(dir..file) then
- if file ~= "rom" and file ~= ".syscrypt" and file ~= ".SyscryptShut" then
- encrypt(dir.."/"..file.."/")
- end
- else
- if file == "startup" then
- else
- local prog = fs.open(dir.."/"..file, "rb")
- local progData = {}
- local progbyte = prog.read()
- repeat
- table.insert(progData, progbyte)
- progbyte = prog.read()
- until progbyte == nil
- prog.close()
- progData = ccaes.encrypt_bytestream(progData, y, z)
- local prog = fs.open(dir.."/"..file, "wb")
- for i=1, #progData do
- prog.write(progData[i])
- end
- prog.close()
- sleep(0.01)
- end
- end
- end
- end
- local y = {}
- local z = {}
- if fs.exists("/User/.SyscryptSetup") then
- fs.delete("/User/.SyscryptSetup")
- end
- if fs.exists("/User/.SyscryptShut") then
- fs.delete("/User/.SyscryptShut")
- end
- if syscrypt_alredydecrypt == true then
- shell.run("/.syscrypt/boot")
- elseif fs.exists("/.syscrypt/.reboot") then
- local file = fs.open("/.syscrypt/.reboot", "r")
- syscrypt_keyhash = file.readLine()
- file.close()
- os.loadAPI("/.syscrypt/hash")
- os.loadAPI("/.syscrypt/ccaes")
- local oshut = os.shutdown
- os.shutdown = function()
- fs.delete("/.syscrypt/.reboot")
- if fs.exists("/ReboOSt") and login == true then
- if fs.exists("/User/.SyscryptShut/..meta") then
- fs.delete("/User/.SyscryptShut/..meta")
- end
- fs.makeDir("/User/.SyscryptShut/")
- local file = fs.open("/User/.SyscryptShut/..meta", "w")
- if admin then
- file.writeLine(hash.sha256(UserPass.."admin"))
- else
- file.writeLine(hash.sha256(UserPass.."stand"))
- end
- file.close()
- UserName = ".SyscryptShut"
- end
- y, z = unfoldkey(syscrypt_keyhash)
- encrypt()
- oshut()
- end
- syscrypt_alredydecrypt = true
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("/.syscrypt/boot") then
- shell.run("/.syscrypt/boot")
- else
- shell.run("shell")
- end
- else
- os.loadAPI("/.syscrypt/hash")
- os.loadAPI("/.syscrypt/ccaes")
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- local textXI = (52 - string.len("This Computer has been protected with Syscrypt")) / 2
- local textXV = (52 - string.len("To decrypt, enter in your password below")) / 2
- term.setCursorPos(textXI, 3)
- print("This Computer has been protected with Syscrypt")
- term.setCursorPos(textXV, 4)
- print("To decrypt, enter in your password below")
- while true do
- term.setCursorPos(1,7)
- term.clearLine()
- term.setCursorPos(1,8)
- term.clearLine()
- term.setCursorPos(1,7)
- write("Password: ")
- local oldpe = os.pullEvent()
- os.pullEvent = os.pullEventRaw
- syscrypt_keyhash = hash.sha256(read("*"))
- shell.run("/.syscrypt/reference_key")
- if hash.sha256(syscrypt_keyhash) == syscrypt_key then
- y, z = unfoldkey(syscrypt_keyhash)
- local function decrypt(dir)
- if dir == nil then dir = "" end
- local ListFiles = fs.list(dir)
- for _, file in ipairs(ListFiles) do
- if fs.isDir(dir..file) then
- if file ~= "rom" and file ~= ".syscrypt" then
- term.setTextColor(colors.lime)
- decrypt(dir.."/"..file.."/")
- end
- else
- if file == "startup" then
- else
- local prog = fs.open(dir.."/"..file, "rb")
- local progData = {}
- local progbyte = prog.read()
- repeat
- table.insert(progData, progbyte)
- progbyte = prog.read()
- until progbyte == nil
- prog.close()
- progData = ccaes.decrypt_bytestream(progData, y, z)
- local prog = fs.open(dir.."/"..file, "wb")
- for i=1, #progData do
- prog.write(progData[i])
- end
- prog.close()
- sleep(0.01)
- end
- end
- end
- end
- decrypt()
- local file = fs.open("/.syscrypt/.reboot", "w")
- file.writeLine(syscrypt_keyhash)
- file.close()
- local oshut = os.shutdown
- os.shutdown = function()
- fs.delete("/.syscrypt/.reboot")
- if fs.exists("/ReboOSt") and login == true then
- if fs.exists("/User/.SyscryptShut/..meta") then
- fs.delete("/User/.SyscryptShut/..meta")
- end
- fs.makeDir("/User/.SyscryptShut/")
- local file = fs.open("/User/.SyscryptShut/..meta", "w")
- if admin then
- file.writeLine(hash.sha256(UserPass.."admin"))
- else
- file.writeLine(hash.sha256(UserPass.."stand"))
- end
- file.close()
- UserName = ".SyscryptShut"
- end
- y, z = unfoldkey(syscrypt_keyhash)
- encrypt()
- oshut()
- end
- syscrypt_alredydecrypt = true
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("/.syscrypt/boot") then
- shell.run("/.syscrypt/boot")
- else
- shell.run("shell")
- end
- break
- else
- printError("Wrong Password!")
- sleep(2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement