Android studio +Python 完成so自动加壳

2018-08-26  本文已影响0人  阿怪Sir

ELF中的Section 和 segment

  1. Section 和 segment的概念


    20170601180629601.png

    ELF文件如上图所示segment 和 section。其实就是对于elf文件中一部分相同内容的不同描述映射而已,就是上图红框中标出的内容,就好比一个学院的学生,有人喜欢用一班的学生,二班的学生去描述,也有人用女同学,男同学去描述

  2. Section 和 segment两者的作用

首先需要了解一下程序编译链接过程如下图


屏幕快照 2018-08-26 下午4.13.58.png

防止静态分析篇——section加密

1.实现逻辑

Android自动化加密的实现

1.克隆https://github.com/aguai1/SoProtect.git java加密程序
2.根据Test.java生成可执行跨平台的jar包。
3.新建python文件。先进行gradle assemble命令生成aar。
然后定义函数:

def execute_command(cmdstring, cwd=None, timeout=None, shell=False):
if shell:
    cmdstring_list = cmdstring
else:
    cmdstring_list = shlex.split(cmdstring)
if timeout:
    end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout)

sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096)

while sub.poll() is None:
    time.sleep(0.1)
    if timeout:
        if end_time <= datetime.datetime.now():
            raise Exception("Timeout:%s" % cmdstring)

return str(sub.returncode)

4.通过python执行函数 完成so自动化加密

common.execute_command("java -jar " + "./core/encodeSection.jar " + libTrackeraarPath, None,
                       None, True)
上一篇 下一篇

猜你喜欢

热点阅读