Commit Graph

245 Commits

Author SHA1 Message Date
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
lwthiker
48d18cd8cd Add GitHub Action to test native builds
Add a GitHub action to compile and test native builds using the new
Makefile-based build system. Currently runs on Ubuntu and in the future
will run similarly on MacOS.
2022-04-12 16:53:22 +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
79f8601a30 Fix typo in Makefile.in 2022-04-12 12:43:02 +03:00
lwthiker
493576a15e Add INSTALL.md
Add INSTALL.md with explanation about using the new Makefile-based build
system and the Docker-based build system, and remove the same section
from README.md.
2022-04-12 12:29:47 +03:00
lwthiker
4e102d1fbf Add Makefile uninstall targets
Add two targets for uninstalling curl-impersonate to the Makefile.
2022-04-12 12:29:47 +03:00
lwthiker
7e19dd7221 Only install binaries in 'make install'
When doing 'make firefox-install' or 'make chrome-install' in our own
Makefile, only install curl's binaries (curl & libcurl) and do not
install the man pages and headers. This will prevent collision of these
files with any installed curl man pages or headers. In the future it
might be possible to rename the man pages or headers as well to allow
them live side-by-side with the vanilla curl.
2022-04-12 12:29:41 +03:00
lwthiker
b484701491 Use autoconf's srcdir variable in Makefile.in
Use autoconf's automatic variable 'abs_srcdir' to find the path to the
patch files and wrapper scripts, instead of relying on the Makefile's
directory. This allows doing out-of-tree builds, i.e. 'mkdir build && cd
build && ../configure && make'.
2022-04-12 11:32:50 +03:00
lwthiker
35623ee453 Use autoconf to configure the Makefile
Use a 'configure' script generated by autoconf to configure whether a
static build is desired, and where to install the final curl-impersonate
binaries. Add installation targets to the Makefile.
2022-04-12 10:58:53 +03:00
lwthiker
15fd7186ac Add Makefile to orchestrate native builds
Add a Makefile to orchestrate native builds of curl-impersonate without
Docker. The Makefile does not compile any program by itself but is just
used to build all the dependencies and then build curl itself with the
needed patches. It has a very similar flow to the Dockerfile.
2022-04-12 10:58:53 +03:00
lwthiker
319139e045 Merge pull request #43 from lwthiker/binary_name_change
Use different binary names for Firefox and Chrome
2022-04-12 10:57:19 +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
22508c6863 Use different binary names for Firefox and Chrome
Rename the binary files of curl-impersonate so that the Firefox and
Chrome versions can co-exist on the same system. The Firefox version is
now named 'curl-impersonate-ff' and 'libcurl-impersonate-ff' and the
Chrome version is named 'curl-impersonate-chrome' and
'libcurl-impersonate-chrome'. The wrapper scripts look for these names
as well. Symbolic names with the old names are still created inside the
Docker images to keep compatibility as much as possible.
2022-04-08 19:10:35 +03:00
lwthiker
af38d2b626 Merge pull request #35 from lwthiker/chrome_android
Add signature for Chrome 99 on Android
v0.3.2
2022-03-24 21:23:22 +02: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
a3054994aa Merge pull request #29 from lwthiker/ff98
Impersonate Firefox 98
2022-03-12 10:57:37 +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
0952bca3de Merge pull request #28 from lwthiker/alpine
Add Alpine Linux images and push automatically to DockerHub
v0.3.1
2022-03-10 14:44:33 +02:00
lwthiker
aba67a4cbe Fix typo and link in README.md v0.3.1-alpha.3 2022-03-10 13:38:37 +02:00