держите для ознакомления готовый луа криптор.
Lua:
local random, randomseed = math.random, math.randomseed
local char, byte, gsub, match, sub, find =
string.char, string.byte, string.gsub, string.match, string.sub, string.find
local insert, concat = table.insert, table.concat
math.randomseed(os.time())
local function getFileNameFromPath(path)
return string.match(path, '.+\\(.-)$')
end
local function getFileNameFromPathWithoutEx(path)
return string.match(path, '.+\\(.+)%..+$')
end
-----------------------------------------------------------------------------------
local val_to_str, key_to_str, tabletostring
function val_to_str ( v )
if "string" == type( v ) then
v = gsub( v, "\\", "\\\\" )
v = gsub( v, "\n", "\\n" )
v = gsub( v, "\t", "\\t" )
if match( gsub(v,"[^'\"]",""), '^"+$' ) then
return "'" .. v .. "'"
end
return '"' .. gsub(v,'"', '\\"' ) .. '"'
else
return "table" == type( v ) and tabletostring( v ) or
tostring( v )
end
end
function key_to_str ( k )
if "string" == type( k ) and match( k, "^[_%a][_%a%d]*$" ) then
return k
else
return "[" .. val_to_str( k ) .. "]"
end
end
function tabletostring( tbl )
local result, done = {}, {}
for k, v in ipairs( tbl ) do
insert( result, val_to_str( v ) )
done[ k ] = true
end
for k, v in pairs( tbl ) do
if not done[ k ] then
insert( result,
key_to_str( k ) .. "=" .. val_to_str( v ) )
end
end
return "{" .. concat( result, "," ) .. "}"
end
local function crypt_func(text) -- crypt
if not text or text == '' then return end
local n1, n2 = random(20), random(20)
while n1 == n2 do n1, n2 = random(20), random(20) end
local n3 = random(#text)
local key = { n3, byte(text, n3) }
local crypt_text = { #text }
for i = 1, #text do
local char = byte(text, i)
crypt_text[#crypt_text + 1] = char - n1 + n2
end
return { crypt_text, key }
end
local function get_params(text)
local t = {}
local b = ''
for i = 1, #text do
if find(sub(text, i, i), '%w') or find(sub(text, i, i), '[^%s%c%p\128-\191][\128-\191]*') then
b = b .. sub(text, i, i)
else
if b ~= '' then
t[#t + 1] = b
b = ''
end
t[#t + 1] = byte(text, i)
end
end
return t
end
-----------------------------------------------------------------------------------
os.execute('cls')
if #arg < 1 then
io.write('Not found files.')
return os.execute('pause')
end
local file = io.open(arg[1], 'rb')
local text = file:read('*a')
local res = tabletostring(crypt_func(text))
local antidecomp = [[local function _() ::SOSAT:: goto SOSAT end
local function __() return]]
for i = 1, math.random(220, 228) do
antidecomp = antidecomp.." "..math.random(-2147483648, 2147483647)..","
end
antidecomp = antidecomp.." "..math.random(-2147483648, 2147483647).." end\n"
local code = [[
local g = _G
local char = 'c'
local str = ''
local function _____()
return str[char .. 'r']
end
char = char .. 'h' .. 'a'
local char = _____()
local chars = {
{
166,
154,
173,
161
},
{
171,
154,
167,
157,
168,
166
}
}
local math = ''
local random = ''
for i = 1, #chars[1] do
math = math..char(chars[1][i] - 57)
end
for i = 1, #chars[2] do
random = random..char(chars[2][i] - 57)
end
local random = g[math][random]
local function decrypt(tab) -- decrypt
local a, b = tab[2][1], tab[2][2]
local n1, n2 = random(20), random(20)
while tab[1][a + 1] - n2 + n1 ~= b do n1, n2 = random(20), random(20) end
local decrypt_text = ''
for i = 2, tab[1][1] + 1 do
decrypt_text = decrypt_text .. char(tab[1][i] - n2 + n1)
end
return decrypt_text
end
local res = decrypt]] .. res .. [[
local pcall = g[decrypt{{5, 125, 112, 110, 121, 121}, {4, 108}}]
local lua_thread = g[decrypt{{10, 120, 129, 109, 107, 128, 116, 126, 113, 109, 112}, {4, 95}}]
local create = decrypt{{6, 114, 129, 116, 112, 131, 116}, {3, 101}}
local loadstring = g[decrypt{{10,106,109,95,98,113,114,112,103,108,101},{2,111}}]
local string = decrypt{{6, 118, 119, 117, 108, 113, 106}, {1, 115}}
local dump = decrypt{{4, 108, 125, 117, 120}, {2, 117}}
local dump = g[string][dump]
local resc = pcall(dump, loadstring)
if not resc then
lua_thread[create](function() loadstring(res)() end)
end
]]
local file = io.open(arg[1], 'w')
file:write(antidecomp..code)
file:close()
os.execute(string.format('luajit.exe -b "%s" "%s.luac"', arg[1], getFileNameFromPathWithoutEx(arg[1])))