lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Mar 2, 2015 at 6:12 PM,  <mchalkley@mail.com> wrote:
> I know this is a sore subject to begin with, and is probaby on the
> "forbidden topics for Mondays" list (or should be), but I'm afraid I
> have to do it anyway.
>
> The issue is that a server/application monitoring program I've written
> in Lua has become very useful (that's the good news), which now
> necessitates deploying it to a bunch (about 75) of our customer's
> Windows servers (that's the bad news). The program requires lfs,
> socket, sigar, and bit. To my knowledge, sigar only works with Lua 5.1.
>
> To have a completely standalone application within a single directory,
> this is what I've gotten down to:
>
> <MonitorDir>:
> lua.exe
> lua51.dll
> bit.dll
> lfs.dll
> liblua.dll
> sigar.dll
> libsigar.dll
> socket.lua
> mime.lua
> Monitor.lua
>
> socket - a directory containing:
> core.dll
>
> mime - a directory containing:
> core.dll
>
> With the above configuration, I can use Windows Task Manager to run
> the monitor program and it works just fine.
>
> Ideally, I'd like to run it with LuaJIT, but for now, I'd be thrilled
> to just get the above into a single windows exe that could be packed
> with UPX/zipped/etc.
>
> My objective is to decrease the number of files necessary to deploy
> and also to keep folks from mucking about with the code and screwing
> up something, so compressing/obfuscating/something along those lines
> would be necessary.
>
> Is there currently a "best way" to do this?
>
> Mark
>
>

I use MXE [1] to build a static executable for Windows. There are MXE
packages: Lua (version 5.2) and LuaJIT. Use one of them as a static
library. Program bin2c.lua [2] can be used to include your Lua file
into C file as a string. In C create Lua state, load Lua code from the
string and execute it. And finally statically link the executable with
modules used getting all-in-one EXE file.

> and also to keep folks from mucking about with the code and screwing
> up something, so compressing/obfuscating/something along those lines
> would be necessary.
Converting Lua file to byte-code before distributing or embedding it
is time-cost trade off. A normal user can't convert byte-code back to
Lua. A hacker can disable almost any kind of protection.

I've created Lua rock "luacryptor" [3], which takes a Lua module and
converts it to C module. It also has an option to convert to byte-code
before encrypting. All Lua functions are encrypted with a password in
the C module. A function is decrypted each time being called. Do not
judge strictly, it is my first Lua rock.

 [1] http://mxe.cc/
 [2] http://lua-users.org/files/wiki_insecure/users/MarkEdgar/bin2c.lua
 [3] https://github.com/starius/luacryptor

Best regards,
Boris Nagaev