{"id":1410,"date":"2024-04-29T22:08:58","date_gmt":"2024-04-29T14:08:58","guid":{"rendered":"http:\/\/www.xiaosuigu.top\/?p=1410"},"modified":"2024-04-29T22:08:58","modified_gmt":"2024-04-29T14:08:58","slug":"%e5%b8%b8%e8%a7%81frida%e6%a3%80%e6%b5%8b","status":"publish","type":"post","link":"https:\/\/www.xiaosuigu.top\/index.php\/2024\/04\/29\/%e5%b8%b8%e8%a7%81frida%e6%a3%80%e6%b5%8b\/","title":{"rendered":"Frida\u68c0\u6d4b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u6587\u4ef6\u68c0\u6d4b<\/h2>\n\n\n\n<p>\u68c0\u6d4b\/data\/local\/tmp\u8def\u5f84\u4e0b\u7684\u662f\u5426\u6709frida\u7279\u5f81\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\uff1a\u5c06frida\u7684server\u6587\u4ef6\u91cd\u65b0\u547d\u540d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7aef\u53e3\u68c0\u6d4b<\/h2>\n\n\n\n<p>Frida\u7684\u9ed8\u8ba4\u7aef\u53e3\u662f27042\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\uff1a\u4fee\u6539\u542f\u52a8\u7aef\u53e3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/fs -l 0.0.0.0:6666\nadb forward tcp:6666 tcp:6666\nfrida -H 127.0.0.1:6666 \u5305\u540d -l hook.js<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u53cc\u8fdb\u7a0b\u4fdd\u62a4<\/h2>\n\n\n\n<p>\u5f53app\u4e3b\u52a8\u9644\u52a0\u81ea\u8eab\u8fdb\u7a0b\u65f6\uff0c\u8fd9\u65f6\u5019\u518d\u6ce8\u5165\u5c31\u4f1a\u63d0\u793a<code>run frida as root<\/code><\/p>\n\n\n\n<p>\u89e3\u51b3\uff1a\u4ee5spawn\u6a21\u5f0f\u542f\u52a8<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9a\u4f4d\u68c0\u6d4bfrida\u7684so<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function hook_dlopen() {\n    Interceptor.attach(Module.findExportByName(null, \"android_dlopen_ext\"),\n        {\n            onEnter: function (args) {\n                var pathptr = args&#91;0];\n                if (pathptr !== undefined &amp;&amp; pathptr != null) {\n                    var path = ptr(pathptr).readCString();\n                    console.log(\"load \" + path);\n                }\n            }\n        }\n    );\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">MAP\u68c0\u6d4b<\/h2>\n\n\n\n<p><code>\/proc\/\u8fdb\u7a0bID\/maps<\/code>\u00a0\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u6587\u4ef6\uff0c\u5b83\u5305\u542b\u4e86\u5f53\u524d\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u4fe1\u606f\u3002\u5f53\u4f60\u6253\u5f00\u8fd9\u4e2a\u6587\u4ef6\u65f6\uff0c\u5b83\u4f1a\u663e\u793a\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u8fdb\u7a0b\u4e2d\u6bcf\u4e2a\u5185\u5b58\u533a\u57df\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u5305\u62ec<code>frida-agent-64.so<\/code>\u3001<code>frida-agent-32.so<\/code>\u00a0\u7b49\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570anti_maps\uff0c\u7528\u4e8e\u963b\u6b62\u7279\u5b9a\u5b57\u7b26\u4e32\u7684\u641c\u7d22\u5339\u914d\uff0c\u907f\u514d\u68c0\u6d4b\u5230\u654f\u611f\u5185\u5bb9\u5982\"Frida\"\u6216\"REJECT\"\nfunction anti_maps() {\n    \/\/ \u67e5\u627elibc.so\u5e93\u4e2dstrstr\u51fd\u6570\u7684\u5730\u5740\uff0cstrstr\u7528\u4e8e\u67e5\u627e\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u6307\u5b9a\u5b57\u7b26\u5e8f\u5217\u7684\u4f4d\u7f6e\n    var pt_strstr = Module.findExportByName(\"libc.so\", 'strstr');\n    \/\/ \u67e5\u627elibc.so\u5e93\u4e2dstrcmp\u51fd\u6570\u7684\u5730\u5740\uff0cstrcmp\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\n    var pt_strcmp = Module.findExportByName(\"libc.so\", 'strcmp');\n    \/\/ \u4f7f\u7528Interceptor\u6a21\u5757\u9644\u52a0\u5230strstr\u51fd\u6570\u4e0a\uff0c\u62e6\u622a\u5e76\u4fee\u6539\u5176\u884c\u4e3a\n    Interceptor.attach(pt_strstr, {\n        \/\/ \u5728strstr\u51fd\u6570\u8c03\u7528\u524d\u6267\u884c\u7684\u56de\u8c03\n        onEnter: function (args) {\n            \/\/ \u8bfb\u53d6strstr\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\uff08\u6e90\u5b57\u7b26\u4e32\uff09\u548c\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff08\u8981\u67e5\u627e\u7684\u5b50\u5b57\u7b26\u4e32\uff09\n            var str1 = args&#91;0].readCString();\n            var str2 = args&#91;1].readCString();\n            \/\/ \u68c0\u67e5\u5b50\u5b57\u7b26\u4e32\u662f\u5426\u5305\u542b\"REJECT\"\u6216\"frida\"\uff0c\u5982\u679c\u5305\u542b\u5219\u8bbe\u7f6ehook\u6807\u5fd7\u4e3atrue\n            if (str2.indexOf(\"REJECT\") !== -1  || str2.indexOf(\"frida\") !== -1) {\n                this.hook = true;\n            }\n        },\n        \/\/ \u5728strstr\u51fd\u6570\u8c03\u7528\u540e\u6267\u884c\u7684\u56de\u8c03\n        onLeave: function (retval) {\n            \/\/ \u5982\u679c\u4e4b\u524d\u8bbe\u7f6e\u4e86hook\u6807\u5fd7\uff0c\u5219\u5c06strstr\u7684\u7ed3\u679c\u66ff\u6362\u4e3a0\uff08\u8868\u793a\u672a\u627e\u5230\uff09\uff0c\u4ece\u800c\u9690\u85cf\u654f\u611f\u4fe1\u606f\n            if (this.hook) {\n                retval.replace(0);\n            }\n        }\n    });\n\n    \/\/ \u5bf9strcmp\u51fd\u6570\u505a\u7c7b\u4f3c\u7684\u5904\u7406\uff0c\u9632\u6b62\u901a\u8fc7\u5b57\u7b26\u4e32\u6bd4\u8f83\u68c0\u6d4b\u654f\u611f\u4fe1\u606f\n    Interceptor.attach(pt_strcmp, {\n        onEnter: function (args) {\n            var str1 = args&#91;0].readCString();\n            var str2 = args&#91;1].readCString();\n            if (str2.indexOf(\"REJECT\") !== -1  || str2.indexOf(\"frida\") !== -1) {\n                this.hook = true;\n            }\n        },\n        onLeave: function (retval) {\n            if (this.hook) {\n                \/\/ strcmp\u8fd4\u56de\u503c\u4e3a0\u8868\u793a\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u7b49\uff0c\u8fd9\u91cc\u540c\u6837\u66ff\u6362\u4e3a0\u4ee5\u907f\u514d\u5339\u914d\u6210\u529f\n                retval.replace(0);\n            }\n        }\n    });\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u68c0\u6d4bstatus(\u7ebf\u7a0b\u540d)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function replace_str() {\n    var pt_strstr = Module.findExportByName(\"libc.so\", 'strstr');\n    var pt_strcmp = Module.findExportByName(\"libc.so\", 'strcmp');\n\n    Interceptor.attach(pt_strstr, {\n        onEnter: function (args) {\n            var str1 = args&#91;0].readCString();\n            var str2 = args&#91;1].readCString();\n            if (str2.indexOf(\"tmp\") !== -1 ||\n                str2.indexOf(\"frida\") !== -1 ||\n                str2.indexOf(\"gum-js-loop\") !== -1 ||\n                str2.indexOf(\"gmain\") !== -1 ||\n                str2.indexOf(\"gdbus\") !== -1 ||\n                str2.indexOf(\"pool-frida\") !== -1||\n                str2.indexOf(\"linjector\") !== -1) {\n                \/\/console.log(\"strcmp-->\", str1, str2);\n                this.hook = true;\n            }\n        }, onLeave: function (retval) {\n            if (this.hook) {\n                retval.replace(0);\n            }\n        }\n    });\n\n    Interceptor.attach(pt_strcmp, {\n        onEnter: function (args) {\n            var str1 = args&#91;0].readCString();\n            var str2 = args&#91;1].readCString();\n            if (str2.indexOf(\"tmp\") !== -1 ||\n                str2.indexOf(\"frida\") !== -1 ||\n                str2.indexOf(\"gum-js-loop\") !== -1 ||\n                str2.indexOf(\"gmain\") !== -1 ||\n                str2.indexOf(\"gdbus\") !== -1 ||\n                str2.indexOf(\"pool-frida\") !== -1||\n                str2.indexOf(\"linjector\") !== -1) {\n                \/\/console.log(\"strcmp-->\", str1, str2);\n                this.hook = true;\n            }\n        }, onLeave: function (retval) {\n            if (this.hook) {\n                retval.replace(0);\n            }\n        }\n    })\n\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">root\u68c0\u6d4b<\/h2>\n\n\n\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/630902421\">\u4f7f\u7528Shamiko\u6a21\u5757\u5b9e\u73b0\u5168\u5c40ROOT\u9690\u85cf &#8211; \u77e5\u4e4e (zhihu.com)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5237\u5165\u9b54\u6539frida<\/h2>\n\n\n\n<p>\u4e0b\u8f7d\u9b54\u6539\u7248\u672c\u7684frida\uff1a<a href=\"https:\/\/github.com\/hzzheyang\/strongR-frida-android\/releases?page=1\">Releases \u00b7 hzzheyang\/strongR-frida-android \u00b7 GitHub<\/a>\uff0c\u4e0b\u8f7d\u54ea\u4e00\u4e2a\u7136\u540e\u4e0a\u4f20\u548c\u6b63\u5e38frida\u4e00\u6837<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\uff1a<a href=\"https:\/\/www.52pojie.cn\/thread-1921073-1-1.html\">\u3010\u65b0\u63d0\u9192\u3011\u300a\u5b89\u5353\u9006\u5411\u8fd9\u6863\u4e8b\u300b\u5341\u516b\u3001\u8868\u54e5\uff0c\u4f60\u4e5f\u4e0d\u60f3\u4f60\u7684Frida\u88ab\u68c0\u6d4b\u5427!(\u4e0a) &#8211; \u300e\u79fb\u52a8\u5b89\u5168\u533a\u300f &#8211; \u543e\u7231\u7834\u89e3 &#8211; LCG &#8211; LSG |\u5b89\u5353\u7834\u89e3|\u75c5\u6bd2\u5206\u6790|www.52pojie.cn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u4ef6\u68c0\u6d4b \u68c0\u6d4b\/data\/local\/tmp\u8def\u5f84\u4e0b\u7684\u662f\u5426\u6709frida\u7279\u5f81\u6587\u4ef6\u3002 \u89e3\u51b3\uff1a\u5c06frida\u7684serve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1410","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/posts\/1410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/comments?post=1410"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/posts\/1410\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/media?parent=1410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/categories?post=1410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaosuigu.top\/index.php\/wp-json\/wp\/v2\/tags?post=1410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}