diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4781ba5 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: run utlsproxy + + +all: utlsproxy + +# note: marking "utlsproxy" as phony because we want to recompile +# each time in case we made changes locally to a dependency. + +utlsproxy: + go build -o utlsproxy certstore.go main.go + +run: utlsproxy + ./utlsproxy \ No newline at end of file diff --git a/README.md b/README.md index 2a98c82..f5e2406 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,37 @@ All (to my knowledge) MITM proxies replay requests to servers with stdlib transp Curious how? Most of the work is at [saucesteals/goproxy](https://github.com/saucesteals/goproxy) (credits to [elazarl/goproxy](https://github.com/elazarl/goproxy) for the base proxy implementation) +## Injecting a Client Hello from a previous session + +Instead of fingerprinting the proxy client's ClientHello, you might want to save a ClientHello and re-inject it. E.g. you can save a Safari ClientHello and use it for your cURL requests. + +### Saving a Client Hello + +Simply define the `GOPROXY_CLIENT_HELLO_SAVE_DIR` variable: + +```bash +GOPROXY_CLIENT_HELLO_SAVE_DIR="./client_hello" ./utlsproxy +``` + +This will save the client hello files in the `./client_hello` directory. + +### Re-using a saved Client Hello + +This time, define the `GOPROXY_OVERWRITE_CLIENT_HELLO` variable: + +```bash +GOPROXY_OVERWRITE_CLIENT_HELLO="./client_hello/ch_safari_17.4.1_macOS_14.4.1.bin" ./utlsproxy +``` + +All requests will then have Safari's fingerprint. + +To confirm + +```bash +curl --silent --insecure --proxy localhost:8080 https://tls.peet.ws/api/tls | jq .tls.peetprint_hash +# "b2bafdc69377086c3416be278fd21121" +``` + ## mTLS Like every other MITM, this will not work with mTLS. Find the client's certificate and private key, then add it to the tls.Config (Rarely will you need this, so this is only possible by cloning and adding it yourself) diff --git a/client_hello/ch_safari_17.4.1_macOS_14.4.1.bin b/client_hello/ch_safari_17.4.1_macOS_14.4.1.bin new file mode 100644 index 0000000..db74424 Binary files /dev/null and b/client_hello/ch_safari_17.4.1_macOS_14.4.1.bin differ diff --git a/go.mod b/go.mod index 4508fe6..463be03 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,8 @@ module github.com/saucesteals/utlsproxy go 1.21.0 -replace github.com/elazarl/goproxy => github.com/saucesteals/goproxy v0.0.0-20240124022437-840670a451ca +// replace github.com/elazarl/goproxy => github.com/saucesteals/goproxy v0.0.0-20240124022437-840670a451ca +replace github.com/elazarl/goproxy => ../goproxy require ( github.com/elazarl/goproxy v0.0.0-20240124022437-840670a451ca