Commit Graph
63 Commits
Author SHA1 Message Date
lwthiker 5682b021d6 Add Safari impersonation support to libcurl
Safari can now be imperonsated with libcurl using
curl_easy_impersonate() with the "safari15_3" target or by setting the
env var CURL_IMPERSONATE to "safari15_3".

curl patch from
https://github.com/lwthiker/curl/commit/0340cd8b3e0f85ba1105d75587e36c45c5b3f2bb
2022-03-03 16:57:26 +02:00
lwthiker f9afe9cf63 Add wrapper script to impersonate Safari 15.3
Add a new wrapper script that impersonates Safari 15.3 on MacOS 11.6.4
("Big Sur"). The wrapper script uses command line arguments
previously added to "curl-impersonate" for that purpose:
* --curves
* --signature-hashes
* --no-tls-session-ticket
* --http2-pseudo-headers-order
2022-03-03 16:16:13 +02:00
lwthiker 8bc8019152 Small refactor to the testing code 2022-03-03 15:29:41 +02:00
lwthiker 2ea7458239 Add control over HTTP/2 pseudo-headers order
Add the ability to control the order of the HTTP/2 pseudo-headers. Each
browser uses a different order for the ":method", ":authority",
":scheme" and ":path" pseudo-headers. It is therefore desirable to be
able to control it. The CURLOPT_HTTP2_PSEUDO_HEADERS_ORDER libcurl
option and '--http2-pseudo-headers-order' command line option now allow
doing that.

Patch from
https://github.com/lwthiker/curl/commit/dd4b76241ed2d099ed7938d5c7db56b86cbaf710
2022-03-03 15:25:23 +02:00
lwthiker 979750a072 Merge pull request #16 from lwthiker/tls_options
Make some of the TLS options configurable
2022-03-03 15:20:02 +02:00
lwthiker e897975660 Update README.md 2022-03-03 15:16:27 +02:00
lwthiker c1aa0bb50c Make TLS session ticket extension configurable
A previous commit has enabled the TLS session ticket extension (by
removing SSL_OP_NO_TICKET) because Chrome uses it. This commit makes it
configurable via the CURLOPT_SSL_ENABLE_TICKET libcurl option or the
'--tls-session-ticker' command line flag. The goal is to impersonate
Safari which, as of version 15.3, does not use TLS session tickets.
2022-03-03 12:16:30 +02:00
lwthiker bafc1416e3 Add full support for TLS certificate compression
This commit adds:
* Support for configuring the TLS certificate compression algorithms the
client is willing to receive via the CURLOPT_SSL_CERT_COMPRESSION option or
the '--cert-compression' command line flag.
* Support for decompressing zlib-compressed certificates in addition to
brotli.

Previously brotli decompression only was available and it was hardcoded
into the binary.
2022-03-02 15:23:24 +02:00
lwthiker 87ed6a2792 Make some of the TLS options configurable
This commit makes some of the TLS options that are used for
impersonation configurable via libcurl options and command line flags to
curl-impersonate. The goal is to give more flexibility in configuring
the TLS extensions instead of hardcoding everything into the binary.
This will enable using the same binary for impersonating different
browsers (e.g. Safari).

The following options are now present:
* CURLOPT_SSL_EC_CURVES and the '--curves' flag are now usable. These
were present in the upstream curl but only for OpenSSL builds. This
commit also enables them for BoringSSL. They configure TLS extension
'supported_groups' (no. 10).
* CURLOPT_SSL_ENABLE_NPN and the '--no-npn' flags are usable. These were
present in the upstream curl but were disabled in a previous commit by
commenting out the relevant code (as Chrome disables NPN). They now work
and the wrapper scripts use the '--no-npn' flag.
* CURLOPT_SSL_ENABLE_ALPS and the '--alps' flag were added. These
control the ALPS TLS extension that Chrome uses.
* CURLOPT_SSL_SIG_HASH_ALGS and the '--signature-hashes' option were
added. These control the clien't list of supported signature & hash
algorithms, i.e. TLS extension 'signature_algorithms' (no. 13).
2022-03-02 10:28:35 +02:00
lwthiker 051ccfd5e6 Merge pull request #15 from lwthiker/boringssl_old_ciphers
Restore old ciphers in BoringSSL
2022-03-02 09:33:36 +02:00
lwthiker ce36fa86a1 Merge pull request #13 from lwthiker/libcurl-impersonate
Add impersonation support to libcurl
2022-02-28 10:25:27 +02:00
lwthiker a7cbfd9fed Add libcurl impersonation support in Firefox build
48415a4b00 added impersonation
capabilities to libcurl in the Chrome build. This adds the same
capabilities to the Firefox build as well.

curl-impersonate.patch generated from
https://github.com/lwthiker/curl/commit/b30b245b722dbe9765615e3f316e9a7dab99bbf9
2022-02-28 10:18:04 +02:00
lwthiker 00dc027185 Update README.md 2022-02-27 23:56:35 +02:00
lwthiker 4e2e782e5f Add Edge 98 signature to libcurl-impersonate 2022-02-27 23:48:17 +02:00
lwthiker 839e4e6ea7 Merge branch 'main' into libcurl-impersonate 2022-02-27 23:38:49 +02:00
lwthiker 6dad23b4b8 Add tests for libcurl-impersonate
Test that libcurl-impersonate produces the desired TLS signature when
the CURL_IMPERSONATE env var is set. A small C program called "minicurl"
is linked to libcurl, and libcurl-impersonate is loaded at runtime with
LD_PRELOAD.
2022-02-27 23:21:00 +02:00
lwthiker f4474a87e8 Restore old ciphers in BoringSSL
BoringSSL removed some old and weak cipehrs from OpenSSL. It appears as
though Safari still uses some of them.

The included patch restores them, so that using them in the "--ciphers"
option to curl will add them to the client's list of supported ciphers.
These ciphers may not actually work if the server chooses to use them,
because the "real" code to handle them is missing. But since they are
considered weak it is unlikely to happen.
2022-02-27 14:07:38 +02:00
lwthiker b918636a5b Merge pull request #14 from lwthiker/impersonate_edge
Impersonate Microsoft Edge
2022-02-27 13:48:01 +02:00
lwthiker f0b2061a68 Impersonate Edge
Microsoft Edge is, since 2019, based on Chromium. It has a completely
identical TLS signature to Chrome's. The only difference is in the HTTP
headers. Adding support for impersonating Edge was therefore extremely
simple.
2022-02-26 22:50:11 +02:00
lwthiker d4e4fbf99d Update README.md 2022-02-26 13:10:15 +02:00
lwthiker 8714c4631c Update README.md about libcurl-impersonate 2022-02-26 12:48:17 +02:00
lwthiker 48415a4b00 Add impersonation support to libcurl
Patch generated from https://github.com/lwthiker/curl/commit/e8cd43c8ebd2624b3c635ec96b165c28f675cdf2

Add curl_easy_impersonate() API function that sets the needed options
on the curl 'easy' handle. It sets the various TLS options needed for
impersonation and the HTTP headers that the browser sends by default.

In addition, libcurl will check for the environment variable
CURL_IMPERSONATE when curl_easy_init() is called, and if it exists it
will call curl_easy_impersonate() internally. This theoretically allows
replacing an existing libcurl by setting the LD_LIBRARY_PATH and
CURL_IMPERSONATE env vars, without having to recompile the app.
2022-02-26 12:23:09 +02:00
lwthiker d22e09eb4a Compile libcurl.so in addition to curl-impersonate
In addition to the statically linked curl-impersonate binary, compile
libcurl.so for dynamic linking as well. The output file is saved at
/build/out/libcurl-impersonate.so.

Also strip the output binaries to reduce their size.

For now, support is for the Chrome build only.
2022-02-26 12:21:24 +02:00
lwthiker df7df8e247 Merge pull request #12 from lwthiker/consolidate_patches
Consolidate curl's patch files
2022-02-26 11:21:26 +02:00
lwthiker 46d5d21941 Consolidate curl's patch files
Consolidate all of curl's patch files into a single file (one for each
browser). The modified curl source code is now maintained in Git (at
    https://github.com/lwthiker/curl) and it is easier to just
generate the needed patch with 'git --diff'.
2022-02-25 22:27:03 +02:00
lwthiker 0f7b39a367 Merge pull request #11 from lwthiker/readme_arch
Add link to AUR packages in README.md
2022-02-25 11:35:03 +02:00
lwthiker 1f740c5d51 Add link to AUR packages in README.md 2022-02-23 23:00:21 +02:00
lwthiker 767cf57215 Merge pull request #9 from lwthiker/automated_tests
Add automated tests to verify curl's TLS signature
v0.2.0
2022-02-23 13:35:31 +02:00
lwthiker 6e672bc719 Add automated tests to verify curl's TLS signature
Add automated testing infrastructure with tests verifying that
`curl-impersonate` has the same TLS signature as that of the
impersonated browser.

Each wrapper script (e.g. curl_chrome98) is launched to wikipedia.org
while a packet capture is running in the background. The Client Hello
is extracted from the capture, parsed and then compared to the known
browser signature.

The known signatures are stored in a YAML database.
2022-02-22 18:10:18 +02:00
lwthiker b1081c5a11 Merge pull request #6 from lwthiker/firefox_http2_headers
Fix the order of HTTP2 headers in Firefox
2022-02-21 16:33:32 +02:00
lwthiker cbeb9fb9c6 Update README.md with new blog post link
Add link to the new blog post about impersonating Chrome.
2022-02-20 15:08:37 +02:00
lwthiker 4f71a1650e Fix the order of HTTP2 headers in Firefox
After inspecting an encrypted TLS session, I noticed that Firefox
sends the HTTP2 pseudo headers in the order :method, :path, :authority,
:scheme while curl was sending them with :authority being the last one.

This patch fixes the order of HTTP2 headers in curl to match Firefox.
2022-02-19 20:34:43 +02:00
lwthiker 248e737d62 Update README.md 2022-02-19 15:52:07 +02:00
lwthiker bd721758c7 Fix binary names 2022-02-19 15:34:19 +02:00
lwthiker 7d41696c84 Update README.md 2022-02-19 15:27:32 +02:00
lwthiker 6f7273fb88 Merge pull request #4 from lwthiker/impersonate_chrome
Impersonate Chrome by building curl with BoringSSL and modifying its TLS and HTTP/2 parameters.
2022-02-19 15:12:15 +02:00
lwthiker f08db5c1cc Move build files to 'firefox' folder
In preparation for merging the support for Chrome impersonation, move
all build files to the 'firefox' folder. The two builds will live
separately as they are rather different (using two different SSL
libraries for instance).
2022-02-19 15:10:29 +02:00
lwthiker 1b41b6de84 Add --compressed flag by default
Similar to https://github.com/lwthiker/curl-impersonate/pull/5
2022-02-19 14:55:50 +02:00
lwthiker 367f91922d Move Chrome related files to their own directory
Building curl-impersonate with Chrome impersonation requires a different
compilation and a different set of patches which may conflict with the
Firefox impersonation. Therefore we will treat them a separate builds.
All chrome related files were moved to the chrome/ directory.
2022-02-19 11:05:20 +02:00
lwthiker a9d285aee4 Merge pull request #5 from lwthiker/use_compressed
Use --compressed flag by default
2022-02-19 09:39:37 +02:00
lwthiker 43b74105e5 Use --compressed flag by default
Because we send the 'Accept-Encoding: gzip, deflate, br' header we
may receive compressed content (gzip or brotli). Previously this was
handled manually in the wrapper script, however curl has a '--compressed'
flag exactly for that purpose. Add it by default to the wrapper scripts.
2022-02-19 09:37:20 +02:00
lwthiker 72cb415d59 Update README.md 2022-02-19 09:31:48 +02:00
lwthiker 62cfde29fa Merge pull request #2 from WeebDataHoarder/main
Adds support for brotli content decoding
2022-02-19 09:28:43 +02:00
lwthiker 01b4a33c82 Fix Curl's HTTP/2 headers to match Chrome's headers
* Change the default HTTP/2 settings sent by Curl to match the ones that
Chrome sends. They appear in the SETTINGS message in the beginning of
the HTTP/2 handshake, which can be seen only after decrypting the TLS
traffic.
* Change the order of the HTTP/2 pseudo-headers ":authority", ":scheme"
and ":path" in the HEADERS message. Curl sent them in a different order
than Chrome.
2022-02-19 00:49:01 +02:00
lwthiker 647c4f428c Finalize TLS Client Hello to impersonate Chrome 2022-02-19 00:48:26 +02:00
lwthiker b7d9388bf3 Improve curl-impersonate for Chrome
* Enable TLS extension 35 (session_ticket) which Curl turned off.
* Set the signature algorithms to match Chrome's.
* Fix the headers to exactly match Chrome.

It seems that the Client Hello message is now identical to Chrome.
However, it is still getting rejected.
2022-02-18 19:47:59 +02:00
lwthiker be4da0e70a First attempt at impersonating Chrome
* Headers and ciphers are aligned to Chrome 98 (Windows, non-incognito)
* GREASE enabled because chrome uses it as well
* TLS extensions 27, 5, 18 enabled.
2022-02-18 18:07:28 +02:00
DataHoarder 5960b786d4 Adds support for brotli content decoding, fixes lwthiker/curl-impersonate#1 2022-02-18 12:28:08 +01:00
lwthiker b00ad551b6 Add support for impersonating Firefox ESR 91
As suggested on the Hacker News thread
(https://news.ycombinator.com/item?id=30378562), add support for Firefox
Extended Support Release.

The required changes were adding one more cipher to the
ciphers list and changing the user agent. Apart from that the TLS
fingerprint is identical to Firefox 95 which was already supported.
2022-02-18 07:59:53 +02:00
lwthiker 4fe2fd36af Update README.md 2022-02-17 22:44:24 +02:00