{"id":540,"date":"2024-10-06T01:30:44","date_gmt":"2024-10-05T17:30:44","guid":{"rendered":"https:\/\/ahui.blog\/?p=540"},"modified":"2024-10-07T17:01:39","modified_gmt":"2024-10-07T09:01:39","slug":"app-https-hook","status":"publish","type":"post","link":"https:\/\/ahui.blog\/index.php\/2024\/10\/06\/app-https-hook\/","title":{"rendered":"\u5b89\u5353APP-HTTPS\u6293\u5305Frida Hook\u6559\u7a0b"},"content":{"rendered":"<h3>\u73af\u5883<\/h3>\n<p>Windows10\u4e3b\u673a\u5b89\u88c5adb\u3001frida16.1.4<\/p>\n<p>BlueStacks 5 China\u5b98\u7f51\u6700\u65b0\u7248<\/p>\n<h3>\u51c6\u5907\u9636\u6bb5<\/h3>\n<ul>\n<li>\n<p>\u6a21\u62df\u5668root\uff0c\u5728\u8bbe\u7f6e\u4e2d\u5c31\u53ef\u4ee5\u627e\u5230<\/p>\n<\/li>\n<li>\n<p>\u6a21\u62df\u5668\u6253\u5f00ADB\u5f00\u5173<\/p>\n<\/li>\n<li>\n<p>\u8fde\u63a5adb\uff0c\u505a\u7aef\u53e3\u8f6c\u53d1<\/p>\n<pre><code>adb connect 127.0.0.1:5555\nadb forward tcp:27042 tcp:27042\nadb forward tcp:27043 tcp:27043<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u6293\u5305<\/h3>\n<ol>\n<li>\n<p>\u8fde\u63a5adb shell\uff0c\u5411\u6a21\u62df\u5668\u4e0a\u4f20frida-server\uff0c\u5e76\u542f\u52a8frida-server\u7aef<\/p>\n<pre><code>adb push frida-server-16.1.4-android-x86_64 \/data\/local\/tmp\/frida-server-16.1.4-android-x86_64\nadb shell\nsu root\ncd \/data\/local\/tmp\n.\/frida-server-16.1.4-android-x86_64<\/code><\/pre>\n<\/li>\n<li>\n<p>\u67e5\u770b\u8981\u6293\u7684\u5305\u540d-\u5f15\u7528\u81eahttps:\/\/zhuanlan.zhihu.com\/p\/467828480?utm_id=0<\/p>\n<blockquote>\n<p>1\u3001\u67e5\u770b\u5c06\u8981\u542f\u52a8\u6216\u9000\u51faapp\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell am monitor\uff08\u53ea\u6709\u5728\u542f\u52a8\u6216\u9000\u51fa\u7684\u65f6\u5019\u624d\u4f1a\u6253\u5370\uff09<\/code><\/pre>\n<p>2\u3001\u67e5\u770b\u5b89\u88c5\u7684\u7b2c\u4e09\u65b9app\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell pm list packages -3<\/code><\/pre>\n<p>3\u3001\u67e5\u770b\u5f53\u524d\u754c\u9762\u7684app\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell dumpsys window windows | findstr mFocusedApp<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>4\u3001\u67e5\u770b\u542f\u52a8\u7684app\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell dumpsys activity top | find \"ACTIVITY\"<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>5\u3001\u67e5\u770b\u6240\u6709\u542f\u52a8\u7684\u5e94\u7528\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell dumpsys activity activities | findstr \"Run\"<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>6\u3001\u67e5\u770b\u5f53\u524d\u542f\u52a8\u5e94\u7528\u7684\u5305\u540d<\/p>\n<pre><code class=\"language-text\">adb shell dumpsys window w |findstr \\\/ |findstr name=<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>7\u3001\u901a\u8fc7\u5e94\u7528\u67e5\u770b\u5305\u540d<\/p>\n<pre><code class=\"language-text\">aapt dump badging D:\\test\\xxx.apk(APK\u7684\u5168\u540d)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>\uff08aapt\u4e0d\u662f\u53ef\u8fd0\u884c\u547d\u4ee4\u7684\u8bdd\uff0c\u9700\u8981\u914d\u7f6e\u73af\u5883\uff09<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/post-540-670177c858f0e.\" alt=\"img\" \/><\/p>\n<p>8\u3001\u5176\u4ed6\u65b9\u6cd5<\/p>\n<p>\uff081\u3001\u67e5\u770b\u8fdb\u7a0b\u7684\u65b9\u6cd5\u67e5\u770b\u5305\u540d 2\u3001\u67e5\u770b\u65e5\u5fd7\u7684\u65b9\u6cd5 3\u3001\u76f4\u63a5\u5728\u624b\u673a\u8bbe\u7f6e\u6253\u5f00\u5e94\u7528\u4e0e\u6743\u9650\u67e5\u770b\uff09<\/p>\n<pre><code class=\"language-text\">**\u6709\u4e9b\u547d\u4ee4\u9700\u8981adb root \uff1b  adb remount \u4e4b\u540e\u624d\u80fd\u4f7f\u7528 ;( remount\u4e0d\u6210\u529f\u7684\u8bdd\u7528\uff1aadb shell verity-disabled \u8fd0\u884c\u4e4b\u540e\u91cd\u542f\u624b\u673a\u5728remount)<\/code><\/pre>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u5728adb shell\u4e2d\u6267\u884c\u547d\u4ee4\uff0c\u5f00\u542ftcpdump\u6293\u5305\uff0c\u8fd9\u4e2a\u76ee\u5f55\u662f\u6a21\u62df\u5668\u8d44\u6e90\u7ba1\u7406\u5668\u7684Download\u76ee\u5f55\uff0c\u65b9\u4fbf\u5bfc\u51fa<\/p>\n<pre><code>tcpdump -i any -s 0 -w \/mnt\/sdcard\/Download\/damai.pcap<\/code><\/pre>\n<\/li>\n<li>\n<p>Windows\u7aef\u6267\u884cfrida hook\uff0c\u6293ssl\u8bc1\u4e66<\/p>\n<p>sslkeyfilelog.js \u6587\u4ef6\u5185\u5bb9<\/p>\n<pre><code class=\"language-js\">function startTLSKeyLogger(SSL_CTX_new, SSL_CTX_set_keylog_callback) {\n   console.log(\"start----\")\n   function keyLogger(ssl, line) {\n       console.log(new NativePointer(line).readCString());\n   }\n   const keyLogCallback = new NativeCallback(keyLogger, 'void', ['pointer', 'pointer']);\n\n   Interceptor.attach(SSL_CTX_new, {\n       onLeave: function(retval) {\n           const ssl = new NativePointer(retval);\n           const SSL_CTX_set_keylog_callbackFn = new NativeFunction(SSL_CTX_set_keylog_callback, 'void', ['pointer', 'pointer']);\n           SSL_CTX_set_keylog_callbackFn(ssl, keyLogCallback);\n       }\n   });\n}\nstartTLSKeyLogger(\n   Module.findExportByName('libssl.so', 'SSL_CTX_new'),\n   Module.findExportByName('libssl.so', 'SSL_CTX_set_keylog_callback')\n)<\/code><\/pre>\n<pre><code>frida -U -l .\\sslkeyfilelog.js  -f cn.damai\uff08\u66ff\u6362\u4e3a\u81ea\u5df1\u7684\u5305\u540d\uff09<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5f00\u59cb\u5728\u6a21\u62df\u5668\u7aef\u6267\u884c\u5404\u79cdAPP\u4e2d\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982\u767b\u5f55\u3001\u641c\u7d22\u7b49\uff0c\u8fd9\u4e9b\u6570\u636e\u5305\u90fd\u4f1a\u88ab\u6293\u53d6\uff0c\u64cd\u4f5c\u5b8c\u6bd5\u540e\uff0c\u5728adb shell\u4e2d\u6309Ctrl c\u5173\u95edtcpdump\u6293\u5305<\/p>\n<\/li>\n<li>\n<p>\u628a\u6b65\u9aa44\u4e2d\u6293\u5230\u7684sslkey\u653e\u5230sslkey.txt\u6587\u4ef6\uff0c\u628a\u6b65\u9aa43\u4e2d\u6293\u5230\u7684damai.pcap\u5bfc\u51fa\u6765<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/image-20241006012353009-300x156.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/image-20241006012501305.png\" alt=\"image-20241006012501305\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/image-20241006012544789.png\" alt=\"image-20241006012544789\" \/><\/p>\n<\/li>\n<li>\n<p>\u7528wireshark\u6253\u5f00damai.pcap\uff0c\u53bbwireshrak\u5bfc\u822a\u680f\u7684\u7f16\u8f91-\u9996\u9009\u9879\u4e2d\u9009TLS\uff0c\u5bfc\u5165sslkey.txt\u5c31\u80fd\u89e3\u5bc6<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ahui.blog\/wp-content\/uploads\/2024\/10\/image-20241006012118696.png\" alt=\"image-20241006012118696\" \/><\/p>\n<\/li>\n<li>\n<p>\u89e3\u5bc6\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u8bf7\u6c42\u5305<\/p>\n<pre><code>#\u8fc7\u6ee4\u6761\u4ef6\nhttp && tcp.dstport==443\n\nhttp && tcp.dstport==443 and !(http.request.uri contains \".webp\" or http.request.uri contains \".jpg\" or http.request.uri contains \".png\" or http.request.uri contains \".jpeg\")<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u5e38\u89c1\u95ee\u9898<\/h3>\n<ul>\n<li>\n<p>\u5982\u679c\u78b0\u5230\u63d0\u793a<code>adb.exe: error: more than one device\/emulator<\/code><\/p>\n<p>\u7b54\uff1a\u5728\u4f7f\u7528adb\u547d\u4ee4\u65f6\u6307\u5b9a-s\uff0c\u4f8b\u5982adb -s 127.0.0.1:5555 shell<\/p>\n<\/li>\n<li>\n<p>\u4e3a\u4ec0\u4e48\u8981\u7aef\u53e3\u8f6c\u53d127042\u548c27043<\/p>\n<p>\u7b54\uff1a<strong>Frida<\/strong>\u662f\u4e00\u4e2a\u7528\u4e8e\u52a8\u6001\u4ee3\u7801\u6ce8\u5165\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5e38\u4f7f\u7528\u7aef\u53e3 27042 \u4e0e\u8bbe\u5907\u901a\u4fe1\u3002\u901a\u8fc7\u7aef\u53e3\u8f6c\u53d1\uff0c\u53ef\u4ee5\u5728\u7535\u8111\u4e0a\u8fd0\u884c\u7684 Frida \u5ba2\u6237\u7aef\u4e0e\u8bbe\u5907\u4e0a\u7684 Frida \u670d\u52a1\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883 Windows10\u4e3b\u673a\u5b89\u88c5adb\u3001frida16.1.4 BlueStacks 5 China\u5b98\u7f51\u6700\u65b0\u7248 &#8230; <a title=\"\u5b89\u5353APP-HTTPS\u6293\u5305Frida Hook\u6559\u7a0b\" class=\"read-more\" href=\"https:\/\/ahui.blog\/index.php\/2024\/10\/06\/app-https-hook\/\" aria-label=\"\u7ee7\u7eed\u9605\u8bfb\u5b89\u5353APP-HTTPS\u6293\u5305Frida Hook\u6559\u7a0b\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,14],"tags":[],"class_list":["post-540","post","type-post","status-publish","format-standard","hentry","category-basic_knowledge","category-safety_research"],"_links":{"self":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/comments?post=540"}],"version-history":[{"count":3,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/540\/revisions"}],"predecessor-version":[{"id":551,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/540\/revisions\/551"}],"wp:attachment":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/media?parent=540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/categories?post=540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/tags?post=540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}