Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Lists
- local BlackList = {}
- local WhiteList = {}
- --Securety Functions
- local FS_oldOpen = fs.open
- local FS_oldDelete = fs.delete
- local FS_oldCopy = fs.copy
- local FS_oldMove = fs.move
- local FS_oldMakeDir = fs.makeDir
- local IO_oldOpen = io.open
- local OS_oldLoadApit = os.loadAPI
- local OS_oldUnloadApi = os.unloadAPI
- local OS_oldShutdown = os.shutdown
- local OS_oldReboot = os.reboot
- local OS_oldSleep = os.sleep
- local OS_oldRun = os.run
- --local SHELL_oldSetDir = shell.setDir
- local SHELL_oldSetAlias = shell.setAlias
- local SHELL_oldClearAlias = shell.clearAlias
- local SHELL_oldRun = shell.run
- local SHELL_oldExit = shell.exit
- fs.open = function(file, mode)
- programName = shell.getRunningProgram()
- slc, saveslc = drawWarningScreen("Securety Break!", programName, "fs.open()")
- if slc == 0 then -- Allow
- if saveslc == true then --Save
- addWhitelist(programName)
- end
- FS_oldOpen(file,mode)
- else -- Deny
- if saveslc == true then--Save
- addBlacklist(programName)
- end
- end
- end
- fs.delete = function(file)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- fs.copy = function(file1, file2)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- fs.move = function(file1, file2)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- fs.makeDir = function(dir)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- io.open = function(file, mode)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.loadAPI = function(file)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.unloadAPI = function(file)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.shutdown = function()
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.reboot = function()
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.sleep = function(sec)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- os.run = function(_sCommand, ...)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- shell.setDir = function(dir)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- shell.setAlias = function(file, name)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- shell.clearAlias = function()
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- shell.run = function(_sCommand, ...)
- noResponse = true
- programName = shell.getRunningProgram()
- while noResponse == true do
- end
- end
- shell.exit = function()
- end
- --sandbox Functions
- function drawWarningScreen(title, name, command)
- slc = 0
- response = false
- saveslc = false
- width, height = term.getSize()
- while response == false do
- --Window
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 0)
- print("+-----------------------------+")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 1)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 2)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 3)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 4)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 5)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 6)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 7)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 8)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 9)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 10)
- print("| |")
- term.setCursorPos((width / 2) - (30 / 2), (height / 2) - (12 / 2) + 11)
- print("+-----------------------------+")
- --Window Content
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 0)
- print(title)
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 2)
- print("The program: ".. resolveProgrammName(name))
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 3)
- print("Trye'd to run: ".. command)
- if slc == 0 then
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 9)
- print("[Allow] Deny ")
- elseif slc == 1 then
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 9)
- print(" Allow [Deny]")
- else
- end
- term.setCursorPos((width / 2) - (30 / 2) + 1, (height / 2) - (12 / 2) + 10)
- if saveslc == true then
- print("(X) Save Selection")
- else
- print("( ) Save Selection")
- end
- event, param = os.pullEventRaw("key")
- if param == 203 then --Links
- if slc <= 1 then
- slc = slc - 1
- end
- elseif param == 205 then --Rechts
- if slc >= 0 then
- slc = slc + 1
- end
- elseif param == 28 then --Eingabe
- response = true
- elseif param == 57 then
- if saveslc == true then
- saveslc = false
- else
- saveslc = true
- end
- else
- end
- end
- return slc , saveslc
- end
- resolveProgrammName = function(path)
- arr = split(path, "/")
- return arr[#arr]
- end
- function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- addBlacklist = function(file)
- exists = false
- for i, v in pairs(BlackList) do
- if v == file then
- exists = true
- end
- end
- if exists == false then
- table.insert(BlackList, file)
- end
- saveBlacklist(".SandBox/Blacklist.db")
- end
- saveBlacklist = function(file)
- end
- loadBlacklist = function(file)
- end
- addWhitelist = function(file)
- exists = false
- for i, v in pairs(WhiteList) do
- if v == file then
- exists = true
- end
- end
- if exists == false then
- table.insert(WhiteList, file)
- end
- saveBlacklist(".SandBox/Whitelist.db")
- end
- saveWhitelist = function(file)
- end
- loadWhitelist = function(file)
- end
Advertisement
Add Comment
Please, Sign In to add comment