美文网首页
【转载】Android硬核https抓包, 在多个app亲测ok

【转载】Android硬核https抓包, 在多个app亲测ok

作者: jczx | 来源:发表于2021-04-17 10:34 被阅读0次

    前提条件

    一台root手机
    frida环境一套
    还要会搜索(回复比较慢)

    开启抓包

    1.手机中执行tcpdmp

    tcpdump -i any -s 0 -w /sdcord/Download/capture.pcap
    

    2.手机没有tcpdump的可以下载

    https://www.androidtcpdump.com/android-tcpdump/downloads

    adb push tcpdump /data/local/tmp/ (如果遇到权限不够的,先push到sdcard/ 再移动过去)
    

    2.1在手机中执行赋予权限

    chomd 777 tcpdump
    

    2.2继续执行操作

    ./tcpdump -i any -s 0 -w /sdcard/Download/capture.pcap
    

    hook app 拿到sslkey

    frida -U -f package -l ./sslkeyfilelog.js --no-pause
    

    //frida 命令选项 更多关于frida信息 可以查看frida官方信息 https://frida.re/docs/home/

    Options:
      --version             show program's version number and exit
      -h, --help            show this help message and exit
      -D ID, --device=ID    connect to device with the given ID
      -U, --usb             connect to USB device
      -R, --remote          connect to remote frida-server
      -H HOST, --host=HOST  connect to remote frida-server on HOST
      -f FILE, --file=FILE  spawn FILE
      -F, --attach-frontmost
                            attach to frontmost application
      -n NAME, --attach-name=NAME
                            attach to NAME
      -p PID, --attach-pid=PID
                            attach to PID
      --stdio=inherit|pipe  stdio behavior when spawning (defaults to “inherit”)
      --runtime=duk|v8      script runtime to use (defaults to “duk”)
      --debug               enable the Node.js compatible script debugger
      -l SCRIPT, --load=SCRIPT
                            load SCRIPT
      -P PARAMETERS_JSON, --parameters=PARAMETERS_JSON
                            Parameters as JSON, same as Gadget
      -C CMODULE, --cmodule=CMODULE
                            load CMODULE
      -c CODESHARE_URI, --codeshare=CODESHARE_URI
                            load CODESHARE_URI
      -e CODE, --eval=CODE  evaluate CODE
      -q                    quiet mode (no prompt) and quit after -l and -e
      --no-pause            automatically start main thread after startup
      -o LOGFILE, --output=LOGFILE
                            output to log file
      --exit-on-error       exit with code 1 after encountering any exception in
                            the SCRIPT
    
    function startTLSKeyLogger(SSL_CTX_new, SSL_CTX_set_keylog_callback) {
        console.log("start----")
        function keyLogger(ssl, line) {
            console.log(new NativePointer(line).readCString());
        }
        const keyLogCallback = new NativeCallback(keyLogger, 'void', ['pointer', 'pointer']);
    
        Interceptor.attach(SSL_CTX_new, {
            onLeave: function(retval) {
                const ssl = new NativePointer(retval);
                const SSL_CTX_set_keylog_callbackFn = new NativeFunction(SSL_CTX_set_keylog_callback, 'void', ['pointer', 'pointer']);
                SSL_CTX_set_keylog_callbackFn(ssl, keyLogCallback);
            }
        });
    }
    startTLSKeyLogger(
        Module.findExportByName('libssl.so', 'SSL_CTX_new'),
        Module.findExportByName('libssl.so', 'SSL_CTX_set_keylog_callback')
    )
    // https://codeshare.frida.re/@k0nserv/tls-keylogger/
    

    将抓包文件拿到pc

    • 将/sdcard/Download/capture.pcap pull 到pc

    保存frida输出的打印信息到sslkey.txt(还没做到一键傻瓜化)

    //格式是这样的,不要参杂别的

    CLIENT_RANDOM 557e6dc49faec93dddd41d8c55d3a0084c44031f14d66f68e3b7fb53d3f9586d 886de4677511305bfeaee5ffb072652cbfba626af1465d09dc1f29103fd947c997f6f28962189ee809944887413d8a20
    CLIENT_RANDOM e66fb5d6735f0b803426fa88c3692e8b9a1f4dca37956187b22de11f1797e875 65a07797c144ecc86026a44bbc85b5c57873218ce5684dc22d4d4ee9b754eb1961a0789e2086601f5b0441c35d76c448
    CLIENT_RANDOM e1c1dcaaf73a8857ee60f5b38979084c3e95fdebd9791bbab985a8f954132426 41dcf3d5e41cb469494bf5014a1ecca9f40124f5728895265fadd38f8dc9d5ac15c5fa6588c1ea68f38476297fe76183
    CLIENT_RANDOM 66c4f37afb2152e3837c8a7c48ce51e8307e6739e1fe3efc542887bbcae4f02a bbafe4881084570af01bed59f95bfcf7bc49d2e55acbc7fe33c1e06f8ff0bc2e747c2c428e7cd13f1c77c2141085f951
    CLIENT_RANDOM 8d0d92154ee030486a2b13f9441f85ef33c5e06732fbb06a1ac81fe34b6f2ce3 8270b34eee784e7f7de45f39af36f26e6abf99bb52fa8350945e3ebf79dc1c53a0693c24b0780ce3a54d39fd4b5b5149
    CLIENT_RANDOM b5d58899346db525f14312cfb52c1247ed7adb710ae43428bd331ce27d77dbc1 9effd5b469ef6fdf7a056ea50fc3ff0fdf9fa40ae709805bea8678ddce404f211ed534623876a5c616f3e7bc43121f48
    CLIENT_RANDOM af1b3f9ba0b4c27756c93595eb54cac6f0d8c6e9e4f0fcb1a36c45f0cd12060d 696a6fff39bf6c9863901a2145703de948c37e1abf6b4c03628118bee11c292239304ee020c71ff31a293fc6b9439364
    CLIENT_RANDOM e2a3d8e6b638976aa27c8cf031be5e6b03cf7ffa573be101816d5103025d404b 2b006379423d7252c864a129b6c5a693b75d477dc5d3f894af5f02db755c4f6dd54470b659882871c62ce002792e211a
    CLIENT_RANDOM 1c8cfe911e2111d80dc81c275c791c04467e8d7bca16963acec6a20051429981 bf08334d973d44d80c8f4542c2356a5fd9e0d390afde0374179cc81dd82aaa15aae52604988e9c9616ad0795c79c81ed
    

    打开.pcap文件 进入 Wireshark

    //wireshark 快速过滤

    (http.request or tls.handshake.type eq 1) and !(ssdp)
    

    //快速参考

    https://www.jianshu.com/p/5525594600db

    设置Wireshark tls

    • 编辑---首选项---Protocols---TLS


      编辑---首选项
      Protocols
      TLS

    选择到 TLS 后,将之前的sslkey.txt导入。在使用下面的过滤命令,正常情况下,现在就能正常看到了。

    在Wireshark中显示结果

    Wrieshark番外篇

    • 编辑
    • 首选项
    • 外观
    • 布局
      设置完这个,就和上图一样了,界面友好很多。


      布局界面
      界面显示效果

    pc浏览器sslkey番外篇

    //一样要把key导入,不然Wireshark怎么会知道

    chrome.exe --ssl-version-max=tls1.3  --ssl-key-log-file="./ssl_keys.txt"
    

    参考内容:

    Wireshark Tutorial: Display Filter Expressions
    https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/

    HTTPS Traffic Without the Key Log File
    https://unit42.paloaltonetworks.com/wireshark-tutorial-decrypting-https-traffic/

    The First Few Milliseconds of an HTTPS Connection
    http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html

    Sniffing HTTPS Traffic in Chromium with Wireshark
    https://adw0rd.com/2020/12/2/chromium-https-ssl-tls-sniffing-with-wireshark/en/

    转载:https://www.52pojie.cn/thread-1405917-1-1.html

    相关文章

      网友评论

          本文标题:【转载】Android硬核https抓包, 在多个app亲测ok

          本文链接:https://www.haomeiwen.com/subject/mdxylltx.html