0% found this document useful (0 votes)
1K views1 page

Deobfuscate Lua

Uploaded by

hrjkelwkcj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views1 page

Deobfuscate Lua

Uploaded by

hrjkelwkcj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

local deobfuscator = {}

-- Base64 decoding function


function deobfuscator.base64_decode(input)
local b64chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

input = input:gsub('[^' .. b64chars .. '=]', '')

return input:gsub('.', function(x)


if x == '=' then return '' end
local r, f = '', (b64chars:find(x) - 1)
for i = 6, 1, -1 do r = r .. (f % 2 ^ i - f % 2 ^ (i - 1) > 0 and '1' or '0')
end
return r
end):gsub('%d%d%d?%d?%d?%d?', function(x)
if #x ~= 8 then return '' end
local c = tonumber(x, 2)
return string.char(c)
end)
end

-- String transformation function


function deobfuscator.transform_string(input)
return input:gsub('%[%[.-]]', function(match)
return match:sub(3, -3)
end)
end

-- Identifier renaming function


function deobfuscator.rename_identifiers(input)
local renamed = input:gsub('_[%w]+', function(match)
return match:sub(2)
end)
return renamed
end

-- Main deobfuscation function


function deobfuscator.deobfuscate(script)
local decoded = deobfuscator.base64_decode(script)
local transformed = deobfuscator.transform_string(decoded)
local readable = deobfuscator.rename_identifiers(transformed)

return readable
end

return deobfuscator

You might also like