Is it possible to change the value in Lua bytecode? How? Any ideas?

I got a script that is no longer supported, and I'm looking for a way to change the value of a variable in it ... the script is encrypted ( loadstring/bytecode/something like this), for example:loadstring('\27\76\117\97\81\0\1\4\4\4\8\0\')

I can find what I want to change (via notepad after compiling the script), but if I try to change the value, the script will not work, if I change and try to recompile it will not work: "luac: Testing09.lua: unexpected end in precompiled chunk" ...

Any ideas? I did something like this with a program that has been using ollydbg for a long time, but I can’t use it with lua scripts ... I got a little lost here that for a while Google Googling could not find a way ... Any ideas?

+4
source share
1 answer

Easy to change line in Lua bytecode. You just need to adjust the length of the string after changing it. The length before the string. It probably takes four or eight bytes immediately before the line, depending on whether you have a 32-bit or 64-bit platform. The length is stored in the content of the machine where the bytecode was created. Note that the lines include the trailing '\ 0', and this is considered the length.

It might be easier to just copy some bytes directly. Write this file

return "this is the new string you want" 

Create a bytecode from it with luacand look at the dump luac.outand find the string and its length. Copy these bytes to the source file.

, . , .

Lua, - , - return "this is the new string you want", - .

- lbci, . - ( ) setconstant , , .

, - ...

+7

All Articles