Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ]]
- --
- function Obfuscate(scr)
- --concat
- local concat = function(...) return table.concat({...}, "") end
- --stringDump1
- local function dumpString(x) return concat("\"", x:gsub(".", function(d) return "\\" .. string.byte(d) end), "\"") end
- --stringDump2
- local function dumpString2(x)
- local x2 = "\""
- local x3 = ""
- for _,__ in x:gmatch("%[(=*)%[(.-)%]%1%]") do
- x3 = __:gsub(".", function(d) return "\\" .. string.byte(d) end)
- end
- return concat(x2, x3, x2)
- end
- --stringDump3
- local function dumpString3(x)
- return(x:gsub(".", function(bb) return "\\" .. bb:byte() end) or thing .. "\"")
- end
- --Bye comments
- scr = scr:gsub("(%-%-%[(=*)%[.-%]%2%])", "")
- scr = scr:gsub("(%-%-[^\r\n]*)", "")
- --Functions rename
- local chars ="1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1I1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1I1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1I1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1IlI1"
- local taken = { }
- taken[""] = true
- local function GetReplacement()
- local s = ""
- while taken[s] do
- for i = 1, math.random(20, 60) do
- local c = chars:sub(i,i)
- s = s..c
- end
- end
- taken[s] = true
- return(customVarNames[math.random(1,#customVarNames)].. s)
- end
- local library = {}
- --wipe strings
- for each in scr:gmatch('"(%w+)"') do
- scr = scr:gsub('"'..each..'"', "'"..dumpString3(each).."'")
- end
- --local functions
- for fType in scr:gmatch("local%s*function%s*([%w_]+)%(") do
- local replacement = GetReplacement()
- if #fType > 5 then
- library[fType] = replacement
- scr = scr:gsub("function " .. fType, "function " .. replacement)
- end
- end
- for fCall in scr:gmatch("([%w_]+)%s*%(") do
- if library[fCall] then
- scr = scr:gsub(fCall .. '(', library[fCall] .. '(')
- end
- end
- --not local function
- for fType in scr:gmatch("%s*function%s*([%w_]+)%(") do
- local replacement = GetReplacement()
- if #fType > 5 then
- library[fType] = replacement
- scr = scr:gsub("function " .. fType, "function " .. replacement)
- end
- end
- for fCall in scr:gmatch("([%w_]+)%s*%(") do
- if library[fCall] then
- scr = scr:gsub(fCall .. '(', library[fCall] .. '(')
- end
- end
- --Var rename
- local function isKeyword(s)
- local s2 = 'and break do else elseif end false for function if in local nil not or repeat return then true until'
- for w in s2:gmatch("(%w+)") do
- if w == s then return true end
- end
- return false
- end
- for each in scr:gmatch("local%s*([%w_]*)%s*=%s") do
- if #each > 3 and not isKeyword(each) then
- local varName = GetReplacement()
- scr = scr:gsub(each," "..varName)
- end
- end
- for i,v in pairs(funcrename) do
- local pp = GetReplacement()
- funcrename[i]= pp
- end
- local setlist = ""
- for i,v in pairs(funcrename) do
- setlist = setlist..("local "..v.."="..i.."; ")
- scr = scr:gsub(i, v)
- end
- scr=setlist..scr
- scr = scr:gsub(" %s+", " ")
- scr = scr:gsub("\n%s", " ")
- --Done
- print(scr)
- end
- do Obfuscate(Script)end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement