github.com/gojue/ecapture@v0.8.2/README_JA.md (about) 1 ![](./images/ecapture-logo-400x400.png) 2 3 [中文介绍](./README_CN.md) | [English](./README.md) | 日本語 4 5 [![GitHub stars](https://img.shields.io/github/stars/gojue/ecapture.svg?label=Stars&logo=github)](https://github.com/gojue/ecapture) 6 [![GitHub forks](https://img.shields.io/github/forks/gojue/ecapture?label=Forks&logo=github)](https://github.com/gojue/ecapture) 7 [![CI](https://github.com/gojue/ecapture/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/gojue/ecapture/actions/workflows/code-analysis.yml) 8 [![Github Version](https://img.shields.io/github/v/release/gojue/ecapture?display_name=tag&include_prereleases&sort=semver)](https://github.com/gojue/ecapture/releases) 9 10 ### eCapture(旁观者): CA証明書なしで SSL/TLS のテキストコンテンツをキャプチャする eBPF を使用。 11 12 > **注** 13 > 14 > Linux/Android カーネルバージョン x86_64 4.18 以上、**aarch64 5.5** 以上に対応しています。 15 > Windows、macOS には対応していません。 16 ---- 17 18 19 <!-- MarkdownTOC autolink="true" --> 20 21 - [eCapture ユーザーマニュアル](#ecapture-ユーザーマニュアル) 22 - [eCapture の仕組み](#ecapture-の仕組み) 23 - [eCapture アーキテクチャ](#ecapture-アーキテクチャ) 24 - [はじめに](#はじめに) 25 - [eBPF とは](#ebpf-とは) 26 - [コンパイル方法](#コンパイル方法) 27 - [コントリビュート](#コントリビュート) 28 29 <!-- /MarkdownTOC --> 30 ---- 31 32 33 # eCapture ユーザーマニュアル 34 35 ![](./images/ecapture-help-v0.7.4.png) 36 37 # eCapture の仕組み 38 39 ![](./images/how-ecapture-works.png) 40 41 * SSL/TLS テキスト コンテキスト キャプチャ、openssl\libssl\boringssl\gnutls\nspr(nss) ライブラリのサポート。 42 * Go TLSライブラリをサポートする平文キャプチャ、つまりGolang言語で書かれたHTTPS/TLSプログラムの暗号化通信を使用します。 43 * bash audit, ホストセキュリティ監査用のbashコマンドをキャプチャ。 44 * mysql クエリ SQL 監査、サポート mysqld 5.6\5.7\8.0、および mariadDB。 45 46 # eCapture アーキテクチャ 47 ![](./images/ecapture-architecture.png) 48 49 50 # はじめに 51 52 ## ELF バイナリファイルを使用する 53 54 ELF zip ファイル[リリース](https://github.com/gojue/ecapture/releases)をダウンロードし、解凍して 55 コマンド `./ecapture --help` で使用します。 56 57 * Linux kernel version >= 4.18 is required. 58 * Enable BTF [BPF Type Format (BTF)](https://www.kernel.org/doc/html/latest/bpf/btf.html) (Optional, 2022-04-17) 59 60 ## docker containerised run 61 62 ```shell 63 ## イメージをプルする 64 docker pull gojue/ecapture:latest 65 # 実行 66 docker run --rm --privileged=true --net=host -v ${hostファイルパス}:${コンテナ内パス} gojue/ecapture ARGS 67 ``` 68 69 ## コマンドラインオプション 70 71 > **注** 72 > 73 > ROOT 権限が必要です。 74 > 75 eCapture はデフォルトで `/etc/ld.so.conf` ファイルを検索し、 76 `SO` ファイルのロードディレクトリを検索し、 77 `openssl` シャードライブラリの場所を検索します。 78 79 ターゲットプログラムが静的にコンパイルされる場合、プログラムパスを `--libssl` フラグの値として直接設定することができます。 80 81 ## 模块介绍 82 eCapture 有8个模块,分别支持openssl/gnutls/nspr/boringssl/gotls等类库的TLS/SSL加密类库的明文捕获、Bash、Mysql、PostGres软件审计。 83 * bash capture bash command 84 * gnutls capture gnutls text content without CA cert for gnutls libraries. 85 * gotls Capturing plaintext communication from Golang programs encrypted with TLS/HTTPS. 86 * mysqld capture sql queries from mysqld 5.6/5.7/8.0 . 87 * nss capture nss/nspr encrypted text content without CA cert for nss/nspr libraries. 88 * postgres capture sql queries from postgres 10+. 89 * tls use to capture tls/ssl text content without CA cert. (Support openssl 1.0.x/1.1.x/3.0.x or newer). 90 91 你可以通过`ecapture -h`来查看这些自命令列表。 92 93 ## openssl 模块 94 openssl模块支持3中捕获模式 95 * pcap/pcapng模式,将捕获的明文数据以pcap-NG格式存储。 96 * keylog/key模式,保存TLS的握手密钥到文件中。 97 * text模式,直接捕获明文数据,输出到指定文件中,或者打印到命令行。 98 ### Pcap 模式 99 你可以通过`-m pcap`或`-m pcapng`参数来指定,需要配合`--pcapfile`、`-i`参数使用。其中`--pcapfile`参数的默认值为`ecapture_openssl.pcapng`。 100 ```shell 101 ./ecapture tls -m pcap -i eth0 --pcapfile=ecapture.pcapng --port=443 102 ``` 103 将捕获的明文数据包保存为pcapng文件,可以使用`Wireshark`打开查看。 104 105 ### keylog 模式 106 你可以通过`-m keylog`或`-m key`参数来指定,需要配合`--keylogfile`参数使用,默认为`ecapture_masterkey.log`。 107 捕获的openssl TLS的密钥`Master Secret`信息,将保存到`--keylogfile`中。你也可以同时开启`tcpdump`抓包,再使用`Wireshark`打开,设置`Master Secret`路径,查看明文数据包。 108 ```shell 109 ./ecapture tls -m keylog -keylogfile=openssl_keylog.log 110 ``` 111 112 也可以直接使用`Wireshark`软件实时解密展示。 113 ```shell 114 tshark -o tls.keylog_file:ecapture_masterkey.log -Y http -T fields -e http.file_data -f "port 443" -i eth0 115 ``` 116 ### text 模式 117 `./ecapture tls -m text ` 将会输出所有的明文数据包。(v0.7.0起,不再捕获SSLKEYLOG信息。) 118 119 120 ## gotls 模块 121 与openssl模块类似。 122 123 ### サーバーの BTF 設定を確認: 124 125 ```shell 126 cfc4n@vm-server:~$# uname -r 127 4.18.0-305.3.1.el8.x86_64 128 cfc4n@vm-server:~$# cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF 129 CONFIG_DEBUG_INFO_BTF=y 130 ``` 131 132 Step 1: 133 ```shell 134 ./ecapture gotls --elfpath=/home/cfc4n/go_https_client --hex 135 ``` 136 137 Step 2: 138 ```shell 139 /home/cfc4n/go_https_client 140 ``` 141 ### more help 142 ```shell 143 ./ecapture gotls -h 144 ``` 145 146 ### bash コマンド 147 bash コマンドをキャプチャする。 148 ```shell 149 ps -ef | grep foo 150 ``` 151 152 # eBPF とは 153 [eBPF](https://ebpf.io) 154 155 # コンパイル方法 156 157 Linux カーネル: >= 4.18. 158 159 ## ツール 160 * golang 1.21 またはそれ以降 161 * clang 9.0 またはそれ以降 162 * cmake 3.18.4 またはそれ以降 163 * clang バックエンド: llvm 9.0 またはそれ以降 164 * カーネル config:CONFIG_DEBUG_INFO_BTF=y (Optional, 2022-04-17) 165 166 ## コマンド 167 ### ubuntu 168 もしUbuntu 20.04以降を使用している場合、1つのコマンドでコンパイル環境の初期化が完了します。 169 170 ```shell 171 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/gojue/ecapture/master/builder/init_env.sh)" 172 ``` 173 ### other Linux 174 上記の`ツールチェーンバージョン`に列挙されたソフトウェア以外に、以下のソフトウェアも必要です。自己でインストールしてください。 175 * linux-tools-common 176 * linux-tools-generic 177 * pkgconf 178 * libelf-dev 179 180 **リポジトリのコードをクローンし、コンパイルしてください** 181 ```shell 182 git clone --recurse-submodules git@github.com:gojue/ecapture.git 183 cd ecapture 184 make 185 bin/ecapture 186 ``` 187 188 ## BTF なしでコンパイル 189 eCapture サポート BTF をコマンド `make nocore` で無効にし、2022/04/17 にコンパイルできるようにしました。LinuxのBTFをサポートしていなくても正常に動作することができます。 190 ```shell 191 make nocore 192 bin/ecapture --help 193 ``` 194 195 ## クロスコンパイル 196 ### 内核头文件 197 要交叉编译eCapture工具,您需要安装目标体系结构的内核头文件。需要安装`linux-source`软件包。 198 ```shell 199 kernel_ver=`uname -r | cut -d'-' -f 1` 200 sudo apt-get install -y linux-source-$kernel_ver 201 cd /usr/src 202 sudo tar -xf linux-source-${kernel_ver}.tar.bz2 203 cd /usr/src/linux-source-${kernel_ver} 204 test -f .config || yes "" | sudo make oldconfig 205 ``` 206 207 Ubuntuの `amd64` システムで `arm64` の成果物をビルドするには、`CROSS_ARCH`環境変数を設定してクロスコンパイルを実行できます。 208 ```shell 209 CROSS_ARCH=arm64 make 210 ``` 211 ## Stargazers over time 212 213 [![Stargazers over time](https://starchart.cc/gojue/ecapture.svg)](https://starchart.cc/gojue/ecapture) 214 215 216 # コントリビュート 217 パッチの投稿やコントリビューションのワークフローの詳細は [CONTRIBUTING](./CONTRIBUTING.md) を参照してください。