如何反混淆Lua脚本?

时间:2017-05-25 20:22:57

标签: string lua byte obfuscation deobfuscation

local script= string.dump(
    function()
        print('Hi')
    end
)

buff=""

for v=1,string.len(script) do
    buff=buff..'\\'..string.byte(script,v)
end

print(buff)  

脚本变成字节码,任何想法如何反转它?

2 个答案:

答案 0 :(得分:5)

您不能将字节码反转为Lua源,但可以使用luac -l列出VM指令。

答案 1 :(得分:0)

要找到VM字节码和Lua字节码之间的区别,在VM字节码中始终总是在前面加上 public static Image FloodFill(this Image img, Point pt, Color color) { Stack<Point> pixels = new Stack<Point>(); var targetColor = ((Bitmap)img).GetPixel(pt.X, pt.Y); pixels.Push(pt); while (pixels.Count > 0) { Point a = pixels.Pop(); if (a.X < img.Width && a.X > -1 && a.Y < img.Height && a.Y > -1) { if (((Bitmap)img).GetPixel(a.X, a.Y) == targetColor) { ((Bitmap)img).SetPixel(a.X, a.Y, color); pixels.Push(new Point(a.X - 1, a.Y)); pixels.Push(new Point(a.X + 1, a.Y)); pixels.Push(new Point(a.X, a.Y - 1)); pixels.Push(new Point(a.X, a.Y + 1)); } } } return img; }

在这种情况下,这是VM \24字节码。这种令人迷惑的事物还使用了(virtual machine)函数,可以很容易地撤消。

这是经过修改的反编译器版本:

string.dump

此版本仅使用local script= string.dump( function() print('Hi') end ) buff="" for v=1,string.len(script) do buff=buff..'\\'..string.byte(script,v) end buff = "'"..buff.."'" print("print("..buff..")") 函数来打印在脚本中创建的print。源清晰可见,我很确定这对于所有不安全的VM混淆器都有效。