Skip to content

Commit 14b6ddf

Browse files
committed
update the readme
1 parent eee8227 commit 14b6ddf

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
</p>
1111
<br>
1212

13-
View the HTTP and HTTPS requests made by a linux program:
13+
View the HTTP and HTTPS requests made by any linux program by running `httptap -- <command>`. For example, the following runs curl on "monasticacademy.org", which results in an HTTP status of 308 (Redirect):
1414

1515
```shell
1616
$ httptap -- curl https://monasticacademy.org
1717
---> GET https://monasticacademy.org/
1818
<--- 308 https://monasticacademy.org/ (15 bytes)
1919
```
2020

21+
Now let's try the same thing with an HTTP request from python. This time we see that python follows the redirect and gets a 200 OK response:
22+
2123
```shell
2224
httptap -- python -c "import requests; requests.get('https://monasticacademy.org')"
2325
---> GET https://monasticacademy.org/
@@ -26,17 +28,7 @@ httptap -- python -c "import requests; requests.get('https://monasticacademy.org
2628
<--- 200 https://www.monasticacademy.org/ (5796 bytes)
2729
```
2830

29-
Httptap runs the requested command in an isolated network namespace, injecting a certificate authority created on-the-fly in order to decrypt HTTPS traffic. If you can run `<command>` on your shell, you can likely also run `httptap -- <command>`. You do not need to be the root user, nor set up any kind of daemon, nor make any system-wide changes to your system. The `httptap` executable is a static Go binary that runs without dependencies. You can install it with:
30-
31-
```shell
32-
go install github.com/monasticacademy/httptap@latest
33-
```
34-
35-
or download a pre-built release with:
36-
37-
```shell
38-
curl -L https://github.com/monasticacademy/httptap/releases/download/v0.0.3/httptap_Linux_x86_64.tar.gz | tar xzf -
39-
```
31+
To run `httptap` you do not need to be the root user. You do not need to set up any kind of daemon or make any system-wide changes to your system. It will not create any iptables rules or change your routing table, and generally will not affect any other processes running on the same system. The `httptap` executable is a static Go binary that runs without dependencies.
4032

4133
Httptap is linux-only. It makes extensive use of linux-specific system calls and is unlikely to be ported to other operating systems.
4234

@@ -79,7 +71,7 @@ Now we can see that after receiving the 302 redirect, curl made an additional HT
7971
Let's see what HTTP endpoints the Google Cloud command line interface uses to list compute resources (this requires that you have gcloud installed and are signed in):
8072

8173
```shell
82-
$ httptap gcloud compute instances list
74+
$ httptap -- gcloud compute instances list
8375
---> POST https://oauth2.googleapis.com/token
8476
<--- 200 https://oauth2.googleapis.com/token (997 bytes)
8577
---> GET https://compute.googleapis.com/compute/v1/projects/maple-public-website/aggregated/instances?alt=json&includeAllScopes=True&maxResults=500&returnPartialSuccess=True
@@ -119,7 +111,7 @@ $ httptap --https 443 6443 -- kubectl get all --insecure-skip-tls-verify
119111

120112
In the above, `--insecure-skip-tls-verify` is necessary because kubectl doesn't use the httptap-generated certificate authority, and `--https 443 6443` says to treat TCP connections on ports 443 and 6443 as HTTPS connections, which is needed because my cluter's API endpoint uses port 6443.
121113

122-
Let's see how DNS-over-HTTP works:
114+
Let's see how DNS-over-HTTP works when you use `--doh-url` with curl:
123115

124116
```shell
125117
$ httptap -- curl -sL --doh-url https://cloudflare-dns.com/dns-query https://buddhismforai.sutra.co -o /dev/null
@@ -133,9 +125,9 @@ $ httptap -- curl -sL --doh-url https://cloudflare-dns.com/dns-query https://bud
133125
<--- 200 https://buddhismforai.sutra.co/space/cbodvy/content (6377 bytes)
134126
```
135127

136-
What happened here is that we told `curl` to request the url "https://buddhismforai.sutra.co", using the cloudflare DNS-over-HTTP service for DNS queries. In the output we see that `curl` made 4 HTTP requests in total; the first two were DNS lookups, and then the second two were the HTTP requests for buddhismforai.sutra.co, making use of the IP addresses obtained in the DNS queries.
128+
What happened here is that we told `curl` to request the url "https://buddhismforai.sutra.co", using the cloudflare DNS-over-HTTP service at `cloudflare-dns.com`. In the output we see that `curl` made 4 HTTP requests in total; the first two were DNS lookups, and then the second two were the ordinary HTTP requests for buddhismforai.sutra.co.
137129

138-
Let's see how the DNS-over-HTTP payloads look:
130+
Let's print the contents of the DNS-over-HTTP payloads look:
139131

140132
```shell
141133
$ httptap --head --body -- curl -sL --doh-url https://cloudflare-dns.com/dns-query https://buddhismforai.sutra.co -o /dev/null
@@ -161,6 +153,8 @@ Here the `--head` option tells httptap to print the HTTP headers, and `--body` t
161153

162154
# How it works
163155

156+
When you run `httptap -- <command>`, httptap runs `<command>` in an isolated network namespace, injecting a certificate authority created on-the-fly in order to decrypt HTTPS traffic. Here is the process in detail:
157+
164158
In linux, there is a kernel API for creating and configuring network interfaces. Conventionally, a network interface would be a physical ethernet or WiFi controller in your computer, but it is possible to create a special kind of network interface called a TUN device. A TUN device shows up to the system in the way that any network interface shows up, but any traffic written to it will be delivered to a file descriptor held by the process that created it. Httptap creates a TUN device and runs the subprocess in an environment in which all network traffic is routed through that device.
165159

166160
There is also a kernel API in linux for creating network namespaces. A network namespace is a list of network interfaces and routing rules. When a process is started in linux, it can be run in a specified network namespace. By default, processes run in a root network namespace that we do not want to make chagnes to because doing so would affect all network traffic on the system. Instead, we create a network namespace in which there are only two network interfaces: a loopback device (127.0.0.1) and a TUN device that delivers traffic to us. Then we run the subprocess in that namespace.
@@ -177,3 +171,4 @@ When httptap starts, it creates a certificate authority (actually a private key
177171

178172
- The process cannot listen for incoming network connections
179173
- You need access to `/dev/net/tun`
174+
- All ICMP echo requests will be echoed without sending any ICMP packets out to the real network

0 commit comments

Comments
 (0)