自上篇文章〔L4LB四层负载均衡IP伪造漏洞〕以来,已经快四五个月没更新,不是笔者太懒,而是实在太忙了,忙得连放屁的时间都没有。得益于社区朋友的贡献,增加了一些新特性,今天来分享给大家。
eCapture旁观者[1]是一个无需CA证书,无侵入的HTTPS/TLS明文抓包工具。可以在Linux 4.18以上版本使用,同时也支持Android arm64 5.5以上版本。项目发布三年累计14000颗星。
eCapture 有8个模块,分别支持openssl/gnutls/nspr/boringssl/gotls等类库的TLS/SSL加密类库的明文捕获、Bash、Mysql、PostGres软件审计。
你可以通过ecapture -h
来查看这些自命令列表。
gnutls
模块的keylog
和pcap
模式对Gnutls TLS[2]类库的密钥捕获、pcapNG
格式文件存储;-m text
下,HTTP 2.0
的内容解码;在eCapture的gnutls模块中,新增TLS加密通讯的密钥捕获,以及保存为pcapNG
格式文件。
以使用gnutls类库的git
命令为例,当执行git pull
时,会调用git-remote-http
程序来访问远程仓库,该程序使用Gnutls类库
ldd /usr/lib/git-core/git-remote-http
linux-vdso.so.1 (0x0000ffff9c6ff000)
libcurl-gnutls.so.4 => /lib/aarch64-linux-gnu/libcurl-gnutls.so.4 (0x0000ffff9c550000)
libpcre2-8.so.0 => /lib/aarch64-linux-gnu/libpcre2-8.so.0 (0x0000ffff9c4b0000)
...
完整演示如下:
首先,在终端中启动ecapture
sudo ecapture gnutls -m pcapng -i ens160 -w gnutls-github.pcapng tcp port 443
之后,在另外一个终端拉取git仓库
git pull
eCapture的结果输出:
sudo ecapture gnutls -m pcapng -i ens160 -w gnutls-github.pcapng tcp port 443
2024-12-15T13:31:38Z INF AppName="eCapture(旁观者)"
2024-12-15T13:31:38Z INF HomePage=https://ecapture.cc
2024-12-15T13:31:38Z INF Repository=https://github.com/gojue/ecapture
2024-12-15T13:31:38Z INF Author="CFC4N <[email protected]>"
2024-12-15T13:31:38Z INF Description="Capturing SSL/TLS plaintext without a CA certificate using eBPF. Supported on Linux/Android kernels for amd64/arm64."
2024-12-15T13:31:38Z INF Version=linux_arm64:v0.9.0:6.5.0-1025-azure
2024-12-15T13:31:38Z INF Listen=localhost:28256
2024-12-15T13:31:38Z INF eCapture running logs logger=
2024-12-15T13:31:38Z INF the file handler that receives the captured event eventCollector=
2024-12-15T13:31:38Z INF listen=localhost:28256
2024-12-15T13:31:38Z INF https server starting...You can upgrade the configuration file via the HTTP interface.
2024-12-15T13:31:38Z INF Kernel Info=5.15.167 Pid=150461
2024-12-15T13:31:38Z INF BTF bytecode mode: CORE. btfMode=0
2024-12-15T13:31:38Z INF GnuTlsProbe init eBPFProgramType=PcapNG model=PcapNG
2024-12-15T13:31:38Z INF module initialization. isReload=false moduleName=EBPFProbeGNUTLS
2024-12-15T13:31:38Z INF Module.Run()
2024-12-15T13:31:38Z INF GnuTLS version found Version=3.7.3
2024-12-15T13:31:38Z INF GnuTLS binary path binaryPath=/lib/aarch64-linux-gnu/libgnutls.so.30 elfType=2
2024-12-15T13:31:38Z INF BPF bytecode loaded bytecode filename=user/bytecode/gnutls_3_7_3_kern_core.o
2024-12-15T13:31:38Z INF Hook type: Gnutls elf ElfType=2 IFindex=2 IFname=ens160 PcapFilter="tcp port 443" binrayPath=/lib/aarch64-linux-gnu/libgnutls.so.30
2024-12-15T13:31:38Z INF Hook masterKey function: gnutls_handshake
2024-12-15T13:31:38Z INF target all process.
2024-12-15T13:31:38Z INF packets saved into pcapng file. pcapng path=/home/cfc4n/gnutls-github.pcapng
2024-12-15T13:31:39Z INF perfEventReader created mapSize(MB)=4
2024-12-15T13:31:39Z INF perfEventReader created mapSize(MB)=4
2024-12-15T13:31:39Z INF module started successfully. isReload=false moduleName=EBPFProbeGNUTLS
2024-12-15T13:31:43Z INF CLIENT_RANDOM save success ClientRandom=8517a6741b2a67369079309c2eac84094aacecef39a5514c6da25da7e219401d TlsVersion=GNUTLS_TLS1_3 eBPFProgramType=PcapNG
2024-12-15T13:31:44Z INF packets saved into pcapng file. count=35
2024-12-15T13:31:46Z INF packets saved into pcapng file. count=2
^C2024-12-15T13:32:15Z INF packets saved into pcapng file. count=37
2024-12-15T13:32:15Z INF Module closed,message recived from Context
2024-12-15T13:32:15Z INF iModule module close
2024-12-15T13:32:15Z INF bye bye.
可以清楚得看到TLS通讯协议是GNUTLS_TLS1_3
,密钥的ClientRandom是8517a6741b2a67369079309c2eac84094aacecef39a5514c6da25da7e219401d
。
Wirehark查看网络包
如图,不光能看到网络包对应发起的进程信息,还能看到HTTPS的明文内容。
eCapture的Docker Hub仓库地址为:https://hub.docker.com/r/gojue/ecapture[5] ,当前最新版为 v0.9.0 。
# 拉取镜像
docker pull gojue/ecapture:latest
# 运行
docker run --rm --privileged=true --net=host -v ${宿主机文件路径}:${容器内路径} gojue/ecapture ARGS
启动命令sudo ecapture zsh
,即可捕获zsh上运行的所有命令,对于安全审计场景,还是比较方便快捷的。
其他更多功能,请查看项目变更日志。
hashLen
不允许超过 64 字节ecapture Docker
镜像CVE-2024-24790[6]incoming chan is full
并退出rs/zerolog
-tags 'netgo'
以避免由于不同 Linux 发行版中的 glibc 版本不同而导致的 SIGSEGVclientRandom
字符串kprobe/__sys_connect
替代uprobe/connect
_core/_noncore
后附加rpmBuild.spec
中移除未使用的标志BuildRequires
golang.org/x/crypto
从 0.23.0 升级到 0.31.0感谢社区小伙伴的贡献:Leon Hwang[7]、SenberHu[8]、yuweizzz[9]、sancppp[10]、Nadeshiko Manju[11]、行旅途[12]、w568w[13] 等,一起继续为爱发电。
eCapture旁观者:https://ecapture.cc
[2]Gnutls TLS:https://gnutls.org/
[3]Zsh Shell:https://www.zsh.org/
[4]https://ecapture.cc/zh/download/:https://ecapture.cc/zh/download/
[5]https://hub.docker.com/r/gojue/ecapture:https://hub.docker.com/r/gojue/ecapture
[6]CVE-2024-24790:https://github.com/advisories/GHSA-49gw-vxvf-fc2g
[7]Leon Hwang:https://github.com/asphaltt
[8]SenberHu:https://github.com/senberhu
[9]yuweizzz:https://github.com/yuweizzz
[10]sancppp:https://github.com/sancppp
[11]Nadeshiko Manju:https://github.com/Zheaoli
[12]行旅途:https://github.com/xxxxxliil
[13]w568w:https://github.com/w568w