There is an Android so (dynamic link library) UPX Reinforcement Guide, in detail how to use UPX to Android so Shell, try to do a result OK, here only to record a few small problems encountered.
1, 40k and below so can not shell
[Email protected]:~/src$ upx.out a.out
Ultimate PackerFor executables
Copyright (C) 1996-2011
UPX 3.08 Markus Oberhumer, Laszlo Molnar & John reiser Dec 12th 2011
File size Ratio Format Name
-------------------- ------ ----------- -----------
Upx.out:a.out:notcompressibleexception
Packed 1 file:0 OK, 1 error.
Fix, add the following code
int Const dummy_to_make_this_compressible[10000] = {1,2,3};
2, no init section of so can not add shell
[Email protected]:~/src$ readelf- D a.out
Dynamic section at offset 0xe28 contains entries:
Tag Type Name/value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x400460
0x000000000000000d (FINI) 0x400694
0x0000000000000019 (Init_array) 0x600e10
[email protected]:~/src$ upx_diy.out libcmxsecd.so
Ultimate Packer for executables
Copyright (C) 1996-
UPX 1.02 Markus oberhumer, Laszlo Molnar & John reiser Mar 30th
File size ratio format Name
- ------------------- ------ ----------- -----------
Upx_diy.out: Libcmxsecd.so:UnknownExecutableFormatException
Packed 0 files.
Above, no (INIT) so cannot be added shell, workaround, by compiling option to join:
First define a function,
void my_init () {}
Compile-time Add compile option in Android.mk
Local_ldflags + =-wl,-init=my_init
3, for Android so reinforcement?
After UPX after the shell of So, through IDA can not be static analysis, there is better protection ability. But the weakness is also obvious, through the upx-d parameter can be perfectly stripped off.
But DIY source code, only our own compiled upx.out can take off the OH;)
4. Focus on Changelog
Https://www.pysol.org:4443/hg/upx.hg/log
https://sourceforge.net/p/upx/bugs/
Special attention to this discussion: https://sourceforge.net/p/upx/bugs/223/
Android so UPX Packers