Commit Graph

27 Commits

Author SHA1 Message Date
lwthiker
c2adb51d08 Remove archive.org from test urls
archive.org rejects connections which makes our test fail.
2022-07-05 08:49:32 +03:00
lwthiker
e5670826ba Add impersonation support for Safari 15.5 2022-07-05 08:22:07 +03:00
lwthiker
d417eb5c5c Rotate URLs in tests script and increase timeout
The tests fail sometimes with timeout for fetching the wikipedia URL.
Try to reduce the chance it happens by increasing the timeout and
rotating URLs.
2022-07-05 08:20:47 +03:00
lwthiker
440fdd2606 Add impersonation support for Firefox 102 2022-07-03 12:09:55 +03:00
lwthiker
0a007c624e Split signatures YAML database to multiple files
For easier maintenance, split the YAML files with the browser signatures
to multiple files, each per browser.
2022-07-03 10:40:18 +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
92a5b8c7ab Add support for impersonating Firefox 100
Add support for impersonating Firefox 100. The TLS signature is identical to
previous versions of Firefox.

In addition, upgrade NSS (Firefox's TLS library) to version 3.77 used by
Firefox 100. This is not strictly necessary as the previous version used
works just fine, but it's better keep up with the newest version.
2022-05-15 20:50:45 +03:00
lwthiker
ea63973256 tests: Use asyncio to wait for nghttpd to start
Seems like the tests may fail because we don't wait for nghttpd (the
HTTP2 server used for testing) to actually start listening.
This commit uses asyncio to launch nghttpd and read its stdout until it
starts listening.
2022-04-30 13:58:11 +03:00
lwthiker
d0c5777420 Run the LD_PRELOAD injection tests on Linux only
Injecting libcurl-impersonate with LD_PRELOAD is supported on
Linux only. On Mac there is DYLD_INSERT_LIBRARIES but it
reuqires more work to be fully functional.
2022-04-30 13:57:57 +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
184fa640e8 Support Python 3.8 in the tests 2022-04-12 17:11:40 +03:00
lwthiker
f5467cec11 Use configurable tcpdump interface in the tests
And add support for capturing the Client Hello message when sent over
IPv6.
2022-04-12 16:51:51 +03:00
lwthiker
facd6e5551 Use configurable binaries directory in the tests
Locate curl-impersonate and libcurl-impersonate in a directory which is
configurable from the command line instead of looking for them in the
current directory. '--install-dir' is passed to pytest, where a 'bin'
and 'lib' directories are expected with (lib)curl-impersonate.

Rename the Actions file for the Docker build to allow the creation of
addition Action for native builds.
2022-04-12 16:50:24 +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
768e37d194 Impersonate Firefox 98
Add support for impersonating Firefox 98 released a few days ago. It has
the same TLS signature as Firefox 95 so the adaptation includes changing
the user-agent only. Upgrade the NSS version used to 3.75, even though
it's not strictly necessary.
2022-03-12 10:44:24 +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
9bab04c170 Test curl-impersonate's HTTP headers
Add tests to verify that the HTTP headers and HTTP/2 pseudo-headers
generated by curl-impersonate match the expected ones from the browser.

The test uses a local nghttpd HTTP/2 server instance with a self-signed
certificate.
2022-03-04 17:31:32 +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
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
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
b30b245b72
2022-02-28 10:18:04 +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
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
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