Friday, June 20, 2014

[kazhsrsn] Uncompress then execute

The UPX executable packer works reasonably well on GHC-compiled programs (7.6.3, ELF x86-64):

$ upx --best hello-world

                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2011
UPX 3.08        Markus Oberhumer, Laszlo Molnar & John Reiser   Dec 12th 2011

     File size         Ratio      Format      Name
--------------------   ------   -----------   -----------
1133761 ->    314008   27.70%  linux/ElfAMD   hello-world

The failure mode before and after compression when libgmp is missing is identical, which is good. Compression does not obfuscate errors, even though ldd can no longer detect the shared libraries.
$ ./hello-world
./hello-world: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory

$ ldd ./hello-world
        not a dynamic executable

Packing executables is in general an interesting problem. Any other type of file that is read, we can insert a uncompression program as a pipe. However, executing is a bit more magical than just reading.

No comments :