Rerubi icon indicating copy to clipboard operation
Rerubi copied to clipboard

decoding luac bytecode with hex and decoding it

Open aiden5070 opened this issue 6 years ago • 6 comments

if you encoded any lua bytecode with hex and then decoding it, running it again it will say it is not valid bytecode. this goes for any form of encryption or encoding. even after decoding it to its original state, the vm will not accept it

for additional information: https://pastebin.com/raw/PvuU9N5e

that has minified the interpreter and has the encoding and decoding. encoded gets decoded then run on the interpreter (is luac bytecode and non encoded runs 100% fine) but throws an error: Lua bytecode expected

aiden5070 avatar Jul 06 '19 11:07 aiden5070

I'm not exactly sure what I'm looking at. Could you provide a non minified example?

Rerumu avatar Jul 12 '19 19:07 Rerumu

Script.zip I've provided a zipped ROBLOX Model containing a repo. Essentially, converting from Hex to bytecode results in Rerubi to complain about the result being incompatible Lua bytecode.

image image

Reinitialized avatar Jul 29 '19 01:07 Reinitialized

It seems like you are trying to execute the ASCII representation of a hex string within Rerubi. This will not work, it's just a bunch of letters and numbers. First, you must properly re-convert the string to binary format first. The example fails to call fromhex as rerubi(fromhex(exampleHex))().

Rerumu avatar Jul 29 '19 01:07 Rerumu

Yikes, seems I didn't double check my work. Here's a fixed version, though it's overall the same error. Script.zip

Reinitialized avatar Jul 29 '19 01:07 Reinitialized

The new repro was also bugged, using string.byte instead of string.char within its tobyte function, causing an invalid binary stream to be generated.

I have fixed this and before further debugging decided to try loading it with my local Lua copy. This is not a Rerubi bug it seems, but whatever code you are using to generate the hex representation is doing it incorrectly. This is not valid Lua bytecode. image

Rerumu avatar Jul 29 '19 06:07 Rerumu

Apologies on the terrible examples, I was running on 2 hours for nearly 48 hours ... yikes. However, as figured, it was the method of translating and not Rerubi itself. I wouldn't have created an issue myself knowing this, but since it was already a thing I figured I'd try to provide the lack of provided information.

Reinitialized avatar Aug 02 '19 19:08 Reinitialized