Skip to content

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox

Merge branch 'main' into libcurl-impersonate

lwthiker839e4e6ea7ec
diff --cc README.md
index b4a0a02,17ecd2d..ad08bea
--- a/README.md
+++ b/README.md
@@@ -30,7 -30,7 +30,8 @@@ docker build -t curl-impersonate-chrom
The resulting image contains:
* `/build/out/curl-impersonate` - The curl binary that can impersonate Chrome. It is compiled statically against libcurl, BoringSSL, and libnghttp2 so that it won't conflict with any existing libraries on your system. You can use it from the container or copy it out. Tested to work on Ubuntu 20.04.
* `/build/out/curl_chrome98` - A wrapper script that launches `curl-impersonate` with the needed headers and ciphers to impersonate Chrome 98.
+ * `/build/out/curl_edge98` - Same but with Edge 98 (which is based on Chromium).
+* `/build/out/libcurl-impersonate.so` - libcurl compiled with impersonation support. See [Usage](#usage) below for more details.
You can use them inside the docker, copy them out using `docker cp` or use them in a multi-stage docker build. If you use it outside this container:
* Install dependencies: `sudo apt install libbrotli1`
diff --cc chrome/Dockerfile
index 00f2925,63e0076..23afa4f
--- a/chrome/Dockerfile
+++ b/chrome/Dockerfile
@@@ -67,29 -67,13 +67,29 @@@ RUN cd ${CURL_VERSION} &&
./configure --with-openssl=/build/boringssl/build --enable-static --disable-shared --with-nghttp2=/usr/local LIBS="-pthread" CFLAGS="-I/build/boringssl/build" USE_CURL_SSLKEYLOGFILE=true && \
make
-# 'xxd' is needed for the wrapper script
-RUN apt-get install -y xxd
-
RUN mkdir out && \
- cp ${CURL_VERSION}/src/curl out/curl-impersonate
+ cp ${CURL_VERSION}/src/curl out/curl-impersonate && \
+ strip out/curl-impersonate
-# Wrapper script
+# Re-compile libcurl dynamically
+RUN cd ${CURL_VERSION} && \
+ ./configure --enable-versioned-symbols \
+ --with-openssl=/build/boringssl/build \
+ --with-nghttp2=/usr/local \
+ LIBS="-pthread" \
+ CFLAGS="-I/build/boringssl/build" \
+ USE_CURL_SSLKEYLOGFILE=true && \
+ make clean && make
+
+# Rename to 'libcurl-impersonate' to avoid confusion, and recreate the
+# symbolic links.
+RUN ver=$(readlink -f curl-7.81.0/lib/.libs/libcurl.so | sed 's/.*so\.//') && \
+ major=$(echo -n $ver | cut -d'.' -f1) && \
+ cp "${CURL_VERSION}/lib/.libs/libcurl.so.$ver" "out/libcurl-impersonate.so.$ver" && \
+ ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so.$major" && \
+ ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \
+ strip "out/libcurl-impersonate.so.$ver"
+
+# Wrapper scripts
- COPY curl_chrome* out/
+ COPY curl_chrome* curl_edge* out/
-
-RUN chmod +x out/*
+RUN chmod +x out/curl_*
diff --cc tests/test_impersonate.py
index f1e12e4,8a6adb8..45a532f
--- a/tests/test_impersonate.py
+++ b/tests/test_impersonate.py
@@@ -177,24 -176,12 +177,25 @@@ class TestImpersonation
return None
@pytest.mark.parametrize(
- "curl_binary, expected_signature",
+ "curl_binary, env_vars, expected_signature",
[
- ("chrome/curl_chrome98", "chrome_98.0.4758.102_win10"),
- ("chrome/curl_edge98", "edge_98.0.1108.62_win10"),
- ("firefox/curl_ff91esr", "firefox_91.6.0esr_win10"),
- ("firefox/curl_ff95", "firefox_95.0.2_win10")
+ # Test wrapper scripts
+ ("chrome/curl_chrome98", None, "chrome_98.0.4758.102_win10"),
++ ("chrome/curl_edge98", None, "edge_98.0.1108.62_win10"),
+ ("firefox/curl_ff91esr", None, "firefox_91.6.0esr_win10"),
+ ("firefox/curl_ff95", None, "firefox_95.0.2_win10"),
+
+ # Test libcurl-impersonate by loading it with LD_PRELOAD to an app
+ # linked against the regular libcurl and setting the
+ # CURL_IMPERSONATE env var.
+ (
+ "./minicurl",
+ {
+ "LD_PRELOAD": "./chrome/libcurl-impersonate.so",
+ "CURL_IMPERSONATE": "chrome98"
+ },
+ "chrome_98.0.4758.102_win10"
+ )
]
)
def test_impersonation(self,