<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by CFC4N on Medium]]></title>
        <description><![CDATA[Stories by CFC4N on Medium]]></description>
        <link>https://medium.com/@cfc4ncs?source=rss-7dd042ef6b05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MrVB60CmVL8eB9mF</url>
            <title>Stories by CFC4N on Medium</title>
            <link>https://medium.com/@cfc4ncs?source=rss-7dd042ef6b05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 01:11:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cfc4ncs/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[eCapture v1.0.0 released , Capturing SSL/TLS plaintext without a CA certificate using eBPF.]]></title>
            <link>https://medium.com/@cfc4ncs/ecapture-v1-0-0-released-capturing-ssl-tls-plaintext-without-a-ca-certificate-using-ebpf-cc25f11dcf02?source=rss-7dd042ef6b05------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc25f11dcf02</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[mitmproxy]]></category>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[CFC4N]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 07:55:54 GMT</pubDate>
            <atom:updated>2025-03-25T07:55:54.996Z</atom:updated>
            <content:encoded><![CDATA[<h3>eCapture v1.0.0 released , Capturing SSL/TLS plaintext without a CA certificate using eBPF.</h3><h3>🚀 eCapture Features Overview</h3><p>eCapture is a powerful network traffic capture and decryption tool focusing on TLS/SSL protocol transparency and analysis. It supports multiple protocols and architectures, providing efficient and flexible capture and decryption capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YAoK4bbRKx-4_kLfRKb-PA.png" /></figure><h3>Core Features</h3><ol><li><strong>Multi-Protocol Support</strong></li></ol><ul><li>Supports TLS, gnutls, nss, openssl, and other encryption protocols, compatible with different versions of SSL/TLS implementations.</li></ul><ol><li><strong>Smart Packet Capture</strong></li></ol><ul><li>Based on eBPF technology, enabling efficient network data capture and protocol parsing. Supports IPv4, IPv6 dual-stack and 4-tuple filtering.</li></ul><ol><li><strong>Master Key Capture</strong></li></ol><ul><li>Supports TLS 1.2 and 1.3 protocol master key capture. Integrates with Wireshark for decryption, allowing direct viewing of encrypted traffic in plain text.</li></ul><ol><li><strong>Modular Architecture</strong></li></ol><ul><li>Modular design allows for easy extension and flexible configuration of different protocol modules.</li></ul><ol><li><strong>Cross-Platform Support</strong></li></ol><ul><li>Supports Linux, Android, and other platforms, compatible with ARM64 and x86 architectures, adapting to different environments.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiDcl-Ac0fZ8O7XjfbgTbw.gif" /></figure><h3>Features</h3><ul><li><strong>Automation</strong> Automatically detects SSL/TLS library versions, intelligently identifies CO-RE and non-CO-RE modes, optimizes memory usage.</li><li><strong>Flexible Configuration</strong> Supports custom filters, log files, decryption modes (keylog, pcap, text), and multiple output formats.</li><li><strong>High Performance</strong> High-efficiency data processing based on eBPF, supports large-scale concurrent captures and long-term packet capturing.</li><li><strong>Strong Compatibility</strong> Supports multiple SSL/TLS library versions, including openssl 1.1.1, 3.0.x, boringssl, etc.</li><li><strong>Extensibility</strong> Provides Wireshark plugin support for easy data analysis and visualization.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5peHwe4yFNF4Rim_DyxaTA.jpeg" /></figure><h3>Technical Advantages</h3><ul><li><strong>eBPF Engine</strong> Utilizes advanced eBPF technology to improve capture and decryption efficiency, reducing system resource usage.</li><li><strong>Modular Architecture</strong> Core functionality is modularized for easy extension and maintenance.</li><li><strong>Intelligence</strong> Automatically detects the runtime environment and intelligently adapts to different protocols and architectures.</li></ul><h3>Application Scenarios</h3><ol><li><strong>Network Debugging</strong> Real-time capture and decryption of TLS/SSL traffic to assist in development and debugging.</li><li><strong>Security Analysis</strong> Analyze encrypted communications to identify potential security vulnerabilities.</li><li><strong>Protocol Research</strong> Study TLS/SSL protocol implementations and analyze traffic characteristics.</li><li><strong>Monitoring and Auditing</strong> Monitor network communications, record, and audit sensitive operations.</li></ol><h3>Links</h3><ol><li><a href="https://ecapture.cc/">eCapture旁观者</a></li><li><a href="https://github.com/gojue/ecapture">eCapture Github</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc25f11dcf02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eCapture:supports capturing plaintext of Golang TLS/HTTPS traffic]]></title>
            <link>https://medium.com/@cfc4ncs/ecapture-supports-capturing-plaintext-of-golang-tls-https-traffic-f16874048269?source=rss-7dd042ef6b05------2</link>
            <guid isPermaLink="false">https://medium.com/p/f16874048269</guid>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[tcpdump]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[CFC4N]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 13:13:44 GMT</pubDate>
            <atom:updated>2023-03-15T13:13:44.203Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In the cloud-native ecosystem, more and more projects are being developed using the Go programming language, such as Docker, K8s, and etcd. As an SRE or RD, it is sometimes necessary to capture network packets in a production environment for troubleshooting analysis.</p><p>Often, the communication protocol is encrypted with TLS/HTTPS. How can we analyze the plaintext communication content without restarting the service or changing to a custom CA certificate?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/0*W6r5zYdSuygL6TuP.jpg" /></figure><h3>Use cases</h3><p><a href="https://github.com/gojue/ecapture/releases/tag/v0.5.0">eCapture version 0.5.0</a> was released on March 12, 2023, supporting plaintext capture of TLS/HTTPS for software written in Go. With root privileges, packets can be captured and saved in pcapng format, which can be opened and viewed using Wireshark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JjGRXXYc55lAGKPO.png" /></figure><h3>Usage</h3><p>The e parameter in the gotls module is used to set the path of the Go-compiled executable file. Usage instructions can be viewed with ecapture gotls -h.</p><pre>bin/ecapture gotls -h<br>NAME:<br>  gotls - capture golang tls/https text content without CA cert for ELF compile by Golang toolchain<br>​<br>USAGE:<br>  ecapture gotls [flags]<br>​<br>DESCRIPTION:<br>  use eBPF uprobe/TC to capture process event data and network data. also support pcap-NG format.<br>  ecapture gotls<br>  ecapture gotls --elfpath=/home/cfc4n/go_https_client --hex --pid=3423<br>  ecapture gotls --elfpath=/home/cfc4n/go_https_client -l save.log --pid=3423<br>  ecapture gotls -w save_android.pcapng -i wlan0 --port 443 --elfpath=/home/cfc4n/go_https_client<br>​<br>OPTIONS:<br>  -e, --elfpath=&quot;&quot;  ELF path to binary built with Go toolchain.<br>  -h, --help[=false]  help for gotls<br>  -i, --ifname=&quot;&quot; (TC Classifier) Interface name on which the probe will be attached.<br>      --port=443  port number to capture, default:443.<br>  -w, --write=&quot;&quot;  write the  raw packets to file as pcapng format.<br>​<br>GLOBAL OPTIONS:<br>  -d, --debug[=false]   enable debug logging<br>      --hex[=false]   print byte strings as hex encoded strings<br>  -l, --log-file=&quot;&quot;   -l save the packets to file<br>      --nosearch[=false]  no lib search<br>  -p, --pid=0     if pid is 0 then we target all pids<br>  -u, --uid=0     if uid is 0 then we target all users</pre><p><strong>For example</strong> /path/elf_filepath_compiled_by_go is a web service written in Go that has enabled HTTPS encryption, and the code is as follows:</p><pre>package main<br>​<br>import (<br>  &quot;crypto/tls&quot;<br>  &quot;fmt&quot;<br>  &quot;io&quot;<br>  &quot;net/http&quot;<br>  &quot;os&quot;<br>)<br>​<br>func main() {<br>​<br>  b, e := GetHttp(&quot;https://github.com&quot;)<br>  if e == nil {<br>    fmt.Printf(&quot;response body: %s\n\n&quot;, b)<br>  } else {<br>    fmt.Printf(&quot;error :%v&quot;, e)<br>  }<br>}<br>​<br>func GetHttp(url string) (body []byte, err error) {<br>  // <br>  f, err := os.OpenFile(&quot;/tmp/go_master_secret.log&quot;, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)<br>  if err != nil {<br>    panic(err)<br>  }<br>  defer f.Close()<br>  c := &amp;http.Client{<br>    Transport: &amp;http.Transport{<br>      TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true, KeyLogWriter: f},<br>    }}<br>  resp, e := c.Get(url)<br>  if e != nil {<br>    return nil, e<br>  }<br>​<br>  defer resp.Body.Close()<br>  body, err = io.ReadAll(resp.Body)<br>  return body, err<br>}</pre><p>The plaintext communication can be captured using the following command. You don’t need to restart the service process or do any other configuration, just like using tcpdump.</p><pre>./ecapture gotls -e=/path/elf_filepath_compiled_by_go -w a.pcapng -i eth0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BkCanBnADZ63koLz.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xV8ndwTdUuAEPgAP.png" /></figure><p><strong>Wireshark</strong></p><h3>Download</h3><p>eCapture Github repo：<a href="https://github.com/gojue/ecapture/releases/tag/v0.5.0">https://github.com/gojue/ecapture/releases/tag/v0.5.0</a></p><h3>TL;DR</h3><h3>How it works</h3><h4>Probe Parameter Retrieval</h4><p>Golang has a different ABI mechanism than C and has a custom ABI mechanism. Before go 1.17, it used a stack-based method to pass call parameters, while 1.17 and later versions used a register-based method. You can read the <a href="https://go.googlesource.com/proposal/+/refs/changes/78/248178/1/design/40724-register-calling.md">Register-based Go calling convention</a> for more information.</p><p>Here is a diagram of Golang’s register-based layout for passing function parameters and return values, which can be used as a reference. For more information, you can read the <a href="https://chai2010.cn/advanced-go-programming-book/ch3-asm/ch3-04-func.html">Advanced Go Programming</a> book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*iGiv-Jvf68TcZuBT.png" /></figure><p>For the implementation of parameter retrieval in eCapture, you can read <a href="https://github.com/gojue/ecapture/blob/master/kern/go_argument.h">kern/go_argument.h</a>.</p><h4>Probe params</h4><p>In this case, the function writeKeyLog in the file crypto/tls/common.go in the Golang source directory is hooked to capture the label type, client random, and key values of the TLS master secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ghjkTbZD7J59qbCU.png" /></figure><p><strong>param call in Golang function</strong></p><p>It’s important to note that in Golang, both string and slice types are represented as structs when passed as function parameters.</p><pre>// runtime/string.go<br>type stringStruct struct {<br>  str unsafe.Pointer<br>  len int<br>}<br>​<br>// runtime/slice.go<br>type slice struct {<br>  array unsafe.Pointer<br>  len   int<br>  cap   int<br>}<br>​</pre><p>For example, when passing a string parameter in Golang, not only the str unsafe.Pointer pointer address is passed, but also the len int is passed to the register. Therefore, when retrieving the parameters, you need to pay attention to their positions.</p><p>The implementation of eCapture handles this as follows:</p><pre>lab_ptr = (void *)go_get_argument(ctx, is_register_abi, 2);<br>lab_len_ptr = (void *)go_get_argument(ctx, is_register_abi, 3);<br>cr_ptr = (void *)go_get_argument(ctx, is_register_abi, 4);<br>cr_len_ptr = (void *)go_get_argument(ctx, is_register_abi, 5);<br>secret_ptr = (void *)go_get_argument(ctx, is_register_abi, 7);<br>secret_len_ptr = (void *)go_get_argument(ctx, is_register_abi, 8);<br>bpf_probe_read_kernel(&amp;lab_len, sizeof(lab_len), (void *)&amp;lab_len_ptr);<br>bpf_probe_read_kernel(&amp;cr_len, sizeof(lab_len), (void *)&amp;cr_len_ptr);<br>bpf_probe_read_kernel(&amp;secret_len, sizeof(lab_len), (void *)&amp;secret_len_ptr);</pre><p><strong>Golang uretprobe</strong></p><p>In eCapture’s text mode, it is necessary to obtain plaintext before encryption and after decryption, which corresponds to two functions, crypto/tls.(*Conn).writeRecordLocked and crypto/tls.(*Conn).Read, respectively. Obtaining plaintext before encryption only requires the use of an eBPF uprobe hook. However, after decryption, a uretprobe is needed, but in Golang, the implementation mechanism of uretprobe will destroy its stack and cause the Golang program process to crash.</p><p>This problem has also been discussed in the iovisor/bcc community, including flame graphs and eBPF leader Brendan Gregg, but there is no good solution to this problem. Gianluca Borello has provided an indirect solution, which is relatively cumbersome and has a certain risk of crashing. Interested readers can go and take a look.</p><p>In eCapture, the uprobe before encryption has been completed to capture plaintext in HTTPS/TLS requests. However, capturing the content after decryption is currently not possible. The author is also trying other approaches, such as finding the calling function of the Read return value and using an uprobe there, but this logic is more business-oriented, with many callers and is not easy to filter. If you have a better solution, please feel free to propose it.</p><h3>Resources</h3><p><a href="https://metalbear.co/blog/hooking-go-from-rust-hitchhikers-guide-to-the-go-laxy/">Hooking Go from Rust — Hitchhiker’s Guide to the Go-laxy</a></p><p><a href="https://github.com/iovisor/bcc/issues/1320">BCC issue: Go crash with uretprobe #1320</a></p><p><a href="https://eli.thegreenplace.net/2022/interface-method-calls-with-the-go-register-abi/">Interface method calls with the Go register ABI</a></p><p><a href="https://ecapture.cc/">eCapture HomePage</a></p><p><a href="https://github.com/gojue/ecapture">eCapture旁观者 Github Repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f16874048269" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eCapture: capture HTTPS traffic without CA certificates on Android/Linux]]></title>
            <link>https://medium.com/@cfc4ncs/ecapture-capture-https-traffic-without-ca-certificates-on-android-linux-a1f6f6ab782b?source=rss-7dd042ef6b05------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1f6f6ab782b</guid>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[tcpdump]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[CFC4N]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 12:07:47 GMT</pubDate>
            <atom:updated>2023-02-10T12:14:41.384Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Beginning</h3><p>Capturing HTTPS packets on Android is getting tricky these days. There are too many things we need to do before we start capturing, like setting certificates, proxies, and hooks, which the APP itself may detect. Is there a better way to solve this problem?</p><p>The answer is YES. <a href="https://ecapture.cc/">eCapture for Android</a> can help you capture HTTPS packets on Android without the trivial settings. and also support Linux Kernel.</p><h3>eCapture Introduction</h3><p>eCapture is a tool for capturing HTTPS plaintext packets without any CA certificate based on eBPF and requires root privileges. And pcapng format is also supported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*25U-e3LkIvTtYETM.png" /></figure><p>In early 2022, I started working on <a href="https://www.cnxct.com/what-is-ecapture/">eCapture</a>, which is now over 5600 stars.</p><p>eCapture is based on eBPF, so the minimum kernel version it requires is 4.18 on X86_64\ARM64 arch Linux, and 5.5 on ARM64 Android(Linux). The lastest version is v0.4.11</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z7qJwf9epXM3Uuf5.png" /></figure><h3>Demo Video</h3><p>Download the release, and run with the following command</p><pre>./ecapture tls -w ecapture.pcapng</pre><p>The envs in following vedio: Ubuntu 21.04 / Android 5.5 (Pixel 6)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGTsm1d29FSQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGTsm1d29FSQ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f4d92171c031cea04b31830b88dfd5e/href">https://medium.com/media/0f4d92171c031cea04b31830b88dfd5e/href</a></iframe><h3>Features</h3><p>eCapture supports capturing tls, bash, mysqld, postgres, etc. In this introduction, we will focus on capturing plaintext in HTTPS/TLS.</p><h3>Capture encrypted communication plaintext with — tls module</h3><p>tls supports openssl, gnutls, nspr/nss, boringssl and so on. The only difference is that pcapng module only supports boringssl on Android.</p><h3>How to use eCapture</h3><h3>Environment</h3><ol><li>Kernel version: Linux/Android x86_64 kernel &gt;= 4.18, Linux/Android aarch64 kernel &gt;= 5.5</li><li>BPF supported, BTF for optional</li><li>Root privileges</li></ol><h3>Version Choice</h3><p>BPF <a href="https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html">CO-RE</a> is a feature for eBPF program running across different kernel versions with BTF. CONFIG_DEBUG_INFO_BTF=y means BTF is supported while n is not. Check this config by the following command:</p><pre>cfc4n@vm-server:~$# cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF​<br>CONFIG_DEBUG_INFO_BTF=y</pre><p>On Android, the config is gzip compressed. Use zcat /proc/config.gz to check instead.</p><p>A CO-RE supported ELF is released by default, and also a non CO-RE version with kernel 5.5 on Android. Check the version by command ecapture -v</p><pre># no CO-RE<br>eCapture version: linux_aarch64:0.4.2-20220906-fb34467:5.4.0-104-generic<br># CO-RE<br>eCapture version: linux_aarch64:0.4.2-20220906-fb34467:[CORE]</pre><p>If the version does not meet your needs, you can compile it yourself. For the steps, see the end of the article.</p><h3>Global flags introduction</h3><pre>root@vm-server:/home/cfc4n/# ecapture -h<br>--hex[=false] print byte strings as hex encoded strings<br>-l, --log-file=&quot;&quot; -l save the packets to file<br>-p, --pid=0 if pid is 0 then we target all pids<br>-u, --uid=0 if uid is 0 then we target all users<br>--hex Stdout with hex encoding, useful for non-ASCII output</pre><ol><li>-l, --log-file= File path to save results</li><li>-p, --pid=0 The target process to capture, the default is 0, which captures all processes</li><li>-u, --uid=0 The target user id to capture, the default is 0, which captures all user ids</li></ol><h3>Module flags introduction</h3><pre>root@vm-server:/home/cfc4n/project/ssldump# bin/ecapture tls -h<br><br>OPTIONS:<br><br>--curl=&quot;&quot; curl or wget file path, use to dectet openssl.so path, default:/usr/bin/curl<br><br>--firefox=&quot;&quot; firefox file path, default: /usr/lib/firefox/firefox.<br><br>--gnutls=&quot;&quot; libgnutls.so file path, will automatically find it from curl default.<br><br>--gobin=&quot;&quot; path to binary built with Go toolchain.<br><br>-h, --help[=false] help for tls<br><br>-i, --ifname=&quot;&quot; (TC Classifier) Interface name on which the probe will be attached.<br><br>--libssl=&quot;&quot; libssl.so file path, will automatically find it from curl default.<br><br>--nspr=&quot;&quot; libnspr44.so file path, will automatically find it from curl default.<br><br>--port=443 port number to capture, default:443.<br><br>--pthread=&quot;&quot; libpthread.so file path, use to hook connect to capture socket FD.will automatically find it from curl.<br><br>--wget=&quot;&quot; wget file path, default: /usr/bin/wget.<br><br>-w, --write=&quot;&quot; write the raw packets to file as pcapng format.</pre><h4>-i flag</h4><p>-i specifies the name of network interface. Defaults to eth0 on Linux, wlan0 on Android.</p><h3>Output mode</h3><p>Two output formats are supported: text and pcapng.</p><ol><li>As default, it outputs to stdout.</li><li>-l global flag, specify the path to save results.</li><li>-w only supports in tls module, save pcapng file to the path.</li></ol><h3>Library path</h3><p>There are several libraries in Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZm9vDSqga66mZ0IhNGkgw.png" /></figure><h3>Text mode</h3><p>Use -l or without -w flag will activate this mode</p><ol><li>Support openssl, boringssl, gnutls, nspr/nss, and some other TLS encryption libraries</li><li>Support DTLS, TLS1.0 to TLS1.3</li><li>Support use -p, -u, and other global flags to filter</li></ol><h3>pcapng mode</h3><p>Activate this mode by setting -w and use -i to specify the network interface. Defaults to eth0 on Linux, wlan0 on Android.</p><p>Support TLS 1.1/1.2/1.3 over openssl and boringssl.</p><h3>Library path &amp; flag</h3><p>In Linux, the library paths and flags are supported, while some are not in Android due to the kernel version and arch.</p><h4>Flag support for different modes</h4><p>-p, -u is not supported for pcapng mode, which is implemented by eBPF TC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nVD8Ufr_0SHV4Yi-.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6l2UV3qy5fvdF0C_fVJFEQ.png" /></figure><h4>Library &amp; protocol support for diffrent modes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4WmltmXheYIRpfYzVRwWA.png" /></figure><p>For now, pcapng mode was also support TLS 1.3.</p><h3>Use with tcpdump</h3><p>eCapture implements the feature of saving a pcapng file by eBPF TC, and supports TLS Master Secret Key capturing by eBPF Uprobe. Also, <a href="https://github.com/google/gopacket/pull/1042">gopacket’s DSB feature</a> is supported, based on <a href="https://github.com/pcapng/pcapng/pull/54">Decryption Secrets Block (DSB)</a></p><p>You can use eCapture to get the master secrets, tcpdump to get the packets, and Wireshark to customize the key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5Ek8nSqNR3bEekKs.jpg" /></figure><h4>Capture the traffic</h4><p>see tcpdump --help</p><h4>Capture the masterkey</h4><p>Use eCapture with either text or pcapng mode, and the TLS master secret key will be recorded in ecapture_masterkey.log</p><h4>Get the plaintext</h4><p>Open the traffic file with Wireshark, set the master key, and plaintext will be there.</p><pre>Wireshark` --&gt; `Preferences` --&gt; `Protocols` --&gt; `TLS` --&gt; `(Pre)-Master-Secret log filename</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qpCtEWT_bBXajZSv.jpg" /></figure><h3>Flags</h3><h3>Specify the path</h3><h4>Default</h4><p>On Android, Google uses the boringssl, which is the wrapper of the C++ language on the basis of libssl. The path is /apex/com.android.conscrypt/lib64/libssl.so as default.</p><h4>App library path</h4><p>Use lsof -p {APP PID}|grep libssl to get the path of the APP&#39;s library path. Use --libssl to specify the path if it is not a default path.</p><h3>Advanced usage</h3><p>If the APP uses a custom SSL library, you can modify eCapture to implement it.</p><h3>Function name &amp; Offset</h3><p>Firstly, check the function name or symbol table address of the HOOK function.</p><h4>Without source code</h4><p>Use IDA or other static/dynamic analysis software to get the offset of SSL Write, and fill the configuration in probe_openssl.go.</p><pre>{<br><br>Section: &quot;uprobe/SSL_write&quot;,<br><br>EbpfFuncName: &quot;probe_entry_SSL_write&quot;,<br><br>AttachToFuncName: &quot;SSL_write&quot;,<br><br>UprobeOffset: 0xFFFF00, // TODO<br><br>BinaryPath: binaryPath,<br><br>},</pre><h4>offset with automatically calc</h4><p>If you have the source code, read the code and get the function name or the symbol table address. For the reading of member properties of a structure, use offsetof macro to get it automatically.</p><p>for example, Generate offsets for openssl 3.0 and boringssl</p><pre>bash utils/openssl_offset_3.0.sh<br>bash utils/boringssl_offset_1.1.1.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZbCeJTqRVsE3kj3e.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*woQ_pwgkUTKPwV2B.jpg" /></figure><h3>Parameters to extract</h3><p>For parameters, you need to confirm the parameter type of the HOOK function in order to confirm the reading method. You can refer to the implementation of the SSL_write function in kern/openssl_kern.c</p><h3>Compile</h3><h3>ARM64 Linux</h3><p>For convenience, you can get an ARM64 environment in some cloud services like Tencent Cloud. For example, in ubuntu 20.04 arm64</p><pre>ubuntu@VM-0-5-ubuntu:~$sudo apt-get update<br><br>ubuntu@VM-0-5-ubuntu:~$sudo apt-get install --yes wget git golang build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common<br><br>ubuntu@VM-0-5-ubuntu:~$wget https://golang.google.cn/dl/go1.18.linux-arm64.tar.gz<br><br>ubuntu@VM-0-5-ubuntu:~$sudo rm -rf /usr/local/go &amp;&amp; sudo tar -C /usr/local -xzf go1.18.linux-arm64.tar.gz<br><br>ubuntu@VM-0-5-ubuntu:~$for tool in &quot;clang&quot; &quot;llc&quot; &quot;llvm-strip&quot;<br><br>do<br><br>sudo rm -f /usr/bin/$tool<br><br>sudo ln -s /usr/bin/$tool-12 /usr/bin/$tool<br><br>done<br><br>ubuntu@VM-0-5-ubuntu:~$export GOPROXY=https://goproxy.cn<br><br>ubuntu@VM-0-5-ubuntu:~$export PATH=$PATH:/usr/local/go/binOptions</pre><ol><li>ANDROID=1 make compile with CORE</li><li>ANDROID=1 make nocore compile with kernel version related</li></ol><h3>Contributing</h3><p>See <a href="https://github.com/gojue/ecapture/blob/master/CONTRIBUTING.md">CONTRIBUTING</a> for details on submitting patches and the contribution workflow.</p><p>Github: <a href="https://github.com/gojue/ecapture">https://github.com/gojue/ecapture</a></p><p>Homepage: <a href="https://ecapture.cc/">https://ecapture.cc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1f6f6ab782b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>