luac precompile

Posted by Renny on Fri 17 Aug 2018 05:19 AM — 14 posts, 47,198 views.

Canada #0
http://www.gammon.com.au/forum/?id=7322

I tried using luac5.1 from the link above but when I use dofile(...) it tells me:

"cannot load incompatible bytecode"


Any reasons why this may be?
Australia Forum Administrator #1
I can't reproduce that. Using the file in that link (luac5.1.exe) and compiling some test Lua code, and then running it in MUSHclient, it works perfectly.
Australia Forum Administrator #2
In any case, using luac only saves the compile time (converting the Lua source code into byte-code). It doesn't speed up execution. I never use it, personally.
Canada #3
Hmm, I tried to load it using the standalone interpreter and it worked, so I'm guessing it has something to do with mushclient.

This page https://www.lua.org/manual/5.1/luac.html mentions

Quote:

The binary files created by luac are portable only among architectures with the same word size and byte order.
Australia Forum Administrator #4
Template:version
Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.
Canada #5
Version 5.06-pre
You are using Aardwolf MUSHclient Package version: r1983
Australia Forum Administrator #6
I think Aardwolf uses LuaJIT - that might not be compatible. It also should be faster anyway without precompiling.
Australia Forum Administrator #7
See this: http://lua-users.org/lists/lua-l/2011-06/msg01052.html

Quote:

The -b command line option saves LuaJIT bytecode (similar to 'luac'):

http://luajit.org/running.html#opt_b


It would seem therefore that to try to precompile for LuaJIT you need to use LuaJIT to do the compiling, not luac.
USA Global Moderator #8
Quote:
I think Aardwolf uses LuaJIT

Yep

Quote:
that might not be compatible

I was going to say probably not, but I guess we're actually beyond probably now. :-)


All of the preceding aside, why are you trying to pre-generate bytecode?
Amended on Sun 19 Aug 2018 01:30 AM by Fiendish
Canada #9
Fiendish said:

All of the preceding aside, why are you trying to pre-generate bytecode?


How else would I obfuscate my RAT?

err I mean... I was just curious.
USA Global Moderator #10
Quote:
How else would I obfuscate my RAT?

Your what?
Australia Forum Administrator #11
I didn't want to ask for fear of looking like I didn't know all the recent acronyms, but maybe:

Quote:

"RAT" also refers to "Operation Shady RAT" in which RAT stands for "Remote Access Tool," a type of software that hackers and security experts use to access computer networks from afar.




Remotely Activated Trojan -or- Remote Access Tool
Australia Forum Administrator #12
Personally I would be very wary of any code distributed as precompiled. There is no way to inspect it and see if it does anything malicious, like open files, send data over the Internet, or even delete files.

See the post about Lua security:

http://www.gammon.com.au/forum/?id=10503


I strongly advise MUSHclient users from installing any plugin or other module which is supplied in pre-compiled form. The same would apply if you are required to run a .exe or .dll file.

The speed improvements that might be obtained from precompiling would be minor, and the possible security breaches could be major.

At least when code is supplied in "normal" plugins, which are fairly human-readable, or Lua modules, which are readable if you know Lua, there is a reasonable chance that someone would detect any attempts to compromise the target computer.

See the link above for suggestions about being wary of certain plugins.
Canada #13
Nick Gammon said:

I didn't want to ask for fear of looking like I didn't know all the recent acronyms, but maybe:



Sorry, that was a snide comment in response to the "why".

Initially I was looking at this thread, http://www.gammon.com.au/forum/?id=4914, and I couldn't get the compiled code to load. But now I know why!

Yes I agree never run compiled code from an untrusted source.