Skip to content

Latest commit

 

History

History
217 lines (167 loc) · 8.05 KB

README_JA.md

File metadata and controls

217 lines (167 loc) · 8.05 KB

中文介绍 | English | 日本語

GitHub stars GitHub forks CI Github Version

eCapture(旁观者): CA証明書なしで SSL/TLS のテキストコンテンツをキャプチャする eBPF を使用。

Linux/Android カーネルバージョン x86_64 4.18 以上、aarch64 5.5 以上に対応しています。 Windows、macOS には対応していません。



eCapture ユーザーマニュアル

eCapture の仕組み

  • SSL/TLS テキスト コンテキスト キャプチャ、openssl\libssl\boringssl\gnutls\nspr(nss) ライブラリのサポート。
  • Go TLSライブラリをサポートする平文キャプチャ、つまりGolang言語で書かれたHTTPS/TLSプログラムの暗号化通信を使用します。
  • bash audit, ホストセキュリティ監査用のbashコマンドをキャプチャ。
  • mysql クエリ SQL 監査、サポート mysqld 5.6\5.7\8.0、および mariadDB。

eCapture アーキテクチャ

はじめに

ELF バイナリファイルを使用する

ELF zip ファイルリリースをダウンロードし、解凍して コマンド ./ecapture --help で使用します。

docker containerised run

## イメージをプルする
docker pull gojue/ecapture:latest
# 実行
docker run --rm --privileged=true --net=host -v ${hostファイルパス}:${コンテナ内パス} gojue/ecapture ARGS

コマンドラインオプション

ROOT 権限が必要です。

eCapture はデフォルトで /etc/ld.so.conf ファイルを検索し、 SO ファイルのロードディレクトリを検索し、 openssl シャードライブラリの場所を検索します。

ターゲットプログラムが静的にコンパイルされる場合、プログラムパスを --libssl フラグの値として直接設定することができます。

模块介绍

eCapture 有8个模块,分别支持openssl/gnutls/nspr/boringssl/gotls等类库的TLS/SSL加密类库的明文捕获、Bash、Mysql、PostGres软件审计。

  • bash capture bash command
  • gnutls capture gnutls text content without CA cert for gnutls libraries.
  • gotls Capturing plaintext communication from Golang programs encrypted with TLS/HTTPS.
  • mysqld capture sql queries from mysqld 5.6/5.7/8.0 .
  • nss capture nss/nspr encrypted text content without CA cert for nss/nspr libraries.
  • postgres capture sql queries from postgres 10+.
  • tls use to capture tls/ssl text content without CA cert. (Support openssl 1.0.x/1.1.x/3.0.x or newer).

你可以通过ecapture -h来查看这些自命令列表。

openssl 模块

openssl模块支持3中捕获模式

  • pcap/pcapng模式,将捕获的明文数据以pcap-NG格式存储。
  • keylog/key模式,保存TLS的握手密钥到文件中。
  • text模式,直接捕获明文数据,输出到指定文件中,或者打印到命令行。

Pcap 模式

你可以通过-m pcap-m pcapng参数来指定,需要配合--pcapfile-i参数使用。其中--pcapfile参数的默认值为ecapture_openssl.pcapng

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

将捕获的明文数据包保存为pcapng文件,可以使用Wireshark打开查看。

keylog 模式

你可以通过-m keylog-m key参数来指定,需要配合--keylogfile参数使用,默认为ecapture_masterkey.log。 捕获的openssl TLS的密钥Master Secret信息,将保存到--keylogfile中。你也可以同时开启tcpdump抓包,再使用Wireshark打开,设置Master Secret路径,查看明文数据包。

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

也可以直接使用Wireshark软件实时解密展示。

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

text 模式

./ecapture tls -m text 将会输出所有的明文数据包。(v0.7.0起,不再捕获SSLKEYLOG信息。)

gotls 模块

与openssl模块类似。

サーバーの BTF 設定を確認:

cfc4n@vm-server:~$# uname -r
4.18.0-305.3.1.el8.x86_64
cfc4n@vm-server:~$# cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF
CONFIG_DEBUG_INFO_BTF=y

Step 1:

./ecapture gotls --elfpath=/home/cfc4n/go_https_client --hex

Step 2:

/home/cfc4n/go_https_client

more help

./ecapture gotls -h

bash コマンド

bash コマンドをキャプチャする。

ps -ef | grep foo

eBPF とは

eBPF

コンパイル方法

Linux カーネル: >= 4.18.

ツール

  • golang 1.21 またはそれ以降
  • clang 9.0 またはそれ以降
  • cmake 3.18.4 またはそれ以降
  • clang バックエンド: llvm 9.0 またはそれ以降
  • カーネル config:CONFIG_DEBUG_INFO_BTF=y (Optional, 2022-04-17)

コマンド

ubuntu

もしUbuntu 20.04以降を使用している場合、1つのコマンドでコンパイル環境の初期化が完了します。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/gojue/ecapture/master/builder/init_env.sh)"

other Linux

上記のツールチェーンバージョンに列挙されたソフトウェア以外に、以下のソフトウェアも必要です。自己でインストールしてください。

  • linux-tools-common
  • linux-tools-generic
  • pkgconf
  • libelf-dev

リポジトリのコードをクローンし、コンパイルしてください

git clone --recurse-submodules [email protected]:gojue/ecapture.git
cd ecapture
make
bin/ecapture

BTF なしでコンパイル

eCapture サポート BTF をコマンド make nocore で無効にし、2022/04/17 にコンパイルできるようにしました。LinuxのBTFをサポートしていなくても正常に動作することができます。

make nocore
bin/ecapture --help

クロスコンパイル

内核头文件

要交叉编译eCapture工具,您需要安装目标体系结构的内核头文件。需要安装linux-source软件包。

kernel_ver=`uname -r | cut -d'-' -f 1`
sudo apt-get install -y linux-source-$kernel_ver
cd /usr/src
sudo tar -xf linux-source-${kernel_ver}.tar.bz2
cd /usr/src/linux-source-${kernel_ver}
test -f .config || yes "" | sudo make oldconfig

Ubuntuの amd64 システムで arm64 の成果物をビルドするには、CROSS_ARCH環境変数を設定してクロスコンパイルを実行できます。

CROSS_ARCH=arm64 make

Stargazers over time

Stargazers over time

コントリビュート

パッチの投稿やコントリビューションのワークフローの詳細は CONTRIBUTING を参照してください。