iOS DEP研究(1)——创建Section

将加密的程序放在一个Section中,外壳运行时解密该Section,并执行解密后的程序。

  • 通过other linker flags创建

这篇文章提到过如何通过创建Section来防止dylib依附。其具体方法是在other linker flags中填入如下内容:

-Wl,-sectcreate,__RESTRICT,__restrict,/dev/null

那么我们要创建自己的Section的话,就可以修改为如下格式:

-Wl,-sectcreate,SEGMENT_NAME,SECTION_NAME,/dev/null

这样就可以创建一个size为1,段名字为SEGMENT_NAME,Section名为SECTION_NAME的Section了。

那么因为我们要把加密数据放进去,所以最后一个参数改为我们的加密文件的路径即可。

你可以在ld(1)中的Options that control additional content找到这部分内容。

  • 通过代码创建

下面来说说怎么用代码创建一个Section。

__declspec(allocate("__[data deleted],__code"))
void func()
{

}

随后找个地方用一下func()就行,如果func()没有被调用的话,默认不会编译进可执行文件。

之后都将使用第一种方式创建Section。

已经创建好的Section

One thought on “iOS DEP研究(1)——创建Section”

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × four =