Commit Graph

27 Commits

Author SHA1 Message Date
lwthiker
fffab4bcc1 Update upstream curl version to 7.84 2022-07-17 16:44:22 +03:00
lwthiker
e5670826ba Add impersonation support for Safari 15.5 2022-07-05 08:22:07 +03:00
lwthiker
9d9e393d0e Move curl-impersonate options to separate files
For better organization, move the curl-impersonate impersonation
definitions to a separate impersonate.c and impersonate.h files.
2022-07-05 07:51:37 +03:00
lwthiker
6080446ef4 Set HTTP/2 stream settings correctly
HTTP/2 includes various settings pertaining to stream priorities. Chrome
and Firefox handle them differently, and this behavior was not mimicked
in curl-impersonate well. With this commit, the stream settings set
by curl-impersonate are identical to the real browsers.

* With Chrome, the default stream weight is 256 and the "exclusive bit"
is set to ON.
* With Firefox, a complex tree of stream dependencies is created
by default using PRIORITY frames. This behavior is now mimicked by
curl-impersonate.
2022-05-29 16:45:17 +03:00
lwthiker
82bca6dab7 Handle curl_easy_reset() calls when impersonating (#44)
curl_easy_reset() may be used by an application to reset the options on
a curl handle. If an app has the CURL_IMPERSONATE env var defined, then
the impersonation options are automatically set in curl_easy_init() but
will be cleared in a call to curl_easy_reset(). The desired behavior is
for the impersonation options to be retained (as they are "transparent"
to the user), which this commit takes care of.

Note that this only has an effect when libcurl-impersonate is loaded and
the CURL_IMPERSONATE env var is set. Otherwise the regular behavior of
resetting all the handle options is retained.

Test that the unique TLS signature of curl-impersonate is preserved
after a call to curl_easy_reset() when libcurl-impersonate is loaded.
For this purpose change the 'minicurl' testing util to support multiple
URLs and launch it with 2 different URLs when testing the TLS signature.
2022-05-18 11:43:46 +03:00
lwthiker
14de5bb0db Add impersonation support for Chrome 100 and 101
.. and for Edge 101 as well. The TLS fingerprint is identical to
previous versions. The HTTP headers have the usual differences in the
user agents. One important change though is in the way the HTTP2
SETTINGS frame is formed. Up until Chrome 98, there was an additional
randomly-generated setting in the frame. This seems to have been removed
since. Therefore it was removed from curl-impersonate as well, and
support for Chrome/Edge 98 was deprecated, since supporting both
signatures requires a lot of work.
2022-05-17 20:53:39 +03:00
lwthiker
5846364b95 Fix bug causing a wrong 'Host' header
When reusing a curl handle on which the 'Host' header was explicitly
set, the previously-set header was being kept in use for following
requests.

The issue was in curl-impersonate's merging of user-supplied headers
with its own list of browser headers. The call to
Curl_http_merge_headers() which takes care of this had been placed after
the handling of the host header, which caused the previous one to be
used.
2022-05-14 21:09:14 +03:00
lwthiker
0c6d1ab92b Improve HTTP/2 impersonation
* Set curl's HTTP/2 window size to match Chrome and Firefox. This
affects the "Window Size Increment" parameter in the WINDOW_UPDATE
HTTP/2 frame sent out by curl, which was different than the one
sent by Chrome or Firefox.

* Set curl's HTTP/2 SETTINGS frame to match Firefox.
2022-05-04 08:20:26 +03:00
lwthiker
31ed18d312 Change libbrotli compilation flags for macOS
macOS doesn't support the '-Bstatic' flag. Remove it as it is not really
needed (the linker will find the static libraries by their name).
2022-04-17 17:24:27 +03:00
lwthiker
d7ed859ad0 Change nghttp2 link flags to support macOS
Previously '-l:nghttp2.a' was used to specify static linking with
nghttp2 and to stop the linker from linking dynamically with
libnghttp2.so. This way of linking is not supported on macOS. Instead,
add '--disable-shared' to prevent libnghttp2.so from even being
compiled. This way the linker will find the static library only and link
against it.
2022-04-17 17:01:15 +03:00
lwthiker
922a8bb72e Support encoded content in curl_easy_impersonate
Set CURLOPT_ACCEPT_ENCODING to an empty string in
curl_easy_impersonate() to enable decompression of encoded responses
using all built-in compressions. This is similar to adding
'--compressed' in the command line curl and is necessary since
curl_easy_impersonate() adds the 'Accept-Encoding' header which may
cause the server to respond with compressed content.
2022-04-17 12:50:16 +03:00
lwthiker
8ffeb3ca56 Change binary names as part of curl's build
Change the binary names of curl and libcurl as part of the curl build
process by patching curl's build scripts. When running 'make' in the
patched curl directory the resulting binaries will be already named
'curl-impersonate-ff' and 'curl-impersonate-chrome' (and the same for
libcurl), thus saving the need for manually renaming them after the
compilation. This also enables running 'make install' with curl's own
Makefiles in order to install curl-impersonate.
2022-04-11 17:59:51 +03:00
lwthiker
584ff54653 Add signature for Chrome 99 on Android phone
Add support for impersonating Chrome 99 on Android 12 (Pixel 6 was
chosen as an arbitrary Android phone to impersonate). The TLS signature
for Chrome on Android is identical to Chrome on Windows. The difference
is in a few HTTP headers ('sec-ch-ua-mobile', 'sec-ch-ua-platform' and
'user-agent').
2022-03-24 21:01:47 +02:00
lwthiker
7df69b5107 Compile libbrotli statically into curl-impersonate
Compile libbrotli statically into curl-impersonate/libcurl-impersonate
for convenience of usage outside the container.
2022-03-08 15:45:30 +02:00
lwthiker
e554958c75 Impersonate Chrome 99 and Edge 99
Add impersonation support for Chrome 99 and Edge 99 which were just released.
Their TLS signature is identical to the previous versions (98).
The only difference is in the user agents.

curl patch from
ca13947f00
2022-03-05 13:03:27 +02:00
lwthiker
6e0e9b90da Fix Edge and Firefox HTTP headers
The HTTP headers for Edge and Firefox were slightly incorrect.

curl patches from
ee0a67058f
and
351dba44d0
2022-03-04 17:27:08 +02:00
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
0340cd8b3e
2022-03-03 16:57:26 +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
dd4b76241e
2022-03-03 15:25:23 +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
4e2e782e5f Add Edge 98 signature to libcurl-impersonate 2022-02-27 23:48:17 +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
48415a4b00 Add impersonation support to libcurl
Patch generated from e8cd43c8eb

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
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
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