Advertisement
ComputerMan123

New Sandbox Test

Sep 25th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sbRoot = "/sandboxed/" --#The path programs shouldn't escape
  2. local function sandboxCheck(path)
  3.   local fullPath = fs.combine(sbRoot, path)
  4.   local splitPath = split(fullPath, "/")
  5.   local sbRootSP = split(sbRoot, "/")
  6.   local ssPath = ""
  7.   local ssFPath = ""
  8.   for i, v in ipairs(splitPath) do
  9.     ssPath = ssPath .. " " .. v
  10.     if i <= #sbRootSP then
  11.           if not isEmpty(sbRootSP[i]) then
  12.             ssFPath = ssFPath .. " " .. sbRootSP[i]
  13.           end
  14.     end
  15.   end
  16.   for i, v in ipairs(sbRootSP) do
  17.     if not string.match(ssPath, v) then
  18.           print("BYPASS ATTEMPT IN: " .. path)
  19.           return false
  20.     end
  21.   end
  22.   return true
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement