解密Lua字节码?

时间:2011-05-23 08:38:43

标签: lua bytecode encryption

我正在用这个脚本加密我的Lua代码。

local script = string.dump(
    function()
        local function h4x(strtbl)
            buffer=""
            for v in strtbl do
                buffer=buffer..strtbl[v]
            end
            return buffer
        end

        print("encrypted")

    end
)

buff=""
for v=1,string.len(script) do --Convert our string into a hex string.
    buff=buff..'\\'..string.byte(script,v)
end

file=io.open('encrypted.txt','w') --Output our bytecode into ascii format to encrypted.txt
file:write(buff)
file:flush()
file:close()

encrypted.txt的输出类似于“00/12/46/4/2/6/4/62 /”。我如何解密字节码?

2 个答案:

答案 0 :(得分:6)

此文字未加密。它只是十六进制的Lua字节码。

讨论将这个字节码反汇编成人类可读的操作码的方法是另一个问题:Lua equivalent to Python dis()?

答案 1 :(得分:1)

显然,它将每个BYTE打印为一个值(十进制,即使它表示转换为十六进制),用'/'分隔。

然后,您需要做的就是使用从字符串中提取的字节填充数组,使用tonumber将它们转换回字节值。 this将有助于解析格式化输出