Go, Just Use eBPF
gojue
is a Golang Cli application framework
Capturing SSL/TLS plaintext without a CA certificate using eBPF. Supported on Linux/Android kernels for amd64/arm64.
Home Page: https://ecapture.cc
License: Apache License 2.0
[root@localhost ecapture]# go run main.go
2022/03/16 14:00:49 https://github.com/ehids/ecapture
2022/03/16 14:00:49 eBPF技术实现的无CA证书HTTPS抓包工具
2022/03/16 14:00:49 process pid: 3253
2022/03/16 14:00:49 start to run EBPFProbeBash module
2022/03/16 14:00:49 start to run EBPFProbeSSLDump module
2022/03/16 14:00:49 couldn't init manager: error:program probe_entry_SSL_write: CO-RE relocations: no BTF found for kernel version 5.16.14-1.el7.elrepo.x86_64: not supported , couldn't load eBPF programs, cs:&{map[active_ssl_read_args_map:Hash(keySize=8, valueSize=8, maxEntries=1024, flags=0) active_ssl_write_args_map:Hash(keySize=8, valueSize=8, maxEntries=1024, flags=0) data_buffer_heap:PerCPUArray(keySize=4, valueSize=4032, maxEntries=1, flags=0) tls_events:PerfEventArray(keySize=0, valueSize=0, maxEntries=0, flags=0)] map[probe_entry_SSL_read:0xc000086e60 probe_entry_SSL_write:0xc000086d20 probe_ret_SSL_read:0xc000086f00 probe_ret_SSL_write:0xc000086dc0] LittleEndian}
exit status 1
Describe the bug
libpthread.so cant found.
Expected behavior
It works.
Screenshots
root@VM-0-13-ubuntu:/home/ubuntu/ecapture# bin/ecapture tls
2022/06/13 23:03:35 pid info :6313
2022/06/13 23:03:35 start to run EBPFProbeOPENSSL module
2022/06/13 23:03:35 stat /usr/lib/libpthread.so.0: no such file or directory
2022/06/13 23:03:35 start to run EBPFProbeGNUTLS module
2022/06/13 23:03:35 stat /usr/lib/libgnutls.so.30: no such file or directory
2022/06/13 23:03:35 start to run EBPFProbeNSPR module
2022/06/13 23:03:35 stat /usr/lib/libnspr4.so: no such file or directory
Linux Server/Desktop (please complete the following information):
#54
-Ubuntu SMP Wed Jun 1 20:43:01 UTC 2022 aarch64 aarch64 aarch64 GNU/LinuxAdditional context
Add any other context about the problem here.
将/bin/bash拷贝到其它目录并执行即可绕过,例如:/home/bash
curl --version curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
ldd /usr/bin/curl | grep ssl libssl3.so => /usr/lib64/libssl3.so (0x00007f255286b000) libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f254f9e4000)
libssl3.so is NSS , it does not contain SSL_read/SSL_write function
ATT
this.Writer()
rewrite to Dispatcher()
interface for child.
https://github.com/ehids/ecapture/blob/5c9b871e42db6f4f564773b1d778f6e65c1ae271/user/probe_openssl.go#L286-L292
empty value check is ugly.
现在项目发布的二进制文件无法在 Apple M1 上运行,猜测不是 arm 架构的,能否直接提供编译的 arm 版,这样也省去了反复编译的问题
🙏 感谢您的项目
Just ran across this project, looks neat. Taking a look at the underlying implementation, this works as a program that just hooks common shared library encryption routines via uprobes and events with the unencrypted data as those routines are invoked. That makes sense.
The README diagrams however, are kind of odd. They:
libpcap
in them, which, as far as I can tell doesn't appear to be leveraged anywhere in this projectlibpcap
shows TC
and XDP
boxes, almost implying that this works with network-level packet captureNeither of those seem accurate, since installing a system-wide uprobe hook into say, the openssl library, will event on data even if it's being encrypted/decrypted locally on a filesystem and doing 0 with the network.
I think it'd be helpful to update the diagrams to better illustrate the uprobe hooks without any reference to libpcap or the network just for people wondering how this actually works.
ATT
我的编译结果如下:
root@ubantu:/home/disk/workspace/ecapture# make
clang -D__TARGET_ARCH_x86
-O2 -mcpu=v1 -nostdinc -Wno-pointer-sign
-I./kern
-target bpfel -c kern/openssl_kern.c -o user/bytecode/openssl_kern.o
-fno-ident -fdebug-compilation-dir . -g -D__BPF_TARGET_MISSING="GCC error "The eBPF is using target specific macros, please provide -target""
-MD -MP
clang: error: unknown argument: '-fdebug-compilation-dir'
clang: warning: .: 'linker' input unused [-Wunused-command-line-argument]
Makefile:62: recipe for target 'kern/openssl_kern.o' failed
make: *** [kern/openssl_kern.o] Error 1
配置如下:
ubantu 1804
golang 1.18
clang 6.0
pahole 1.21
cmake 3.10
Maybe we can support postgres
(version 11+) like mysql
I think I can open a PR
to support this.
but I am not sure we can get the return value
like #44 will take a try.
由于cilium/ebpf的PerfEventArray限制,超过4K数据,用户态无法读取map的事件。
考虑改为ringbuf
bug 描述
Ubuntu 21.10 运行 ecapture
错误,我还是重新编译的。
root@ubuntu2110:~/ecapture-master# ./bin/ecapture tls
2022/04/12 16:56:21 pid info :9870
2022/04/12 16:56:21 start to run EBPFProbeOPENSSL module
2022/04/12 16:56:21 start to run EBPFProbeGNUTLS module
2022/04/12 16:56:21 start to run EBPFProbeNSPR module
2022/04/12 16:56:21 HOOK type:2, binrayPath:/lib/x86_64-linux-gnu/libssl.so.1.1
2022/04/12 16:56:21 libPthread so Path:/lib/x86_64-linux-gnu/libpthread.so.0
2022/04/12 16:56:21 target all process.
2022/04/12 16:56:21 HOOK type:2, binrayPath:/lib/x86_64-linux-gnu/libgnutls.so.30
2022/04/12 16:56:21 target all process.
2022/04/12 16:56:21 HOOK type:2, binrayPath:/lib/x86_64-linux-gnu/libnspr4.so
2022/04/12 16:56:21 target all process.
2022/04/12 16:56:22 couldn't start bootstrap manager: error:1 error occurred:
* error:opening uprobe: symbol connect: not found , isRet:%!d(bool=false), {UID:, EbpfFuncName:probe_connect}
, probes activation validation failed
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Linux Server/Desktop (please complete the following information):
root@ubuntu2110:~/ecapture-master# cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF
CONFIG_DEBUG_INFO_BTF=y
CONFIG_DEBUG_INFO_BTF_MODULES=y
root@ubuntu2110:~/ecapture-master# uname -r
5.13.0-37-generic
root@ubuntu2110:~/ecapture-master# openssl version
OpenSSL 1.1.1l 24 Aug 2021
root@ubuntu2110:~/ecapture-master#
Additional context
Add any other context about the problem here.
ATT.
Describe the bug
When I execute the following command:
ecapture --help
2022/06/10 11:21:08 BTF not support, please check it. shell: cat /boot/config-uname -r
| grep CONFIG_DEBUG_INFO_BTF
Or you can compile a no BTF version with youeself by make nocore
command,Please read Makefile for more info.
Linux Server/Desktop (please complete the following information):
cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
uname -r
4.19.136
github.com/ehids/ecapture/releases/download/v0.1.8/ecapture-v0.1.8.tar.gz
ATT
OS: centos 4.18
[root@vm-server]# ldd `which curl`
linux-vdso.so.1 => (0x00007ffebd5fd000)
libcurl.so.4 => /lib64/libcurl.so.4 (0x00007f923be91000)
libssl3.so => /lib64/libssl3.so (0x00007f923bc3f000)
libsmime3.so => /lib64/libsmime3.so (0x00007f923ba18000)
libnss3.so => /lib64/libnss3.so (0x00007f923b6eb000)
libnssutil3.so => /lib64/libnssutil3.so (0x00007f923b4bc000)
libplds4.so => /lib64/libplds4.so (0x00007f923b2b8000)
libplc4.so => /lib64/libplc4.so (0x00007f923b0b3000)
libnspr4.so => /lib64/libnspr4.so (0x00007f923ae75000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f923ac59000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f923aa55000)
libz.so.1 => /lib64/libz.so.1 (0x00007f923a83f000)
libc.so.6 => /lib64/libc.so.6 (0x00007f923a471000)
libidn.so.11 => /lib64/libidn.so.11 (0x00007f923a23e000)
libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f923a014000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f9239dc7000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f9239adf000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f92398ac000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f92396a8000)
liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007f9239499000)
libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007f9239247000)
librt.so.1 => /lib64/librt.so.1 (0x00007f923903f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f923c0fa000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007f9238dcd000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f923896a000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f923875c000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f9238558000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f923833e000)
libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007f9238121000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f9237efa000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f9237cc3000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f9237a61000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f923785e000)
0,body类型识别, magic number 判断,gzip、其他二进制流等。
1,http body的gzip压缩解码
2,二进制流特殊处理
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Linux Server/Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
如题
Linux VM-16-8-centos 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-16-8-centos ecapture]# ldd /usr/bin/wget |grep tls
libgnutls.so.30 => /lib64/libgnutls.so.30 (0x00007f237c6b0000)
Describe the bug
cant load ebpf bytecode with cilium/ebpf library on linux kernel 4.18.0 while global variable used in kernel code.
To Reproduce
./bin/ecapture tls
loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: map .rodata: map create: read- and write-only maps not supported (requires >= v5.2)
** DEBUG**
const volatile u64 target_pid declaration at
https://github.com/ehids/ecapture/blob/0787e297de3c9c78ea13fbc7aacc7d68b88ac367/kern/common.h#L23-L28
const volatile u64 target_pid = 0;
Expected behavior
It works with global variable in ebpf kernel function on linux kernel 4.18.
Additional context
seems like a cilium/ebpf bug ref cilium/ebpf#628 .
ATT, tls version info need to get.
Hi,
for example I have a netshoot pod running in kubernetes, when I run curl
kubectl exec -it netshoot-hostnetwork -- curl -k -v https://10.1.34.88/
I want to trace the TLS connection from the curl from the netshoot-hostnetwork pod, the curl in netshoot-hostnetwork pod has libssl below in the pod namespace
kubectl exec -it netshoot-hostnetwork -- ldd /usr/bin/curl
/lib/ld-musl-x86_64.so.1 (0x7f932eda0000)
libcurl.so.4 => /usr/lib/libcurl.so.4 (0x7f932ece5000)
libz.so.1 => /lib/libz.so.1 (0x7f932eccb000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f932eda0000)
libnghttp2.so.14 => /usr/lib/libnghttp2.so.14 (0x7f932eca6000)
libssl.so.1.1 => /lib/libssl.so.1.1 (0x7f932ec25000)
libcrypto.so.1.1 => /lib/libcrypto.so.1.1 (0x7f932e9a4000)
libbrotlidec.so.1 => /usr/lib/libbrotlidec.so.1 (0x7f932e998000)
libbrotlicommon.so.1 => /usr/lib/libbrotlicommon.so.1 (0x7f932e975000)
is this possible? or in general, could we improve ecapture to capture container TLS traffic?
内核版本 4.19
必须重新编译内核吗?
Describe the bug
arm64编译失败,替换vmlinux.h为arm64的之后,编译通过。是我提交一下pr,还是您自己加一下?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Linux Server/Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
I see that Android supports eBPF, Is it possible we can make this project work on Android with the help of tools like Magisk/Zygisk.
Describe the bug
In k8s environment, run ecapture in k8s node normally with --pthread
argument works fine
[root@cilium-dev home]# ecapture tls --libssl=/lib64/libssl.so.1.1.1g --pthread=/lib64/libpthread.so.0 --hex
2022/06/05 12:26:22 pid info :3292288
2022/06/05 12:26:22 start to run EBPFProbeOPENSSL module
2022/06/05 12:26:22 start to run EBPFProbeGNUTLS module
2022/06/05 12:26:22 stat /usr/lib/libgnutls.so.30: no such file or directory
2022/06/05 12:26:22 start to run EBPFProbeNSPR module
2022/06/05 12:26:22 stat /usr/lib/libnspr4.so: no such file or directory
2022/06/05 12:26:22 HOOK type:2, binrayPath:/lib64/libssl.so.1.1.1g
2022/06/05 12:26:22 libPthread so Path:/lib64/libpthread.so.0 <===libPhread
2022/06/05 12:26:22 target all process.
but if run ecapture in pod/container with --pthread
in the same k8s node, ecapture fail to locate libpthread, the pod mounted node /
in pod /mnt
directory for ecapture to locate the node /lib64/libpthread.so.0
library
[root@cilium-dev home]# kubectl exec -it netshoot-ecap -- /bin/bash
bash-5.1# ecapture tls --pthread=/mnt/lib64/libpthread.so.0 --libssl=/mnt/lib64/libssl.so.1.1.1g --hex
2022/06/05 16:46:48 pid info :3305486
2022/06/05 16:46:48 start to run EBPFProbeOPENSSL module
2022/06/05 16:46:48 start to run EBPFProbeGNUTLS module
2022/06/05 16:46:48 lstat /etc/ld.so.conf: no such file or directory <===
2022/06/05 16:46:48 invalid argument <====
bash-5.1# ls -l /mnt/lib64/libpthread.so.0 /mnt/lib64/libssl.so.1.1.1g
lrwxrwxrwx 1 root root 18 Jul 20 2020 /mnt/lib64/libpthread.so.0 -> libpthread-2.28.so
-rwxr-xr-x 1 root root 615576 Mar 30 2021 /mnt/lib64/libssl.so.1.1.1g
To Reproduce
Steps to reproduce the behavior:
see netshoot diff vincentmli/netshoot@72633ba to build your netshoot
or deploy the netshoot pod from docker hub vli39/netshoot:ecap
with following yaml
netshoot-ecap yaml with privilege and mount k8s node /
in pod /mnt
apiVersion: v1
kind: Pod
metadata:
name: netshoot-ecap
spec:
hostPID: true
hostNetwork: true
nodeSelector:
dedicated: master
containers:
- name: netshoot-ecap
image: vli39/netshoot:ecap
command:
- /bin/sleep
- "3600"
volumeMounts:
- mountPath: /mnt
name: host-slash
securityContext:
privileged: true
volumes:
- name: host-slash
hostPath:
path: /
type: ''
[root@cilium-dev home]# kubectl exec -it netshoot-ecap -- /bin/bash
bash-5.1# ecapture tls --pthread=/mnt/lib64/libpthread.so.0 --libssl=/mnt/lib64/libssl.so.1.1.1g --hex
2022/06/05 16:46:48 pid info :3305486
2022/06/05 16:46:48 start to run EBPFProbeOPENSSL module
2022/06/05 16:46:48 start to run EBPFProbeGNUTLS module
2022/06/05 16:46:48 lstat /etc/ld.so.conf: no such file or directory
2022/06/05 16:46:48 invalid argument
bash-5.1# ls -l /mnt/lib64/libpthread.so.0 /mnt/lib64/libssl.so.1.1.1g
lrwxrwxrwx 1 root root 18 Jul 20 2020 /mnt/lib64/libpthread.so.0 -> libpthread-2.28.so
-rwxr-xr-x 1 root root 615576 Mar 30 2021 /mnt/lib64/libssl.so.1.1.1g
Expected behavior
expect ecapture in container environment with --pthread
argument to find the right libpthread lib for connect
and ignore looking for libthread through ld.so.conf
Linux Server/Desktop (please complete the following information):
cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
uname -a
Linux cilium-dev 5.18.0+ #1 SMP PREEMPT_DYNAMIC Wed Jun 1 21:37:44 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
0.1.8-20220525-c030d80-prev-84a358e
Additional context
Describe the bug
capture to firefox content is encrypted
To Reproduce
Steps to reproduce the behavior:
Screenshots
ecapture output content(show a little part):
Linux Server/Desktop (please complete the following information):
Describe the bug
cfc4n@vm-server:~/project/ssldump/bin$ ./ecapture bash
2022/06/17 21:44:06 <nil>
To Reproduce
./ecapture
Screenshots
If applicable, add screenshots to help explain your problem.
Linux Server/Desktop (please complete the following information):
输出:
<a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%!A(MISSING)%!F(MISSING)%!F(MISSING)www.baidu.com%!f(MISSING)%!f(MISSING)bdorz_come%!d(MISSING)1 name=tj_login class=lb>登录</a>
实际:
<a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript><a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>
Thank you, ecapture is a great tool for tls capture.
Currently, ecapture cannot use other network analyzer, i.e. Wireshark. ecapture may support generate SSLKEYLOGFILE
and pcap file, which can be analyzed by Wireshark.
P.S. NSS Key Log Format
New feature
Expected behavior
Need to support mysql 5.7\mysql 8.0 like 5.6
如题
ATT
Describe the bug
A clear and concise description of what the bug is.
Can we have a possible to export the outputs with pcap format?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Linux Server/Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.