-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ssl_sniffer): added process name to logs
- Loading branch information
Showing
6 changed files
with
141 additions
and
38 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,68 @@ | ||
# SSL Sniffer | ||
|
||
> [!NOTE] | ||
> Still in WIP. A `bpftrace_demo.sh` script is provided to try to sniff any encrypted messages on a provided program. | ||
> Run the script with `sudo ./bpftrace_demo.sh <program_name/path>`. | ||
`ssl_sniffer` is a simple tool to sniff on-going SSL/TLS traffic on the machine without installing, trusting, or modifying any certificate. It will **intercept the raw decrypted SSL/TLS traffic**, and display it on the fly. | ||
|
||
`ssl_sniffer` is a simple tool to sniff on-going SSL/TLS traffic on the machine without installing, trusting, or modifying any certificate. It will **intercept the SSL/TLS traffic** and **decrypt it** on the fly at the system SSL libraries level. | ||
![ssl_demo](../../resources/ssl_sniffer_demo.gif) | ||
|
||
## Features | ||
|
||
- ✅ Sniff many SSL/TLS libraries (OpenSSL, GnuTLS, NSS) | ||
- ✅ On-the-fly SSL/TLS traffic sniffing (no need to install certificates & restart the application) | ||
- ✅ Bypass SSL Pinning | ||
- 🚧 [**Planned**] protocol parsing (HTTP2+) | ||
|
||
It supports out-of-the-box the following applications: | ||
- `curl` | ||
- `wget` | ||
- `nginx` (not all versions, some have inbuilt SSL/TLS support) | ||
& many more... | ||
|
||
## Usage | ||
|
||
```bash | ||
$ sudo ./ssl_sniffer | ||
libssl.so probes attached to ... | ||
``` | ||
|
||
From there, any application making uses of the system's SSL/TLS libraries will be sniffed. The output will be displayed on the terminal. | ||
|
||
```bash | ||
$ sudo ./ssl_sniffer | ||
... | ||
Press Ctrl+C to stop | ||
[+] curl(12345), ts: 1234567890, op: SSL_OP_WRITE, len: 78 --> | ||
GET / HTTP/1.1 | ||
Host: www.google.com | ||
User-Agent: curl/7.81.0 | ||
Accept: */* | ||
|
||
|
||
[+] curl(12345), ts: 1234567890, op: SSL_OP_READ, len: 1378 --> | ||
HTTP/1.1 200 OK | ||
Date: ... | ||
Set-Cookie: ... | ||
... | ||
``` | ||
|
||
## How it works | ||
|
||
`ssl_sniffer` is an eBPF program that will be attached to various uprobe and kprobe events to intercept the SSL/TLS traffic. It supports the following libraries: | ||
- OpenSSL | ||
- GnuTLS | ||
- NSS | ||
|
||
> [!IMPORTANT] | ||
> Despite trying to sniff most of the SSL/TLS traffic, some applications might not be appearing in the traffic. This is because the application might be **using a different non supported SSL/TLS library**, **bringing their own library** in a directory which is not being sniffed or have **inbuilt SSL/TLS support**. It would still be possible to hijack them if we know their paths and trying to guess func. by their DWARF info. | ||
> | ||
> The hardest case is when the statically compiled application is using **non-standard SSL/TLS libraries** and have **no DWARF info**. In this case, it's better to give up unless we know the functions locations. | ||
# Requirements | ||
## Requirements | ||
|
||
- Kernel version >= 5.8 (could be lower but that requires to ditch ring buffer's and replace them with perf buffers) | ||
- Kernel version **>= 5.8** (could be lower but that requires to ditch ring buffer's and replace them with perf buffers) | ||
|
||
# Steps | ||
Tested on: | ||
- Ubuntu 22.04 LTS (kernel 5.15.0-106-generic) | ||
|
||
- for every running KNOWN process to sniff, we will: | ||
- Listen for the `connect` syscall and store the file descriptor IF its a remote connection (may think about local connections later) | ||
- Linkage of the SSL/TLS library to the TCP file descriptor: | ||
- (OpenSSL) Listen for the `SSL_set_fd` function call and store the SSL context linked to the file descriptor | ||
- (GnuTLS) Listen for the `gnutls_transport_set_ptr` function call and store the SSL context linked to the file descriptor | ||
- (NSS) Listen for the `PRFileDesc` structure and store the SSL context linked to the file descriptor | ||
- Listen for the equivalent `SSL_read` and `SSL_write` function calls and decrypt the data linked to the SSL context we stored earlier. | ||
## Extra | ||
|
||
We now know the outgoing/incoming data of any SSL/TLS connection on the machine and their destination. | ||
A `bpftrace_demo.sh` script is provided to try to sniff any encrypted SSL/TLS traffic on specified programs. It will use `bpftrace` to compile and load the eBPF program. It's a simplier version of the `ssl_sniffer` tool with truncated output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters