Commit Graph

164 Commits

Author SHA1 Message Date
lwthiker
f51620327a Add compiler flags necessary to build on Fedora
* Add compiler flags to the boringssl build step to suppress gcc errors
raised when compiling with gcc 12+, which is present in Fedora. It is not
clear whether this is a compiler bug or a boringssl bug, however the
errors only appear when building in release mode and with gcc 12, so I
don't see any problem with manually supressing them.
* Add documentation for building on Fedora.
2022-05-20 17:46:56 +03:00
lwthiker
41986464c4 Fix build system to work on Red Hat-based systems
Tweak the curl-impersonate build system to make it work on Red Hat
based systems such as CentOS, Fedora and Amazon Linux.

* Change the Makefile to be more portable with different bash versions.
* Detect whether cmake is 'cmake' or 'cmake3', and whether ninja is
'ninja' or 'ninja-build'.
* Explicitly tell brotli to put its libraries in 'lib' dir, otherwise it
might put them in 'lib64' where curl doesn't find them.
* Add instructions for building curl-impersonate from source on Red Hat
based systems.
2022-05-20 15:52:30 +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
aa6e8a4700 Merge pull request #67 from lwthiker/chrome100_again
Add impersonation support for Chrome 100 and 101, drop support for Chrome 98
2022-05-17 21:11:49 +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
4642bd78d7 Merge pull request #62 from lwthiker/wrong_host_header
Fix bug causing a wrong 'Host' header
2022-05-16 21:00:01 +03:00
lwthiker
1b46a3fb88 Merge pull request #65 from lwthiker/firefox100
Add support for impersonating Firefox 100
2022-05-15 21:18:05 +03:00
lwthiker
2a03f51297 Fix incorrect link name in README.md 2022-05-15 20:54:03 +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
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
3263cd2c52 Merge pull request #61 from lwthiker/release_artifacts
Add compiled binaries to GitHub releases
v0.4.1
2022-05-14 19:12:16 +03:00
lwthiker
7167328e37 Publish stripped binaries to GitHub release assets
To reduce size of built binaries, strip the binaries before publishing
them.
v0.4.1-alpha.3
2022-05-14 18:50:18 +03:00
lwthiker
e042960659 Update README.md about pre-compiled binaries 2022-05-14 18:49:46 +03:00
lwthiker
201a5472ef Add option to strip binaries before installation
And use 'install' instead of 'cp' for installing the wrapper scripts.
2022-05-14 18:48:28 +03:00
lwthiker
b0e9d4c91e Use 'rm -f' in Makefile.in
Use 'rm -f' to ignore non-existant file errors.
v0.4.1-alpha.2
2022-05-14 17:58:22 +03:00
lwthiker
53a87e0d9d Add forgotten '.PHONY' declarations in Makefile.in v0.4.1-alpha.1 2022-05-14 10:10:34 +03:00
lwthiker
5b260dfa3c Add compiled binaries to GitHub releases 2022-05-14 10:09:03 +03:00
lwthiker
124f0740be Cache build files during GitHub action workflows (#60)
To speed up the automatic workflows, attempt to cache the slowest part
of the build, which is the compilation of the TLS libraries (NSS/BoringSSL).
2022-05-13 23:13:51 +03:00
lwthiker
f7cdf10b7f Merge pull request #57 from lwthiker/http2_settings
Improve HTTP/2 impersonation
2022-05-04 08:59:39 +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
0b45494394 Update README.md for version 0.4.0 2022-04-30 15:15:50 +03:00
lwthiker
95987a9bed Merge pull request #56 from lwthiker/macos_part2
Add support for linking NSS statically on macOS
v0.4.0
2022-04-30 14:37:02 +03:00
lwthiker
e3a552f90c Update README.md and INSTALL.md for macOS 2022-04-30 13:58:11 +03:00
lwthiker
31e61775a3 Search for libnssckbi in curl's configure script
libnssckbi is loaded at runtime by NSS. On some systems it is located in
a non-standard location that dlopen() can't find. For example, in Ubuntu
it may be in /usr/lib/x86_64-linux-gnu and on Mac M1 in
/opt/homebrew/nss. This becomes a problem when you static link NSS.

Search for libnssckbi in the configure script and add the relevant path
using '-rpath' linker flag. In addition, drop the previous hack for
Ubuntu that searched libnssckbi in a hardcoded location.
2022-04-30 13:58:11 +03:00
lwthiker
2b4b284cc8 Add 'apt-get update' in GitHub action workflow
And change 'apt' to 'apt-get' to prevent the warning message:
'WARNING: apt does not have a stable CLI interface. Use with caution in
scripts.'
2022-04-30 13:58:11 +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
90012e78de Fix various issues with automatic tests on macOS 2022-04-30 13:56:33 +03:00
lwthiker
ad77483b70 Don't install Go on macOS GitHub Action runner
Go is already installed and conflicts with 'brew install go'.
2022-04-30 13:56:33 +03:00
lwthiker
8019a00959 Run the automatic tests on a macOS runner as well 2022-04-30 13:56:33 +03:00
lwthiker
59209c19c7 Add support for linking NSS statically on macOS
This is an attmept to link with NSS statically on macOS (both Intel and
 Apple M1).

 Statically linking with NSS is a total mess and completely
undocumented. There are 20+ .a files to link with, and their linking
order matters. The main reference for this commit is a Mozilla Rust code
responsible for statically linking NSS:

    b2690fd2e4/components/support/rc_crypto/nss/nss_b    uild_common/src/lib.rs#L94

Unfortunately, even with that in hand, a lot of hacking is needed to
make it all work.
2022-04-30 13:56:16 +03:00
lwthiker
3f1c350132 Merge pull request #50 from lwthiker/macos_part1
macOS initial support attempt
2022-04-19 08:24:50 +03:00
lwthiker
4b41e5bd09 Add compilation instructions for macOS 2022-04-17 17:38:01 +03:00
lwthiker
7d86e2f285 Add make target to check that build is correct
Add a few checks as in f320cec to ensure that 'curl-impersonate' was
compiled with all the required features (compression, tls, http2).
2022-04-17 17:30:53 +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
f320cecdfd Ensure 'curl-impersonate' is compiled correctly
Add a few commands to the Dockerfile to check that 'curl-impersonate'
was compiled correctly: Check that it has brotli, http2 and tls support,
and check that the dependencies were compiled statically.

These are basic checks which are useful when modifying the Dockerfile:
Sometimes even small modifications cause curl to be compiled
incorrectly but without failing the build.
2022-04-17 17:23:20 +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
a6c4fa6ac1 Use $(MAKE) instead of 'make' in Makefile.in
To support platforms where 'make' is named differently (e.g. on MacOS we
use 'gmake' instead), replace it with '$(MAKE)' in Makefile.in
2022-04-17 14:50:53 +03:00
lwthiker
8afee95885 Merge pull request #49 from lwthiker/accept_encoding
Support encoded content in curl_easy_impersonate
2022-04-17 14:42:02 +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
22c6e96089 Update README.md
Try to fix GitHub Actions badges showing "no status"
2022-04-17 11:32:28 +03:00
lwthiker
a7127644af Merge pull request #47 from lwthiker/ldconfig_after_make_install
Update INSTALL.md
2022-04-17 10:51:14 +03:00
lwthiker
a79b14f5fc Update INSTALL.md
On some systems (Ubuntu), after doing 'make firefox-install' or 'make chrome-install', the linker can't find libcurl-impersonate.
Instruct users to run 'ldconfig' manually after installation to refresh the linker's cache, so it finds libcurl-impersonate in /usr/local/
2022-04-15 18:23:15 +03:00
lwthiker
4bd8671112 Update INSTALL.md 2022-04-15 17:52:37 +03:00
lwthiker
7717c220d1 Merge pull request #45 from lwthiker/makefile
Native build system using Makefile
2022-04-12 22:33:57 +03:00
lwthiker
842415f119 Add missing tests dependency in GitHub action 2022-04-12 22:21:13 +03:00
lwthiker
f1b31726dc Fix action failing on running pytest as sudo 2022-04-12 21:59:26 +03:00
lwthiker
e04e53b4d5 Use 'sudo' to launch pytest (because of tcpdump) 2022-04-12 17:32:29 +03:00
lwthiker
184fa640e8 Support Python 3.8 in the tests 2022-04-12 17:11:40 +03:00
lwthiker
f1324f7718 Add Badge for the native-build GitHub Action 2022-04-12 16:55:00 +03:00