Skip to content

Commit

Permalink
Upgrade curl to 8.5.0 and more options (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
perklet authored Apr 16, 2024
1 parent b3409f8 commit a8c85e8
Show file tree
Hide file tree
Showing 29 changed files with 1,196 additions and 540 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RUN cd ${NGHTTP2_VERSION} && \
make && make install

# Download curl.
ARG CURL_VERSION=curl-8.1.1
ARG CURL_VERSION=curl-8.5.0
RUN curl -o ${CURL_VERSION}.tar.xz https://curl.se/download/${CURL_VERSION}.tar.xz
RUN tar xf ${CURL_VERSION}.tar.xz

Expand Down
53 changes: 2 additions & 51 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NSS_URL := https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_92_RTM/src/ns
BORING_SSL_COMMIT := d24a38200fef19150eef00cad35b138936c08767
NGHTTP2_VERSION := nghttp2-1.56.0
NGHTTP2_URL := https://github.com/nghttp2/nghttp2/releases/download/v1.56.0/nghttp2-1.56.0.tar.bz2
CURL_VERSION := curl-8.1.1
CURL_VERSION := curl-8.5.0

brotli_install_dir := $(abspath brotli-$(BROTLI_VERSION)/out/installed)
brotli_static_libs := $(brotli_install_dir)/lib/libbrotlicommon-static.a $(brotli_install_dir)/lib/libbrotlidec-static.a
Expand Down Expand Up @@ -65,55 +65,6 @@ help: ## Show this help message
.PHONY: help
.DEFAULT_GOAL := help

firefox-build: $(CURL_VERSION)/.firefox ## Build the Firefox version of curl-impersonate
cd $(CURL_VERSION)
# Don't pass this Makefile's MAKEFLAGS
$(MAKE) MAKEFLAGS=-j$(SUBJOBS)
.PHONY: firefox-build

firefox-checkbuild: ## Run basic checks on the built binary
ifeq ($(host),$(build))
cd $(CURL_VERSION)
# Make sure all needed features were compiled in
./src/curl-impersonate-ff -V | grep -q zlib
./src/curl-impersonate-ff -V | grep -q brotli
./src/curl-impersonate-ff -V | grep -q nghttp2
./src/curl-impersonate-ff -V | grep -q NSS
$(info Build OK)
else
$(info Cross compiling, skipping checkbuild)
endif
.PHONY: firefox-checkbuild

firefox-install: ## Install the Firefox version of curl-impersonate after build
cd $(CURL_VERSION)
$(MAKE) install-exec MAKEFLAGS=
# Wrapper scripts for the Firefox version (e.g. 'curl_ff98')
install $(srcdir)/firefox/curl_ff* @bindir@
.PHONY: firefox-install

firefox-install-strip: ## Like 'firefox-install', but strip binaries for smaller size
cd $(CURL_VERSION)
$(MAKE) install-exec MAKEFLAGS=
# We could have used 'install-strip' but then the docs would be installed as well.
# Instead strip manually.
$(STRIP) @bindir@/curl-impersonate-ff
# Wrapper scripts for the Firefox version (e.g. 'curl_ff98')
install $(srcdir)/firefox/curl_ff* @bindir@
.PHONY: firefox-install-strip

firefox-uninstall: ## Uninstall the Firefox version of curl-impersonate after 'make install'
cd $(CURL_VERSION)
$(MAKE) uninstall MAKEFLAGS=
rm -Rf @bindir@/curl_ff*
.PHONY: firefox-uninstall

firefox-clean: ## Clean build artifacts of the Firefox version. Use after re-running './configure'
cd $(CURL_VERSION)
$(MAKE) clean MAKEFLAGS=
rm -f .firefox
.PHONY: firefox-clean

chrome-build: $(CURL_VERSION)/.chrome ## Build the Chrome version of curl-impersonate
cd $(CURL_VERSION)
# Don't pass this Makefile's MAKEFLAGS
Expand All @@ -138,7 +89,7 @@ chrome-install: ## Install the Chrome version of curl-impersonate after build
cd $(CURL_VERSION)
$(MAKE) install-exec MAKEFLAGS=
# Wrapper scripts for the Chrome version (e.g. 'curl_chrome99')
install $(srcdir)/chrome/curl_chrome* $(srcdir)/chrome/curl_edge* $(srcdir)/chrome/curl_safari* @bindir@
install $(srcdir)/chrome/curl_* @bindir@
.PHONY: chrome-install

chrome-install-strip: ## Like 'chrome-install', but strip binaries for smaller size
Expand Down
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# curl-impersonate ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png "Chrome") ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png "Edge") ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") ![Safari](https://github.com/alrra/browser-logos/blob/main/src/safari/safari_24x24.png "Safari")
# curl-impersonate ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png "Chrome") ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png "Edge") ![Safari](https://github.com/alrra/browser-logos/blob/main/src/safari/safari_24x24.png "Safari")
[![Build and test](https://github.com/yifeikong/curl-impersonate/actions/workflows/build-and-test-make.yml/badge.svg)](https://github.com/yifeikong/curl-impersonate/actions/workflows/build-and-test-make.yml)
[![Docker images](https://github.com/yifekong/curl-impersonate/actions/workflows/build-and-test-docker.yml/badge.svg)](https://github.com/yifeikong/curl-impersonate/actions/workflows/build-and-test-docker.yml)

> [!NOTE]
> This is a maintained fork of [curl-impersonate](https://github.com/lwthiker/curl-impersonate). Chrome's fingerprints has changed a lot since the last update of upstream, use this fork if your impersonation is not working.
A special build of [curl](https://github.com/curl/curl) that can impersonate the four major browsers: Chrome, Edge, Safari & Firefox. curl-impersonate is able to perform TLS and HTTP handshakes that are identical to that of a real browser.
A special build of [curl](https://github.com/curl/curl) that can impersonate the four major browsers: Chrome, Edge, Safari. curl-impersonate is able to perform TLS and HTTP handshakes that are identical to that of a real browser.

curl-impersonate can be used either as a command line tool, similar to the regular curl, or as a library that can be integrated instead of the regular libcurl. See [Usage](#Basic-usage) below.

Expand All @@ -21,7 +21,7 @@ With the modified curl in this repository, the TLS and HTTP handshakes look *exa
## How?

To make this work, `curl` was patched significantly to resemble a browser. Specifically, The modifications that were needed to make this work:
* Compiling curl with nss, the TLS library that Firefox uses, instead of OpenSSL. For the Chrome version, compiling with BoringSSL, Google's TLS library.
* For the Chrome version, compiling with BoringSSL, Google's TLS library.
* Modifying the way curl configures various TLS extensions and SSL options.
* Adding support for new TLS extensions.
* Changing the settings that curl uses for its HTTP/2 connections.
Expand All @@ -47,13 +47,6 @@ The following browsers can be impersonated.
| ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png "Chrome") | 99 | 99.0.4844.73 | Android 12 | `chrome99_android` | [curl_chrome99_android](chrome/curl_chrome99_android) |
| ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png "Edge") | 99 | 99.0.1150.30 | Windows 10 | `edge99` | [curl_edge99](chrome/curl_edge99) |
| ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png "Edge") | 101 | 101.0.1210.47 | Windows 10 | `edge101` | [curl_edge101](chrome/curl_edge101) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 91 ESR | 91.6.0esr | Windows 10 | `ff91esr` | [curl_ff91esr](firefox/curl_ff91esr) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 95 | 95.0.2 | Windows 10 | `ff95` | [curl_ff95](firefox/curl_ff95) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 98 | 98.0 | Windows 10 | `ff98` | [curl_ff98](firefox/curl_ff98) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 100 | 100.0 | Windows 10 | `ff100` | [curl_ff100](firefox/curl_ff100) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 102 | 102.0 | Windows 10 | `ff102` | [curl_ff102](firefox/curl_ff102) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 109 | 109.0 | Windows 10 | `ff109` | [curl_ff109](firefox/curl_ff109) |
| ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") | 117 | 117.0.1 | Windows 10 | `ff117` | [curl_ff117](firefox/curl_ff117) |
| ![Safari](https://github.com/alrra/browser-logos/blob/main/src/safari/safari_24x24.png "Safari") | 15.3 | 16612.4.9.1.8 | MacOS Big Sur | `safari15_3` | [curl_safari15_3](chrome/curl_safari15_3) |
| ![Safari](https://github.com/alrra/browser-logos/blob/main/src/safari/safari_24x24.png "Safari") | 15.5 | 17613.2.7.1.8 | MacOS Monterey | `safari15_5` | [curl_safari15_5](chrome/curl_safari15_5) |
| ![Safari](https://github.com/alrra/browser-logos/blob/main/src/safari/safari_24x24.png "Safari") | 17.0 | unclear | MacOS Sonoma | `safari17_0` | [curl_safari17_0](chrome/curl_safari17_0) |
Expand Down Expand Up @@ -85,7 +78,7 @@ See [Advanced usage](#Advanced-usage) for more options, including using `libcurl
More documentation is available in the [docs/](docs/README.md) directory.

## Installation
There are two versions of `curl-impersonate` for technical reasons. The **chrome** version is used to impersonate Chrome, Edge and Safari. The **firefox** version is used to impersonate Firefox.
There are two versions of `curl-impersonate` for technical reasons. The **chrome** version is used to impersonate Chrome, Edge and Safari.

### Pre-compiled binaries
Pre-compiled binaries for Windows, Linux and macOS are available at the [GitHub releases](https://github.com/yifeikong/curl-impersonate/releases) page. Before you use them you need to install nss (Firefox's TLS library) and CA certificates:
Expand Down Expand Up @@ -113,10 +106,6 @@ See [INSTALL.md](INSTALL.md).
Docker images based on Alpine Linux and Debian with `curl-impersonate` compiled and ready to use are available on [Docker Hub](https://hub.docker.com/r/lwthiker/curl-impersonate). The images contain the binary and all the wrapper scripts. Use like the following:
```bash
# Firefox version, Alpine Linux
docker pull lwthiker/curl-impersonate:0.5-ff
docker run --rm lwthiker/curl-impersonate:0.5-ff curl_ff109 https://www.wikipedia.org

# Chrome version, Alpine Linux
docker pull lwthiker/curl-impersonate:0.5-chrome
docker run --rm lwthiker/curl-impersonate:0.5-chrome curl_chrome110 https://www.wikipedia.org
Expand Down Expand Up @@ -176,7 +165,6 @@ In particular, see the [note about the Firefox version](INSTALL.md#a-note-about-

This repository contains two main folders:
* [chrome](chrome) - Scripts and patches for building the Chrome version of `curl-impersonate`.
* [firefox](firefox) - Scripts and patches for building the Firefox version of `curl-impersonate`.

The layout is similar for both. For example, the Firefox directory contains:
* [Dockerfile](firefox/Dockerfile) - Used to build `curl-impersonate` with all dependencies.
Expand Down
2 changes: 1 addition & 1 deletion chrome/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RUN cd ${NGHTTP2_VERSION} && \
make && make install

# Download curl.
ARG CURL_VERSION=curl-8.1.1
ARG CURL_VERSION=curl-8.5.0
RUN curl -o ${CURL_VERSION}.tar.xz https://curl.se/download/${CURL_VERSION}.tar.xz
RUN tar xf ${CURL_VERSION}.tar.xz

Expand Down
2 changes: 1 addition & 1 deletion chrome/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RUN cd ${NGHTTP2_VERSION} && \
make && make install

# Download curl.
ARG CURL_VERSION=curl-8.1.1
ARG CURL_VERSION=curl-8.5.0
RUN curl -o ${CURL_VERSION}.tar.xz https://curl.se/download/${CURL_VERSION}.tar.xz
RUN tar xf ${CURL_VERSION}.tar.xz

Expand Down
1 change: 1 addition & 0 deletions chrome/curl_chrome100
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome101
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome104
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome107
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome110
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps --tls-permute-extensions \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome116
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps --tls-permute-extensions \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome119
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ dir=${0%/*}
--ech GREASE \
--tlsv1.2 --alps --tls-permute-extensions \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome120
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ dir=${0%/*}
--ech GREASE \
--tlsv1.2 --alps --tls-permute-extensions \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome99
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_chrome99_android
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_edge101
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_edge99
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dir=${0%/*}
--compressed \
--tlsv1.2 --alps \
--cert-compression brotli \
--tls-grease \
"$@"
28 changes: 28 additions & 0 deletions chrome/curl_firefox120
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Find the directory of this script
dir=${0%/*}

# The list of ciphers can be obtained by looking at the Client Hello message in
# Wireshark, then converting it using the cipherlist array at
# https://github.com/curl/curl/blob/master/lib/vtls/nss.c
"$dir/curl-impersonate-chrome" \
--ciphers "TLS_AES_128_GCM_SHA256,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA" \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/120.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \
-H 'Accept-Language: en-US,en;q=0.5' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'Sec-Fetch-Dest: document' \
-H 'Sec-Fetch-Mode: navigate' \
-H 'Sec-Fetch-Site: none' \
-H 'Sec-Fetch-User: ?1' \
-H 'TE: Trailers' \
--http2 \
--http2-settings '1:65536;4:131072;5:16384' \
--http2-streams '3:0:0:201,5:0:0:101,7:0:0:1,9:0:7:1,11:0:3:1,13:0:0:241' \
--http2-window-update 12517377 \
--http2-pseudo-headers-order 'mpas' \
--compressed \
--ech GREASE \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_safari15_3
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dir=${0%/*}
--http2-window-update 10485760 \
--compressed \
--tlsv1.0 --no-tls-session-ticket \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_safari15_5
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ dir=${0%/*}
--compressed \
--tlsv1.0 --no-tls-session-ticket \
--cert-compression zlib \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_safari17_0
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dir=${0%/*}
--compressed \
--tlsv1.0 --no-tls-session-ticket \
--cert-compression zlib \
--tls-grease \
"$@"
1 change: 1 addition & 0 deletions chrome/curl_safari17_2_ios
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dir=${0%/*}
--compressed \
--tlsv1.0 --no-tls-session-ticket \
--cert-compression zlib \
--tls-grease \
"$@"
Loading

0 comments on commit a8c85e8

Please sign in to comment.