ecapture README

项目的 README,来自 github.com/gojue/ecapture。合并为一个 markdown 文件:README.md。

eCapture logo

eCapture (旁观者)
Capture SSL/TLS plaintext with eBPF—no MITM proxy or custom CA installation.

English · 汉字
CodeQL Latest release HomePage

Star History Rank GitHub Trending Repository of the Day

[!IMPORTANT] Supports Linux on x86_64 (kernel 4.18+), aarch64 (kernel 5.5+), and LoongArch64 loong64 (kernel 6.6+). Android supports x86_64 and aarch64 with the existing kernel minimums. Capturing data requires root privileges or specific Linux capabilities. Does not support Windows or macOS.


Introduction

Run ecapture --help to list commands and global options. Use ecapture tls --help or ecapture help tls for TLS options and examples. You can view help as a regular user.

Getting started

Download

ELF binary file

[!TIP] Supports Linux on x86_64, aarch64, and LoongArch64; Android supports x86_64 and aarch64.

Download the ELF binary package from the releases page, extract it, and run:

ecapture --help

Docker image

[!TIP] Linux only.

# Pull the Docker image
docker pull gojue/ecapture:latest

# Run it
docker run --rm --privileged=true --net=host -v ${HOST_PATH}:${CONTAINER_PATH} gojue/ecapture ARGS

⚠️ Security note: --privileged=true grants full host access. For production use, prefer specific capabilities instead. See the Minimum Privileges Guide.

See Docker Hub for more information.

Capture OpenSSL plaintext data

sudo ecapture tls

eCapture automatically detects the system's OpenSSL library and selects a capture interface: it prefers an up Ethernet interface on the lowest-metric IPv4/IPv6 default route, then falls back to interface traffic counters or an up interface. A startup warning names the selected interface and explains how to override it with -i eth0 or --ifname eth0. Only that interface is captured; use -i lo for loopback traffic. Generate an HTTPS request with an OpenSSL-linked client to see the reconstructed request and response. This synthetic HTTP/1.1 example illustrates the text format:

[2026-01-01T12:00:00.000000000Z] http/1.1 request 192.0.2.1:43210 -> 192.0.2.2:443 host="example.com" domain_source="Host" connection="17-4-client/192.0.2.1:43210--192.0.2.2:443/tcp#2"
GET / HTTP/1.1
Host: example.com

📄 For output formats and verification examples, see docs/example-outputs.md.

Modules

Linux builds include all eight modules below. Android builds include tls, gotls, and bash.

You can use ecapture -h to view the full list of subcommands.

OpenSSL module

eCapture searches standard library paths for libssl. Use --libssl to select a specific library.

If the target program is statically linked, you can set the program path directly as the value of the --libssl flag.

The OpenSSL module supports three output modes:

For OpenSSL, GoTLS, and GnuTLS, repeat --output to choose multiple destinations. The default is stdout; explicit destinations replace that default. stdout and stderr render readable records with log_type/module labels. In -m pcapng mode, the terminal shows only operational logs. Files and tcp://host:port use Protobuf v2 JSON Lines. In text mode they carry both operational logs and captured events; in keylog/pcapng mode an output file contains only operational logs, while TCP carries both record types. Use --keylogfile/--pcapfile for native artifacts, with explicit filenames required in the corresponding mode and no default native files.

--stream-listen ws://127.0.0.1:28257/ starts a separate Protobuf v2 subscription listener requiring the ecapture.v2 subprotocol. --config-listen 127.0.0.1:28256 starts the HTTP configuration service. Both listeners are disabled by default. The old --listen, --eventaddr, --logaddr, --ecaptureq and event rotation flags are removed without compatibility aliases. See the output API for the complete mode matrix and receiver migration.

Live decryption for text output

tls, gotls, and gnutls default to the pcapng text source and automatically select a capture interface when -i is omitted. All three accept --text-source hook for function-hook capture. GoTLS still requires --elfpath to identify the target binary.

Use -m text --text-source=pcapng with tls, gotls, or gnutls to reconstruct complete HTTP/1.1 and HTTP/2 messages from the captured network stream. Each message includes direction, timestamp, IP/port tuple, connection identity, and an HTTP/2 stream ID when applicable. host comes from the HTTP Host header or HTTP/2 :authority; domain_source="server_ip" marks a fallback to the server IP. Output goes to --output (stdout by default). Raw pcapng and a standalone keylog are disabled by default; specify --pcapfile or --keylogfile to save either artifact.

sudo ecapture tls -m text --text-source=pcapng -i eth0 --output stdout --output /tmp/http.jsonl 'tcp port 443'
sudo ecapture gotls -m text --text-source=pcapng --elfpath /path/to/go-client -i eth0 --pcapfile /tmp/raw.pcapng 'tcp port 443'
sudo ecapture gnutls -m text --text-source=pcapng --gnutls /path/to/libgnutls.so -i eth0 'tcp port 443'

The decryptor waits for TLS secrets that may appear in a DSB after the corresponding packets. HTTP/3 over QUIC v1/v2 has GoTLS test fixtures; support depends on the TLS backend supplying the required secrets. The following options require text mode with the pcapng source:

Option Output / selection
--text-raw Authenticated TLS/QUIC STREAM bytes and QUIC DATAGRAM messages
--text-http-events Incremental HTTP/1.x, HTTP/2, HTTP/3, SSE and HTTP/2 gRPC events
--text-max-decoded-body N Per-message gzip expansion limit in bytes; requires HTTP events; zero keeps content encoding
--text-protocol dot|doh|doq|mqtt|redis Explicit application parser; MQTT 3.1.1 and fixed-length RESP2/RESP3
--text-tls-upgrade smtp|imap|pop3|ldap|postgres|mysql|connect|https-connect One explicit STARTTLS/SSLRequest/CONNECT negotiation; HTTPS CONNECT includes one inner TLS layer
--text-udp-protocol dtls DTLS 1.2 ECDHE-RSA AES-128/256-GCM records; the default UDP protocol is QUIC

Structured events use lossless hex plus metadata JSON, preserving headers, trailers, message/stream IDs, early-data status and TLS depth, including events with no payload. Stream chunks carry offsets/end markers; datagrams retain message boundaries without invented stream offsets. Application selection is explicit, not automatic ALPN routing. Raw, HTTP-event and explicit application modes are mutually exclusive. HTTP reload uses the corresponding underscore JSON keys; omitted module options reset to their zero defaults. Mail/database upgrades negotiate TLS; use --text-raw for application bytes without a supported parser. gRPC events preserve schema-free Protobuf bytes. Operational logs contain payload-free diagnostics. ECH still requires ECH_SECRET/ECH_CONFIG material that current probes do not capture; upgrading the decryptor alone does not enable live ECH. DTLS/DATAGRAM do not imply WebRTC, WebTransport or MASQUE decoding. With v1.4.0, some zero-length-client-CID QUIC loopback captures still fail connection routing; the maintained DoQ/DATAGRAM baseline uses 8-byte client CIDs.

To verify the source independently, add --pcapfile /tmp/raw.pcapng to the capture command and send a request with a unique path or response token. After stopping eCapture, preload only its embedded secrets with Wireshark >= 4.4 to handle DSBs arriving after their packets, then compare TLS stream 0:

keys=$(mktemp)
editcap --extract-secrets /tmp/raw.pcapng - >"$keys"
tshark -n -r /tmp/raw.pcapng -o "tls.keylog_file:$keys" -q -z follow,tls,ascii,0
rm -f -- "$keys"

The optional file receives the same pcapng bytes as the live SDK stream.

Terminal records and JSON files distinguish operational logs from captured events. JSON and Protobuf share the v2 schema; receivers must preserve TEXT metadata and save native KEYLOG/PCAPNG bytes by format. Subscriptions receive future events; a late pcapng connection starts an independent fragment without historical packets or keys. See the v2 protocol and receiver example.

--output, --keylogfile and --pcapfile also accept FIFOs created with mkfifo -m 600 PATH. Open the reader before starting eCapture. Output remains v2 JSON Lines, raw NSS keylog, or raw pcapng respectively. A missing reader fails immediately; a broken pipe or a write taking over five seconds fails without reconnecting. Native FIFO consumers must handle EOF and keep a reader open across reload.

Pcap mode

Supports TLS-encrypted HTTP 1.0/1.1/2.0 over TCP and HTTP/3 (QUIC) over UDP.

Use -m pcapng (alias -m pcap) with --pcapfile to name the required local capture file. Use -i to override the automatically selected interface.

sudo ecapture tls -m pcap -i eth0 --pcapfile=ecapture.pcapng tcp port 443

This command saves captured network packets and TLS secrets in a pcapng file. Wireshark uses its embedded secrets to decrypt supported TLS traffic.

📄 For pcapng verification, see docs/example-outputs.md.

Keylog mode

You can specify -m keylog or -m key together with the --keylogfile option. --keylogfile must name an explicit local artifact file; there is no default filename.

The captured OpenSSL TLS master secret is saved to --keylogfile. You can also enable tcpdump capture and then open the file in Wireshark, setting the master secret path to view plaintext packets.

sudo ecapture tls -m keylog --keylogfile=openssl_keylog.log

You can also use tshark for real-time decryption and display:

tshark -o tls.keylog_file:openssl_keylog.log -Y http -T fields -e http.file_data -f "port 443" -i eth0

Text mode

sudo ecapture tls -m text

This reconstructs HTTP messages using the default pcapng text source. To capture plaintext bytes from TLS function hooks, use sudo ecapture tls -m text --text-source hook (no interface required).

GoTLS module

Similar to the OpenSSL module.

gotls command

Capture TLS plaintext data.

Step 1:

sudo ecapture gotls --elfpath=/path/to/go-client

Step 2:

/path/to/go-client

More help

ecapture gotls -h

Other modules

Modules such as bash, mysqld, and postgres can also be used. You can view the full list with ecapture -h.

Videos

eCaptureQ GUI application

eCaptureQ is a cross-platform graphical client for eCapture that visualizes eBPF-based TLS capture capabilities. It provides an interface for analyzing encrypted traffic without needing a CA certificate.

It supports two modes:

This eCapture version requires a client with Protobuf v2 support and the ecapture.v2 WebSocket subprotocol. Check the selected client release against the receiver contract; older v1 clients cannot connect without an update.

Event forwarding

Event forwarding projects

Video demonstration

https://github.com/user-attachments/assets/c8b7a84d-58eb-4fdb-9843-f775c97bdbfb

🔗 GitHub repository

Protobuf protocols

For details of the Protobuf log schema used by eCapture/eCaptureQ, see:

Star History

Star History Chart

Security & operations

Contributing

See CONTRIBUTING for details on submitting patches and the contribution workflow.

Compilation

Custom compilation

You can customize the features you want, such as setting the uprobe offset address to support statically linked OpenSSL libraries. Refer to the compilation guide for detailed instructions.

Loong64 releases are cross-built on Ubuntu 24.04 x86_64 with LLVM 22.1.8. Use TARGET_ARCH=loong64; the sysroot, BTF, verification steps, and current runtime validation limits are documented in Loong64 build and validation.

Remote configuration updates

After eCapture is running, you can dynamically modify configurations through HTTP interfaces. Refer to the HTTP API documentation.

Event forwarding

eCapture supports multiple event-forwarding methods. You can forward events to packet capture software such as Burp Suite. For details, refer to the Event Forwarding API documentation.

ecapture (gojue/ecapture)

正在搜索数据库…

这是什么东西?一个开源的命令行安全工具,利用 eBPF 直接捕获 SSL/TLS 流量的明文内容,无需安装 CA 证书,也不用 MITM 代理。它还能审计主机上的 shell 命令和数据库查询。
它是加到我代码里的库,还是一个独立的工具?是一个独立的命令行工具,用 sudo 在你想监控的机器上运行,不是库。另外还有一个独立的跨平台图形界面客户端 eCaptureQ,用 Rust、Tauri 和 React 开发。
怎么把它跑起来?从 GitHub Releases 下载对应架构的 ELF zip 包,解压后运行 'sudo ecapture --help'。在 Linux 上也可以使用 Docker 镜像;工具会自动检测系统的 OpenSSL 库,然后开始捕获明文。
运行它需要 root 权限或什么证书吗?需要 root 权限——要么是 ROOT 权限,要么是特定的 Linux capabilities,文档里有一份最小权限指南介绍最低权限的配置方式。不需要安装任何证书:开箱即支持 OpenSSL、LibreSSL、BoringSSL、GnuTLS、NSS/NSPR 和 Go 的 TLS 库。
上手前有哪些最大的坑?不支持 Windows 和 macOS,Docker 镜像只能在 Linux 上运行——它以特权模式运行,README 里特别标注了这一安全提示。对于静态编译链接 OpenSSL 的程序,需要通过 --libssl 参数传入二进制文件路径。
它能在哪些系统上运行?Linux 和 Android,支持 x86_64(内核 4.18 或更新)和 aarch64/arm64(内核 5.5 或更新);不同 CPU 架构对内核版本的要求不一样。
除了 HTTPS 流量,它还能抓什么?总共有八个模块。除了各种 TLS 库(OpenSSL、GnuTLS、NSS、Go TLS)之外,它还能出于主机安全审计的目的记录 bash 和 zsh 命令,并捕获 mysqld 5.6/5.7/8.0、MariaDB 以及 PostgreSQL 10+ 的 SQL 查询。
抓到的数据怎么导出?OpenSSL 模块有三种模式:text 模式把明文输出到终端或文件;pcap/pcapng 模式保存 pcapng 文件,可以用 Wireshark 打开(支持 HTTP/1.x、基于 TCP 的 HTTP/2 和基于 UDP 的 HTTP/3 QUIC);keylog 模式写出 TLS 主密钥,供 Wireshark 或 tshark 解密用。事件还可以转发给 Burp Suite 之类的工具。
有图形界面吗,还是只能在终端里用?有一个叫 eCaptureQ 的跨平台图形界面客户端,用 Rust + Tauri + React 编写。集成模式运行在 Linux/Android 上,远程模式则让 Windows、macOS 或 Linux 客户端连接到别处运行的 eCapture 服务。
不用 CA 证书它是怎么解密 TLS 的?它不去拦截网络流量,而是通过 eBPF uprobes 挂到目标进程内部的 SSL/TLS 库函数上,直接读取明文和 TLS 密钥,所以不存在需要客户端信任的证书。uprobe 偏移量还可以手动设置,以支持静态编译的 OpenSSL。
有哪些类似的项目?kubeshark, brook, openssl, cilium, scapy, openvpn, smartdns, portmaster
作者
gojue
大小
18 MB
星标
15.6K
时长
4年
提交 · 90 天