Android so UPX加壳

时间:2016-06-27 21:18:38   收藏:0   阅读:1450

网上有篇 Android SO(动态链接库)UPX加固指南,详细介绍了如何使用UPX给Android SO加壳,尝试做了一下结果ok,这里只记录遇到的几个小问题。

1、40k以下so不能加壳

kiiim@ubuntu:~/src$ upx.out a.out
                       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
   --------------------   ------   -----------   -----------
upx.out: a.out: NotCompressibleException                                      

Packed 1 file: 0 ok, 1 error.

解决,添加下面代码

int const dummy_to_make_this_compressible[10000] = {1,2,3};

2、无INIT节区的so不能加壳

kiiim@ubuntu:~/src$ readelf -d a.out

Dynamic section at offset 0xe28 contains 24 entries:
  Tag        Type                         Name/Value
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
0x000000000000000c (INIT)               0x400460
0x000000000000000d (FINI)               0x400694
0x0000000000000019 (INIT_ARRAY)         0x600e10

 

 

kiiim@ubuntu:~/src$ upx_diy.out libcmxsecd.so
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2016
UPX 1.02        Markus Oberhumer, Laszlo Molnar & John Reiser   Mar 30th 2016

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx_diy.out: libcmxsecd.so: UnknownExecutableFormatException

Packed 0 files.

以上,没有(INIT)的so不能进行加壳,解决办法,通过编译选项加入:

首先定义一个函数,

void my_init(){}

编译时在Android.mk添加编译选项,

LOCAL_LDFLAGS += -Wl,-init=my_init

3、用于Android so加固?

经过UPX加壳后的so,通过IDA不能静态分析,有比较好的保护能力。但弱点也很明显,通过 upx -d参数就可以完美扒掉。

但diy源码,就只有我们自己编译的upx.out可以脱了哦;)

4、关注changelog

https://www.pysol.org:4443/hg/upx.hg/log

https://sourceforge.net/p/upx/bugs/

特别关注下这个讨论:https://sourceforge.net/p/upx/bugs/223/

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!