Skip to content

Commit b1e0e87

Browse files
authored
Merge pull request #4 from Notifysolutions/dev
add firefox98 tls-fingerprint
2 parents 2df1c09 + 639b459 commit b1e0e87

File tree

7 files changed

+739
-1723
lines changed

7 files changed

+739
-1723
lines changed

Dockerfile

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Python is needed for building libnss.
99
# Use it as a common base.
10-
FROM python:3.10.1-slim-buster as builder
10+
FROM python:3.10.1-slim-bullseye as builder
1111

1212
WORKDIR /build
1313

@@ -19,8 +19,14 @@ RUN apt-get update && \
1919
# both for libnghttp2 and curl.
2020
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
2121

22-
# Dependencies for downloading and building BoringSSL
23-
RUN apt-get install -y g++ golang-go unzip
22+
# Dependencies for building libnss
23+
# See https://firefox-source-docs.mozilla.org/security/nss/build.html#mozilla-projects-nss-building
24+
RUN apt-get install -y mercurial python3-pip
25+
26+
# curl tries to load the CA certificates for libnss.
27+
# It loads them from /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so,
28+
# which is supplied by libnss3 on Debian/Ubuntu
29+
RUN apt-get install -y libnss3
2430

2531
# Download and compile libbrotli
2632
ARG BROTLI_VERSION=1.0.9
@@ -31,28 +37,18 @@ RUN cd brotli-${BROTLI_VERSION} && \
3137
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed .. && \
3238
cmake --build . --config Release --target install
3339

34-
# BoringSSL doesn't have versions. Choose a commit that is used in a stable
35-
# Chromium version.
36-
ARG BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080
37-
RUN curl -L https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip -o boringssl.zip && \
38-
unzip boringssl && \
39-
mv boringssl-${BORING_SSL_COMMIT} boringssl
40-
41-
# Compile BoringSSL.
42-
# See https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md
43-
COPY patches/boringssl-*.patch boringssl/
44-
RUN cd boringssl && \
45-
for p in $(ls boringssl-*.patch); do patch -p1 < $p; done && \
46-
mkdir build && cd build && \
47-
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=on -GNinja .. && \
48-
ninja
40+
# Needed for building libnss
41+
RUN pip install gyp-next
42+
43+
ARG NSS_VERSION=nss-3.77
44+
# This tarball is already bundled with nspr, a dependency of libnss.
45+
ARG NSS_URL=https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_77_RTM/src/nss-3.77-with-nspr-4.32.tar.gz
4946

50-
# Fix the directory structure so that curl can compile against it.
51-
# See https://everything.curl.dev/source/build/tls/boringssl
52-
RUN mkdir boringssl/build/lib && \
53-
ln -s ../crypto/libcrypto.a boringssl/build/lib/libcrypto.a && \
54-
ln -s ../ssl/libssl.a boringssl/build/lib/libssl.a && \
55-
cp -R boringssl/include boringssl/build
47+
# Download and compile nss.
48+
RUN curl -o ${NSS_VERSION}.tar.gz ${NSS_URL}
49+
RUN tar xf ${NSS_VERSION}.tar.gz && \
50+
cd ${NSS_VERSION}/nss && \
51+
./build.sh -o --disable-tests --static --python=python3
5652

5753
ARG NGHTTP2_VERSION=nghttp2-1.46.0
5854
ARG NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2
@@ -85,15 +81,15 @@ RUN cd ${CURL_VERSION} && \
8581
--disable-shared \
8682
--with-nghttp2=/build/${NGHTTP2_VERSION}/installed \
8783
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
88-
--with-openssl=/build/boringssl/build \
89-
LIBS="-pthread" \
90-
CFLAGS="-I/build/boringssl/build" \
84+
--with-nss=/build/${NSS_VERSION}/dist/Release \
85+
--with-nss-deprecated \
86+
CFLAGS="-I/build/${NSS_VERSION}/dist/public/nss -I/build/${NSS_VERSION}/dist/Release/include/nspr" \
9187
USE_CURL_SSLKEYLOGFILE=true && \
9288
make && make install
9389

9490
RUN mkdir out && \
95-
cp /build/install/bin/curl-impersonate-chrome out/ && \
96-
ln -s curl-impersonate-chrome out/curl-impersonate && \
91+
cp /build/install/bin/curl-impersonate-ff out/ && \
92+
ln -s curl-impersonate-ff out/curl-impersonate && \
9793
strip out/curl-impersonate
9894

9995
# Verify that the resulting 'curl' has all the necessary features.
@@ -112,18 +108,18 @@ RUN cd ${CURL_VERSION} && \
112108
./configure --prefix=/build/install \
113109
--with-nghttp2=/build/${NGHTTP2_VERSION}/installed \
114110
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
115-
--with-openssl=/build/boringssl/build \
116-
LIBS="-pthread" \
117-
CFLAGS="-I/build/boringssl/build" \
111+
--with-nss=/build/${NSS_VERSION}/dist/Release \
112+
--with-nss-deprecated \
113+
CFLAGS="-I/build/${NSS_VERSION}/dist/public/nss -I/build/${NSS_VERSION}/dist/Release/include/nspr" \
118114
USE_CURL_SSLKEYLOGFILE=true && \
119115
make clean && make && make install
120116

121117
# Copy libcurl-impersonate and symbolic links
122118
RUN cp -d /build/install/lib/libcurl-impersonate* /build/out
123119

124-
RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-chrome.so | sed 's/.*so\.//') && \
120+
RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-ff.so | sed 's/.*so\.//') && \
125121
major=$(echo -n $ver | cut -d'.' -f1) && \
126-
ln -s "libcurl-impersonate-chrome.so.$ver" "out/libcurl-impersonate.so.$ver" && \
122+
ln -s "libcurl-impersonate-ff.so.$ver" "out/libcurl-impersonate.so.$ver" && \
127123
ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \
128124
strip "out/libcurl-impersonate.so.$ver"
129125

@@ -132,26 +128,27 @@ RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-chrome.so |
132128
RUN ! (ldd ./out/curl-impersonate | grep -q -e nghttp2 -e brotli -e ssl -e crypto)
133129

134130
# Wrapper scripts
135-
COPY curl_chrome* curl_edge* curl_safari* out/
131+
COPY curl_ff* out/
132+
136133

137134
# Create a final, minimal image with the compiled binaries
138135
# only.
139-
FROM python:3.10-buster
136+
FROM ubuntu:22.10
137+
138+
RUN apt-get update && apt-get install -y ca-certificates
139+
RUN apt-get install -y libnss3 nss-plugin-pem wget python3 python3-pip
140140

141-
RUN apt update -y && apt install libbrotli-dev libunwind-dev libssl-dev libnghttp2-dev -y
142141
# Copy curl-impersonate from the builder image
143142
COPY --from=builder /build/install /usr/local
144143
RUN ldconfig
145-
# RUN apk add gcc libc-dev openssl-dev brotli
146-
147144
# Copy to /build/out as well for backward compatibility with previous versions.
148145
COPY --from=builder /build/out /build/out
149146
# Wrapper scripts
150147
COPY --from=builder /build/out/curl_* /usr/local/bin/
151148

152149
RUN wget https://github.com/pycurl/pycurl/archive/refs/tags/REL_7_45_2.tar.gz && tar -xzf REL_7_45_2.tar.gz
153-
154-
RUN cd pycurl-REL_7_45_2 && python3 setup.py install --curl-config=/usr/local/bin/curl-impersonate-chrome-config
155-
150+
RUN cd pycurl-REL_7_45_2 && python3 setup.py install --curl-config=/usr/local/bin/curl-impersonate-ff-config
156151
RUN pip install request_curl
157152

153+
CMD ["python3"]
154+

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,34 @@ response = s.post("https://httpbin.org/post", json=json_data)
127127
To use request_curl with [curl-impersonate](https://github.com/lwthiker/curl-impersonate),
128128
opt for our [custom Docker image](https://hub.docker.com/r/h3adex/request-curl-impersonate) by either pulling or building it.
129129
The image comes with request_curl and curl-impersonate pre-installed.
130-
Check below for a demonstration on impersonating chrome101 tls-fingerprint and request_curl with our custom Docker Image.
130+
Check below for a demonstration on impersonating firefox98 tls-fingerprint and request_curl with our custom Docker Image.
131131

132-
**Note**: This feature is still considered experimental.
132+
**Note**: This feature is still considered experimental. Only tested with firefox fingerprint
133133

134134
To pull the Docker image:
135135

136136
```bash
137-
docker pull h3adex/request-curl-impersonate:0.0.2
137+
docker pull h3adex/request-curl-impersonate:latest
138138
docker run --rm -it h3adex/request-curl-impersonate
139139
```
140140

141141
Example Python code for a target website:
142142

143143
```python
144144
import request_curl
145-
from request_curl import CHROME_CIPHER_SUITE, CHROME_HEADERS
146-
147-
# impersonates chrome101
148-
session = request_curl.Session(http2=True, cipher_suite=CHROME_CIPHER_SUITE, headers=CHROME_HEADERS)
149-
response = session.get("https://google.com")
145+
from request_curl import FIREFOX98_CIPHER_SUITE, FIREFOX98_HEADERS
146+
147+
# impersonates ff98
148+
session = request_curl.Session(
149+
http2=True,
150+
cipher_suite=FIREFOX98_CIPHER_SUITE,
151+
headers=FIREFOX98_HEADERS
152+
)
153+
response = session.get("https://tls.browserleaks.com/json")
150154
# <Response [200]>
155+
# "ja3_hash":"25e9b0dd5b8e9330b206eae87e885e19"
156+
# same result as:
157+
# docker run --rm lwthiker/curl-impersonate:0.5-ff curl_ff98 https://tls.browserleaks.com/json
151158
```
152159

153160
# Contributing

patches/boringssl-old-ciphers.patch

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)