1

I am trying to decrypt an encrypted lua code, because: First: I don't want to create it from the begging. Second: It sounds fun!

I've created a simple program at Visual Basic 2013 that executes lua functions from a file, the files as you guys can see below contains the encrypted code defined as 'code' in ASCII bytes and my lua code translate it back to the original form.

The problem is: I can translate some words and sign but it still pretty mess, since this is a lua code and contains numbers, signs and words.

The files of the program, as the code encrypted and the code to decrypt can be found at my Gist: https://gist.github.com/DarkShinz/e9aeca7dd1ac1035cf6e ; so you guys can reproduce my so far progress.

I need advices to improve my following code, because, so far, it decrypts some words but others are still just numbers and some signs. Still a mess to the eye.

function tablelength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end

local code = {SOME COMPILED LUA CODE} //Mine is too extensive to be added here
local finalString = "Yay! :"
local codeLength = tablelength(code)
local text = nil

for i = 1, codeLength do
local letter = string.char(code[i])


if (letter:match("%w")) then

elseif (letter:match("%d")) then

elseif (letter:match("%s")) then

elseif (letter:match("%p")) then

elseif (letter:match("%(")) then

elseif (letter:match("%)")) then

elseif (letter:match("%.")) then

elseif (letter:match("%+")) then

elseif (letter:match("%*")) then

elseif (letter:match("%@")) then

elseif (letter:match("%?")) then

elseif (letter:match("%^")) then

elseif (letter:match("%$")) then

elseif (letter:match("%-")) then

elseif (letter:match("%=")) then

elseif (letter:match("%_")) then

elseif (letter:match("%[")) then

elseif (letter:match("%]")) then

elseif (letter:match("%:")) then

elseif (letter:match("%,")) then

elseif (letter:match("%#")) then

elseif (letter:match("%&")) then

else
letra = string.byte(letter)
end

finalString = finalString .. letra
end

print(finalString)

This is my output

I wish I had a full clean lua source code.

Xabirau
  • 41
  • 9
  • I do not understand your problem or question. Perhaps you are just looking for advice to improve your existing code? If so, this question belongs on http://codereview.stackexchange.com – Phrogz Mar 19 '16 at 04:48
  • 2
    What you're looking for is "decompiling", not decrypting. http://stackoverflow.com/questions/743684/best-tools-for-decompiling-lua-bytecode – Vlad Mar 19 '16 at 08:15
  • @Phrogz I cannot add the whole code cause of its extesion, so I've add the "decompiler code" without the compiled code that I am trying to decompile.. – Xabirau Mar 19 '16 at 13:47
  • Please post some sample input, what you expect the output to be, and what you get instead. – Phrogz Mar 19 '16 at 13:48
  • @Phrogz Just edited the main thread. – Xabirau Mar 19 '16 at 14:58
  • @Vlad I've tried to use both LuaDec and unluac, but my code is in Decimal (ASCII), not hexadecimal as a luac file is compiled. So I am trying to turn it back to a string format. – Xabirau Mar 19 '16 at 17:06

0 Answers0