http://blog.csdn.net/zcrong/article/details/51617348

在Other Linker Flags中添加:

-Wl,-sectcreate,__RESTRICT,__restrict,/dev/null
 
再来看看生成的macho文件多了一个__RESTRICT/__restrict  section
类似美团某个版本采取的section办法
为什么加了这样的一个section就能阻止dylib注入了呢?
 
 

在这里找到了答案:http://www.opensource.apple.com/source/dyld/dyld-210.2.3/src/dyld.cpp

也就是说下面三种情况,可以让环境变量:DYLD_INSERT_LIBRARIES被无视

if ( removedCount != 0 ) {
        dyld::log("dyld: DYLD_ environment variables being ignored because ");
        switch (sRestrictedReason) {
            case restrictedNot:
                break;
            case restrictedBySetGUid:
                dyld::log("main executable (%s) is setuid or setgid\n", sExecPath);
                break;
            case restrictedBySegment:
                dyld::log("main executable (%s) has __RESTRICT/__restrict section\n", sExecPath);
                break;
            case restrictedByEntitlements:
                dyld::log("main executable (%s) is code signed with entitlements\n", sExecPath);
                break;
        }
    }

  1. 1.Set restricted status by entitlements

    This option is only available to applications on OS X with special entitlements.

  2. 2.setuid and setgid

    Any application that makes these two calls are going to be marked as restricted by the linker as a security measure.

  3. 3.Restricted Segment of Header

    The final way to mark a binary as restricted is by telling the linker to add new section to the binary header that is named “__RESTRICT” and has a section named “__restrict” when you compile it.

所以编译生成的含有__RESTRICT/__restrict  section的app会忽略DYLD_INSERT_LIBRARIES。

当然解决办法也是有的,用010 editor打开可执行文件,把section的名字修改一下即可。

iOS安全—阻止tweak注入hook api的更多相关文章

  1. EasyHook远程进程注入并hook api的实现

    EasyHook远程进程注入并hook api的实现 http://blog.csdn.net/v6543210/article/details/44276155

  2. HOOK API (一)——HOOK基础+一个鼠标钩子实例

    HOOK API (一)——HOOK基础+一个鼠标钩子实例 0x00 起因 最近在做毕业设计,有一个功能是需要实现对剪切板的监控和进程的防终止保护.原本想从内核层实现,但没有头绪.最后决定从调用层入手 ...

  3. 汇编Ring 3下实现 HOOK API

    [文章标题]汇编ring3下实现HOOK API [文章作者]nohacks(非安全,hacker0058) [作者主页]hacker0058.ys168.com [文章出处]看雪论坛(bbs.ped ...

  4. HOOK API(四)—— 进程防终止

    HOOK API(四) —— 进程防终止 0x00        前言 这算是一个实战吧,做的一个应用需要实现进程的防终止保护,查了相关资料后决定用HOOK API的方式实现.起初学习HOOK API ...

  5. HOOK API(三)—— HOOK 所有程序的 MessageBox

    HOOK API(三) —— HOOK 所有程序的 MessageBox 0x00 前言 本实例要实现HOOK MessageBox,包括MessageBoxA和MessageBoxW,其实现细节与H ...

  6. HOOK API(二)—— HOOK自己程序的 MessageBox

    HOOK API(二) —— HOOK自己程序的 MessageBox 0x00 前言 以下将给出一个简单的例子,作为HOOK API的入门.这里是HOOK 自己程序的MessageBox,即将自己程 ...

  7. Android进程so注入Hook java方法

    本文博客链接:http://blog.csdn.net/qq1084283172/article/details/53769331 Andorid的Hook方式比较多,现在来学习下,基于Android ...

  8. HOOK API(二) —— HOOK自己程序的 MessageBox

    转载来源:https://www.cnblogs.com/hookjc/ 0x00 前言 以下将给出一个简单的例子,作为HOOK API的入门.这里是HOOK 自己程序的MessageBox,即将自己 ...

  9. HOOK API(三) —— HOOK 所有程序的 MessageBox

    转载来源:https://www.cnblogs.com/hookjc/ 0x00 前言 本实例要实现HOOK MessageBox,包括MessageBoxA和MessageBoxW,其实现细节与H ...

随机推荐

  1. Navigator

      Navigator   这是一个简单的例子,用Navigator来跳转页面,页面之间传递参数 (代码是ES6语法写的): import React from 'react'; import { V ...

  2. GOLANG SDK下载

    如果没有FQ的话是不能访问国外网站的,但是golang提供了中国站点,要下载sdk可以在中国站点下载 中国站点: http://www.golangtc.com/download

  3. ubuntu 14.04 vsftpd安装问题

    sudo apt-get install vsftpd; 打开允许访问用户名 local_enable=YES write_enable=YES chroot_list_file=/etc/vsftp ...

  4. 微信小程序-表单组件

    button 按钮 注:button-hover 默认为{background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;} 示例代码: /** wxss **/ ...

  5. solrconfig.xml解析

    solrconfig.xml配置文件主要定义了SOLR的一些处理规则,包括索引数据的存放位置,更新,删除,查询的一些规则配置.下面将对solrconfig进行详细描述:1 <luceneMatc ...

  6. DSO的记录模式Record Mode字段测试

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  7. Rails中的缓存

    最近学习Rails. 看到如下代码: <% if notice %> <p id="notice"><%= notice %></p> ...

  8. JQuery 添加节点

    Mark一段自己写的添加节点的代码 function reply2(){ $( "<div class=sec1-div5>"+"<div class= ...

  9. angular 路由请求js文件

    <script type="text/javascript" src="http://apps.bdimg.com/libs/angular.js/1.3.2/an ...

  10. eclipse rcp 打包出适合不同操作系统和操作位数.

    http://blog.csdn.net/luoww1/article/details/8677999 http://blog.csdn.net/soszou/article/details/8053 ...