### Install macOS Build Dependencies Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Installs required build tools and Go for macOS using Homebrew. Ensure Homebrew is installed before running these commands. ```bash brew install pkg-config make cmake ninja autoconf automake libtool brew install go ``` -------------------------------- ### Install CA certificates on Ubuntu Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Install the CA certificates package on Ubuntu systems. ```bash apt install ca-certificates ``` -------------------------------- ### Run curl-impersonate Wrapper Scripts Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Examples of using the installed wrapper scripts to make requests with specific browser profiles. You can also run the main binary directly. ```bash curl_chrome119 https://www.example.com # Or run the binary directly with your own flags: curl-impersonate https://www.example.com ``` -------------------------------- ### Install Artifacts with Stripped Binaries Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Installs the built artifacts. Use `install-strip` to optionally strip binaries, reducing their size. ```makefile make install-strip ``` -------------------------------- ### Install Libcurl Libraries (Windows) Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Installs libcurl runtime libraries on Windows. It specifically looks for .lib, .a, and .dll files matching the pattern. ```cmake if(WIN32) install( DIRECTORY "${DEPS_BUILD_DIR}/curl/lib/" DESTINATION ${CMAKE_INSTALL_LIBDIR} FILES_MATCHING PATTERN "libcurl-impersonate*.lib" PATTERN "libcurl-impersonate*.a" PATTERN "libcurl-impersonate*.dll" ) else() install( DIRECTORY "${DEPS_BUILD_DIR}/curl/lib/" DESTINATION ${CMAKE_INSTALL_LIBDIR} FILES_MATCHING PATTERN "libcurl-impersonate*.a" PATTERN "libcurl-impersonate*.so*" PATTERN "libcurl-impersonate*.dylib*" ) endif() ``` -------------------------------- ### Install Wrapper Scripts (Windows) Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Installs curl wrapper batch scripts on Windows. It uses file globbing to find scripts starting with 'curl_' in the win/bin directory. ```cmake if(WIN32) file(GLOB _curl_wrapper_scripts CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/win/bin/curl_*.bat") else() file(GLOB _curl_wrapper_scripts CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/bin/curl_*") endif() if(_curl_wrapper_scripts) install(PROGRAMS ${_curl_wrapper_scripts} DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() ``` -------------------------------- ### Define All Install Custom Target Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Defines a custom CMake target named 'install-all' that orchestrates the installation process. It first builds the 'curl-install' target and then performs the main installation. ```cmake add_custom_target(install-all COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target curl-install COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Install Curl Header Files Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Installs the curl header files from the source directory to the installation's include directory. It specifically matches files ending with .h. ```cmake install( DIRECTORY "${DEPS_SRC_DIR}/curl/include/curl" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" ) ``` -------------------------------- ### Build and Install curl-impersonate from Source Source: https://github.com/lexiforest/curl-impersonate/blob/main/curl_impersonate_playground.ipynb Compiles the curl-impersonate project from the cloned source code and installs it system-wide. This process may take a significant amount of time. ```shell #@title ๐Ÿ—๏ธ Start Build print("โณ Starting build process... (This may take some time)") !cd /app && mkdir -p build && cd build && ../configure && make build !cd /app/build && sudo make install !sudo ldconfig print("\nโœ… Build and installation successfully completed.") ``` -------------------------------- ### Install CA certificates on Arch Linux Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Install the CA certificates package on Arch Linux systems. ```bash pacman -S ca-certificates ``` -------------------------------- ### Install Dependencies for Build Source: https://github.com/lexiforest/curl-impersonate/blob/main/curl_impersonate_playground.ipynb Installs essential system packages required for compiling curl-impersonate. This includes build tools like git, cmake, and golang. ```shell #@title ๐Ÿ“ฆ Install Dependencies print("โณ Updating system packages and installing dependencies...") !sudo apt-get update !sudo apt-get install -y \ git ninja-build cmake autoconf automake pkg-config libtool \ ca-certificates curl \ golang-go bzip2 xz-utils unzip print("\nโœ… Dependencies successfully installed.") ``` -------------------------------- ### Download and Install Pre-built Binary Source: https://github.com/lexiforest/curl-impersonate/blob/main/curl_impersonate_playground.ipynb Downloads a pre-compiled binary version of curl-impersonate from a specified URL and installs it into the system's executable path. This is an alternative to building from source. ```python #@title โฌ‡๏ธ Binary Installation BINARY_URL = "https://github.com/lexiforest/curl-impersonate/releases/download/v1.5.6/curl-impersonate-v1.5.6.x86_64-linux-gnu.tar.gz" #@param {type:"string"} INSTALL_DIR = "/usr/local/bin" import os print(f"โณ Downloading: {BINARY_URL}") !wget -qO /tmp/curl-impersonate.tar.gz {BINARY_URL} if os.path.exists("/tmp/curl-impersonate.tar.gz"): print("๐Ÿ“ฆ Extracting archive...") !sudo tar -xzf /tmp/curl-impersonate.tar.gz -C {INSTALL_DIR} print(f"โœ… Installation completed: {INSTALL_DIR}") print("๐ŸŒ Made available system-wide.") else: print("โŒ Download failed!") ``` -------------------------------- ### Install Ubuntu Build Dependencies Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Installs essential packages for building curl-impersonate on Ubuntu systems. Ensure you have git, ninja-build, cmake, and development tools. ```bash sudo apt-get install -y \ git ninja-build cmake autoconf automake pkg-config libtool \ ca-certificates curl \ curl \ golang-go bzip2 xz-utils unzip ``` -------------------------------- ### Install Curl Binary (Windows) Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Installs the curl-impersonate executable on Windows systems. This targets the specific executable built for Windows. ```cmake if(WIN32) install(PROGRAMS "${DEPS_BUILD_DIR}/curl/src/curl-impersonate.exe" DESTINATION ${CMAKE_INSTALL_BINDIR}) elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") install(PROGRAMS "${DEPS_BUILD_DIR}/curl/src/curl-impersonate.app/curl-impersonate" DESTINATION ${CMAKE_INSTALL_BINDIR}) else() install(PROGRAMS "${DEPS_BUILD_DIR}/curl/src/curl-impersonate" DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() ``` -------------------------------- ### Clone and Build curl-impersonate (Ubuntu) Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Clones the repository, configures the build, and compiles curl-impersonate. Use 'make build' to compile and 'make install' to install. ```bash git clone https://github.com/lexiforest/curl-impersonate.git cd curl-impersonate mkdir build && cd build # Optionally, use --enable-static for static binaries ../configure # Build and install make build sudo make install # You may need to update the linker's cache to find libcurl-impersonate sudo ldconfig # Optionally remove all the build files cd ../ && rm -Rf build ``` -------------------------------- ### FreeBSD VM Build Helper Script (macOS) Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Scripts to set up, start, build, and manage artifacts from a FreeBSD VM on macOS for testing. Useful for local development and testing FreeBSD builds. ```bash scripts/freebsd-vm-macos.sh setup scripts/freebsd-vm-macos.sh start scripts/freebsd-vm-macos.sh build scripts/freebsd-vm-macos.sh fetch-artifacts scripts/freebsd-vm-macos.sh stop ``` -------------------------------- ### Conditional libidn2 Check Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Checks if libidn2 is required and if a prebuilt version exists in the installation directory. If not found, it throws a fatal error, guiding the user on how to prepare it. ```cmake if(USE_LIBIDN2) set(_libidn2_archive "${DEPS_INSTALL_DIR}/lib/libidn2.a") if(NOT EXISTS "${_libidn2_archive}") message(FATAL_ERROR "USE_LIBIDN2 requires prebuilt libidn2 in ${DEPS_INSTALL_DIR}. " "Run `make prepare-libidn2` before configuring CMake, or use " "`make configure` so the Autotools IDN preparation runs first.") endif() add_custom_target(libidn2 COMMAND ${CMAKE_COMMAND} -E echo "Using prebuilt libidn2 from ${DEPS_INSTALL_DIR}" ) endif() ``` -------------------------------- ### Install CA certificates on macOS with Homebrew Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Install the CA certificates package on macOS using Homebrew. ```bash brew install ca-certificates ``` -------------------------------- ### Install CA certificates on Red Hat/Fedora/CentOS Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Install the CA certificates package on Red Hat, Fedora, or CentOS systems. ```bash yum install ca-certificates ``` -------------------------------- ### Install curl-impersonate on macOS with Homebrew Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Use this command to install curl-impersonate via Homebrew on macOS. ```bash brew install lexiforest/tap/curl-impersonate ``` -------------------------------- ### Install FreeBSD Build Dependencies Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Installs packages required for building curl-impersonate on FreeBSD. Note that libidn2 is disabled for BSD builds. ```bash pkg install -y \ pkgconf cmake ninja curl autoconf automake libtool \ gmake gperf go ``` -------------------------------- ### Repository Settings and Cloning Source: https://github.com/lexiforest/curl-impersonate/blob/main/curl_impersonate_playground.ipynb Configures repository URLs and branches for curl-impersonate and its dependencies (BoringSSL, Curl, nghttp3, ngtcp2). Downloads patches for specified commits. This is the initial setup step before building. ```python #@title ๐Ÿ“ฅ Repository Settings CURL_IMPERSONATE_GIT = "https://github.com/lexiforest/curl-impersonate" #@param {type:"string"} # @markdown --- # @markdown **BoringSSL Settings** # @markdown (Default: https://github.com/lexiforest/boringssl) BORINGSSL_GIT = "" #@param {type:"string"} BORINGSSL_BRANCH = "impersonate" #@param {type:"string"} BORINGSSL_COMMIT = "673e61fc215b178a90c0e67858bbf162c8158993" # @markdown --- # @markdown **Curl Settings** # @markdown (Default: https://github.com/lexiforest/curl-chrome) CURL_GIT = "" #@param {type:"string"} CURL_BRANCH = "impersonate-chrome" #@param {type:"string"} CURL_COMMIT = "cfbfb65047e85e6b08af65fe9cdbcf68e9ad496a" # @markdown --- # @markdown **nghttp3 Settings** # @markdown (Default: https://github.com/riverside-ai/nghttp3) NGHTTP3_GIT = "" #@param {type:"string"} NGHTTP3_BRANCH = "impersonate" #@param {type:"string"} NGHTTP3_COMMIT = "d326f4c1eb3f6a780d77793b30e16756c498f913" # @markdown --- # @markdown **ngtcp2 Settings** # @markdown (Default: https://github.com/riverside-ai/ngtcp2) NGTCP2_GIT = "" #@param {type:"string"} NGTCP2_BRANCH = "impersonate" #@param {type:"string"} NGTCP2_COMMIT = "ca898d32348c93af9fbbc81538505a1c1c062685" import os import requests def download_patch(git_url, commit_id, branch, patch_path): if not git_url: return # GitHub compare URL format (.diff) patch_url = f"{git_url.rstrip('/')}/compare/{commit_id}...{branch}.diff" print(f"๐Ÿ” Downloading patch: {patch_url}") try: response = requests.get(patch_url) if response.status_code == 200: if os.path.exists(patch_path): os.remove(patch_path) os.makedirs(os.path.dirname(patch_path), exist_ok=True) with open(patch_path, "wb") as f: f.write(response.content) print(f"โœ… Patch updated: {patch_path}") else: print(f"โš ๏ธ Failed to download patch (HTTP {response.status_code})") except Exception as e: print(f"โŒ Error: {e}") print("๐Ÿš€ Cloning main repository...") !rm -rf /app !git clone --depth 1 --shallow-submodules --recurse-submodules {CURL_IMPERSONATE_GIT} -b main /app print("\n๐Ÿ› ๏ธ Updating patches...") download_patch(BORINGSSL_GIT, BORINGSSL_COMMIT, BORINGSSL_BRANCH, "/app/patches/boringssl.patch") download_patch(CURL_GIT, CURL_COMMIT, CURL_BRANCH, "/app/patches/curl.patch") download_patch(NGHTTP3_GIT, NGHTTP3_COMMIT, NGHTTP3_BRANCH, "/app/patches/nghttp3.patch") download_patch(NGTCP2_GIT, NGTCP2_COMMIT, NGTCP2_BRANCH, "/app/patches/ngtcp2.patch") print("\nโœ… Cloning and preparation completed.") ``` -------------------------------- ### Install curl-impersonate on Arch Linux with Pacman Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Use this command to install curl-impersonate via Pacman on Arch Linux. ```bash sudo pacman -S curl-impersonate ``` -------------------------------- ### Install Red Hat Build Dependencies Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Installs necessary development tools and libraries for building on Red Hat-based systems like CentOS and Fedora. Includes CMake, Python, and Ninja. ```bash yum groupinstall "Development Tools" yum groupinstall "C Development Tools and Libraries" # Fedora only yum install cmake3 python3 python3-pip # Install Ninja. This may depend on your system. yum install ninja-build # OR pip3 install ninja yum install golang ``` -------------------------------- ### Configure and Build curl-impersonate (FreeBSD) Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Configures and builds curl-impersonate on FreeBSD using CMake and Ninja. Specifies installation path and disables libidn2. ```bash cmake_args="-G Ninja -DCMAKE_INSTALL_PREFIX=$PWD/freebsd-install" cmake_args="$cmake_args -DUSE_LIBIDN2=OFF" gmake configure BUILD_DIR=build-freebsd CMAKE_CONFIGURE_ARGS="$cmake_args" gmake build BUILD_DIR=build-freebsd CMAKE_CONFIGURE_ARGS="$cmake_args" gmake install-strip BUILD_DIR=build-freebsd CMAKE_CONFIGURE_ARGS="$cmake_args" ``` -------------------------------- ### Local CI-like Test Execution Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Runs integration tests locally, mimicking a CI environment. Requires specifying the installation directory and network interface. ```bash cd tests && pytest . --install-dir --capture-interface ``` -------------------------------- ### Clone and Build curl-impersonate (macOS) Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Clones the repository and builds curl-impersonate on macOS. Uses 'gmake' for build and install commands. ```bash git clone https://github.com/lexiforest/curl-impersonate.git cd curl-impersonate mkdir build && cd build ../configure # Build and install gmake build sudo gmake install # Optionally remove all the build files cd ../ && rm -Rf build ``` -------------------------------- ### Cross-compilation with Zig Toolchain Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Utilizes the zig toolchain for cross-compilation targets. Refer to the GitHub workflow for detailed examples and configurations. ```bash # Example command structure (refer to workflow for specifics) zig build --target ``` -------------------------------- ### Configure Uninstall Target Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Configures an Uninstall.cmake file based on a template. This file is used to record installed files for later uninstallation. ```cmake configure_file( "${CMAKE_SOURCE_DIR}/cmake/Uninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" @ONLY ) ``` -------------------------------- ### Define Curl Install Custom Target Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Defines a custom CMake target named 'curl-install' that depends on the 'curl' target. This target is used to manage the installation of curl. ```cmake add_custom_target(curl-install DEPENDS curl ) ``` -------------------------------- ### Specify CA certificates for curl-impersonate on Linux Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Example of how to specify the CA certificate bundle path when using curl-impersonate on Linux distributions other than Ubuntu. ```bash curl_chrome123 https://www.example.com --cacert /etc/ssl/certs/ca-bundle.crt ``` -------------------------------- ### Add Custom Uninstall Target Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Adds a custom CMake target named 'uninstall'. When invoked, it executes the generated cmake_uninstall.cmake script to remove installed files. ```cmake add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" COMMENT "Uninstall files recorded in install manifests" ) ``` -------------------------------- ### Add nghttp3 External Project Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Configures the nghttp3 library as an external project in CMake. It specifies the URL, source and build directories, installation path, and applies a patch. Build arguments are set to enable static libraries only and disable testing. ```cmake ExternalProject_Add(nghttp3 URL "${NGHTTP3_URL}" SOURCE_DIR "${DEPS_SRC_DIR}/nghttp3" BINARY_DIR "${DEPS_BUILD_DIR}/nghttp3" INSTALL_DIR "${DEPS_INSTALL_DIR}" PATCH_COMMAND ${PATCH_EXE} -p1 -i "${CMAKE_SOURCE_DIR}/patches/nghttp3.patch" CMAKE_ARGS ${_common_cmake_args} ${_shadow_avoid_cmake_args} -DCMAKE_INSTALL_PREFIX= -DENABLE_LIB_ONLY=ON -DENABLE_SHARED_LIB=OFF -DENABLE_STATIC_LIB=ON -DBUILD_TESTING=OFF BUILD_COMMAND ${CMAKE_COMMAND} --build --config Release --parallel ${SUBJOBS} INSTALL_COMMAND ${CMAKE_COMMAND} --build --config Release --target install --parallel ${SUBJOBS} COMMAND ${CMAKE_COMMAND} -E copy_if_different /lib/includes/nghttp3/nghttp3.h /include/nghttp3/nghttp3.h COMMAND ${CMAKE_COMMAND} -DHEADER=/include/nghttp3/nghttp3.h -DNEEDLE=nghttp3_settings_entry -P "${CMAKE_SOURCE_DIR}/cmake/CheckFileContains.cmake" ) ``` -------------------------------- ### Build All Dependencies and curl-impersonate Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Use this command to build all external dependencies and the main curl-impersonate project. Ensure CMake build files are generated first. ```makefile make build ``` -------------------------------- ### Load libcurl-impersonate at Runtime on macOS Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/bindings.md On macOS, rename the dylib to match the expected libcurl version and place it in a system library path. Then, use DYLD_LIBRARY_PATH to point PHP to this directory for runtime loading. ```bash DYLD_LIBRARY_PATH=/usr/local/lib php -r 'print_r(curl_version());' ``` -------------------------------- ### Build Docker Image for Tests Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Builds the Docker image used for running integration tests. This command should be executed from the root of the repository. ```docker docker build -t curl-impersonate-tests tests/ ``` -------------------------------- ### Using Wrapper Script for Chrome 104 Signature Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/quick_start.md Utilize a wrapper script to generate a TLS and HTTP/2 signature identical to Chrome 104. ```bash curl_chrome104 -v -L https://example.com ``` -------------------------------- ### HTTP/2 Initial Streams Settings Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets the initial streams settings for HTTP/2. ```APIDOC ## CURLOPT_HTTP2_STREAMS ### Description Sets the initial streams settings for HTTP/2. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **value** (string) - Required - The initial streams settings for HTTP/2. ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http2-streams ` ``` -------------------------------- ### Load libcurl-impersonate at Runtime on Linux Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/bindings.md Load the patched libcurl-impersonate using LD_PRELOAD and specify the desired impersonation profile (e.g., chrome101) when running PHP scripts. This allows PHP to use the impersonated libcurl. ```bash LD_PRELOAD=/path/to/libcurl-impersonate.so CURL_IMPERSONATE=chrome101 php -r 'print_r(curl_version());' ``` -------------------------------- ### Verify libcurl-impersonate SSL Version on Linux Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/bindings.md After setting up and loading libcurl-impersonate on Linux, this command verifies that the SSL version is reported as BoringSSL, indicating successful integration. ```bash [ssl_version] => BoringSSL ``` -------------------------------- ### Enable Static Compilation Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Compiles curl-impersonate statically by passing the '--enable-static' flag to the configure script. This creates self-contained binaries. ```bash # Optionally, use --enable-static for static binaries ../configure --enable-static ``` -------------------------------- ### Configure Curl Build Options Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Configures the build options for libcurl, enabling SSL, Brotli, Zstd, and other features. Use this to customize the curl build for specific requirements. ```cmake cmake \ -DCURL_USE_OPENSSL=ON \ -DCURL_ENABLE_SSL=ON \ ${_curl_openssl_flags} \ # Bypass BoringSSL check -DHAVE_SSL_SET0_WBIO=1 \ -DHAVE_SSL_SET1_ECH_CONFIG_LIST=1 \ -DHAVE_SSL_SET_QUIC_USE_LEGACY_CODEPOINT=1 \ -DHAVE_OPENSSL_SRP=0 \ -DCURL_BROTLI=ON \ -DCURL_ZSTD=ON \ # Make sure curl doesn't link against an unversioned .so (Linux only). -DZLIB_INCLUDE_DIR=${DEPS_INSTALL_DIR}/include \ -DZLIB_LIBRARY=${_curl_zlib_library} \ -DZLIB_LIBRARY_RELEASE=${_curl_zlib_library} \ -DZSTD_INCLUDE_DIR=${DEPS_INSTALL_DIR}/include \ -DZSTD_LIBRARY=${_curl_zstd_library} \ -DUSE_NGHTTP2=ON \ -DUSE_NGTCP2=ON \ -DCURL_DISABLE_LDAP=ON \ -DCURL_DISABLE_LDAPS=ON \ # XXX: psl should be enabled in the future: # https://daniel.haxx.se/blog/2024/01/10/psl-in-curl/ -DCURL_USE_LIBPSL=OFF \ -DUSE_LIBRTMP=OFF \ -DCURL_DISABLE_WEBSOCKETS=OFF \ -DUSE_ECH=ON \ -DUSE_SSLS_EXPORT=ON \ -DENABLE_IPV6=ON \ -DCURL_USE_LIBSSH2=OFF \ -DBUILD_MISC_DOCS=OFF \ -DENABLE_CURL_MANUAL=OFF \ ${_curl_ca_flags} \ ${_curl_idn_flags} \ ${_curl_build_flags} \ ${_curl_platform_flags} \ -GNinja \ -S -B ``` -------------------------------- ### Basic curl-impersonate Command Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/quick_start.md Run curl-impersonate from the command line with standard curl flags. ```bash curl-impersonate -v -L https://example.com ``` -------------------------------- ### Runtime Library Replacement with LD_PRELOAD Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/quick_start.md Use LD_PRELOAD to replace the libcurl library at runtime and set the CURL_IMPERSONATE environment variable to impersonate a specific browser. This is useful for applications already using libcurl. ```bash LD_PRELOAD=/path/to/libcurl-impersonate.so CURL_IMPERSONATE=chrome116 my_app ``` -------------------------------- ### Build Curl-Impersonate Docker Image Source: https://github.com/lexiforest/curl-impersonate/blob/main/tests/README.md Build the Docker image for curl-impersonate tests. Ensure you have built the curl-impersonate Docker image beforehand. ```bash docker build -t curl-impersonate-tests tests/ ``` -------------------------------- ### Curl Configuration Flags Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Sets up configuration flags for curl based on the operating system and whether libidn2 is used. This ensures correct IDN handling for different platforms. ```cmake set(_curl_use_pkgconfig_flag -DCURL_USE_PKGCONFIG=OFF) set(_curl_clean_env) if(NOT WIN32) list(APPEND _curl_clean_env "CPATH=" "C_INCLUDE_PATH=" "CPLUS_INCLUDE_PATH=" "LIBRARY_PATH=" "PKG_CONFIG_PATH=" ) endif() if(WIN32) set(_curl_idn_flags -DUSE_WIN32_IDN=ON -DUSE_LIBIDN2=OFF) elseif(APPLE) if(USE_LIBIDN2) set(_curl_idn_flags -DUSE_APPLE_IDN=OFF -DUSE_LIBIDN2=ON) else() set(_curl_idn_flags -DUSE_APPLE_IDN=ON -DUSE_LIBIDN2=OFF) endif() elseif(ANDROID) set(_curl_idn_flags -DUSE_LIBIDN2=OFF) elseif(USE_LIBIDN2) set(_curl_idn_flags -DUSE_LIBIDN2=ON) else() set(_curl_idn_flags -DUSE_LIBIDN2=OFF) endif() ``` -------------------------------- ### HTTP/2 Initial Window Update Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets the initial HTTP/2 window update value. ```APIDOC ## CURLOPT_HTTP2_WINDOW_UPDATE ### Description Sets the initial HTTP/2 window update value. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **value** (long) - Required - The initial window update value (e.g., `15663105`). ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http2-window-update ` ``` -------------------------------- ### Build Debian-based Docker Image Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/building.md Use this command to build the Debian-based Docker image for curl-impersonate. This image is suitable for reproducible builds. ```bash docker build -t curl-impersonate . ``` -------------------------------- ### Build Curl-Impersonate Source: https://github.com/lexiforest/curl-impersonate/blob/main/CMakeLists.txt Builds the curl-impersonate project using the configured CMake options. This command executes the build process for the Release configuration. ```bash BUILD_COMMAND ${CMAKE_COMMAND} -E env ${_curl_clean_env} ${CMAKE_COMMAND} --build --config Release --parallel ${SUBJOBS} ``` -------------------------------- ### Impersonation and Headers Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Options for controlling impersonation targets, custom headers, header order, and multipart form boundaries. ```APIDOC ## `CURLOPT_IMPERSONATE` (string) ### Description The master option for setting an impersonation target. The format is `name[:yes|no]`. ### Method N/A (CURL option) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ## `CURLOPT_HTTPBASEHEADER` (slist) ### Description A list of headers used by the impersonated browser. If given, it is merged with `CURLOPT_HTTPHEADER`. ### Method N/A (CURL option) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ## `CURLOPT_HTTPHEADER_ORDER` (string) ### Description Comma-separated order for normal HTTP headers. e.g. `Host,User-Agent,Cookie`. This is particularly useful for impersonating the http/1.1 behavior. ### Method N/A (CURL option) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ## `CURLOPT_FORM_BOUNDARY` (string) ### Description Sets the multipart `form-data` boundary style. Possible values: `webkit`, for webkit and blink based browsers, e.g. Safari and Chrome. `firefox`, for Gecko based browsers, e.g. Firefox. ### Method N/A (CURL option) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### Run Tests Using Docker Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Executes the integration tests within a Docker container. This ensures a consistent and reproducible testing environment. ```docker docker run --rm curl-impersonate-tests ``` -------------------------------- ### Patch libcurl-impersonate SONAME on Linux Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/bindings.md Use patchelf to set the SONAME of the libcurl-impersonate shared object on Linux systems. This is a prerequisite for runtime loading. ```bash patchelf --set-soname libcurl.so.4 /path/to/libcurl-impersonate.so ``` -------------------------------- ### HTTP/3 Settings Frame Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets HTTP/3 settings frame keys and values. ```APIDOC ## CURLOPT_HTTP3_SETTINGS ### Description Sets HTTP/3 settings frame keys and values, in the format `1:v;6:v;7:v`. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **settings** (string) - Required - The HTTP/3 settings in the format `1:v;6:v;7:v`. ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http3-settings ` ``` -------------------------------- ### Test Center - Curl-Impersonate Playground Source: https://github.com/lexiforest/curl-impersonate/blob/main/curl_impersonate_playground.ipynb Run tests with different curl variants, target URLs, and HTTP/3 settings. This snippet configures and executes a command using subprocess. ```python #@title ๐Ÿงช Test Center TARGET_URL = "https://cloudflare-quic.com/" #@param {type:"string"} CURL_VARIANT = "curl_chrome146" #@param ['curl_chrome146', 'curl_chrome100', 'curl_chrome101', 'curl_chrome104', 'curl_chrome107', 'curl_chrome110', 'curl_chrome116', 'curl_chrome119', 'curl_chrome120', 'curl_chrome123', 'curl_chrome124', 'curl_chrome131', 'curl_chrome131_android', 'curl_chrome133a', 'curl_chrome136', 'curl_chrome142', 'curl_chrome145', 'curl_chrome99', 'curl_chrome99_android', 'curl_edge101', 'curl_edge99', 'curl_firefox133', 'curl_firefox135', 'curl_firefox144', 'curl_firefox147', 'curl_safari153', 'curl_safari155', 'curl_safari170', 'curl_safari172_ios', 'curl_safari180', 'curl_safari180_ios', 'curl_safari184', 'curl_safari184_ios', 'curl_safari260', 'curl_safari2601', 'curl_safari260_ios', 'curl_tor145'] USE_HTTP3 = False #@param {type:"boolean"} ARGS = "" #@param {type:"string"} import subprocess def run_test(cmd): print(f"Executing: {cmd}") try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True) print("---" + " STDOUT ---") print(result.stdout) if result.stderr: print("---" + " STDERR ---") print(result.stderr) except Exception as e: print(f"Error: {e}") cmd = [CURL_VARIANT] if USE_HTTP3: cmd.append("--http3") if ARGS: cmd.append(ARGS) cmd.append("-I") cmd.append(TARGET_URL) final_cmd = " ".join(cmd) print(f"๐Ÿ” Version Check ({CURL_VARIANT}):") run_test(f"{CURL_VARIANT} --version") print(f"\n๐Ÿ“ก Request Test ({TARGET_URL}):") run_test(final_cmd) ``` -------------------------------- ### libcurl-impersonate API Function Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/quick_start.md Use the `curl_easy_impersonate` function to set browser-like TLS and HTTP/2 fingerprints programmatically. Set `default_headers` to 0 to provide headers manually. ```c CURLcode curl_easy_impersonate(struct Curl_easy *data, const char *target, int default_headers); ``` -------------------------------- ### HTTP/3 Pseudo-Headers Order Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets the order of HTTP/3 pseudo-headers, analogous to the HTTP/2 option. ```APIDOC ## CURLOPT_HTTP3_PSEUDO_HEADERS_ORDER ### Description Sets the order of the HTTP/3 pseudo-headers. The value must contain the letters `m`, `a`, `s`, and `p`, representing `:method`, `:authority`, `:scheme`, and `:path` in the desired order of appearance in the HTTP/3 HEADERS frame. This is the HTTP/3 analogue of `CURLOPT_HTTP2_PSEUDO_HEADERS_ORDER`. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **order** (string) - Required - The desired order of pseudo-headers (e.g., `masp`). ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http3-pseudo-headers-order ` ``` -------------------------------- ### HTTP/2 Settings Frame Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets HTTP/2 settings frame keys and values. ```APIDOC ## CURLOPT_HTTP2_SETTINGS ### Description Sets HTTP/2 settings frame keys and values, in the format `1:v;2:v;3:v`. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **settings** (string) - Required - The HTTP/2 settings in the format `1:v;2:v;3:v` (e.g., `1:65536;3:1000;4:6291456;6:262144`). ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http2-settings ` ``` -------------------------------- ### Basic Usage with Chrome Wrapper Source: https://github.com/lexiforest/curl-impersonate/blob/main/README.md Launches curl-impersonate using the curl_chrome123 wrapper script to access a URL. This script preconfigures necessary headers and flags for Chrome impersonation. ```bash curl_chrome123 https://www.example.com ``` -------------------------------- ### Detailed curl_chrome104 Wrapper Script Configuration Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/quick_start.md Examine the configuration of the curl_chrome104 wrapper script, including ciphers, HTTP headers, and TLS/HTTP2 options. ```bash "$dir/curl-impersonate" \ --ciphers TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,ECDHE-RSA-AES128-SHA,ECDHE-RSA-AES256-SHA,AES128-GCM-SHA256,AES256-GCM-SHA384,AES128-SHA,AES256-SHA \ -H 'sec-ch-ua: "Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Windows"' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \ -H 'Sec-Fetch-Site: none' \ -H 'Sec-Fetch-Mode: navigate' \ -H 'Sec-Fetch-User: ?1' \ -H 'Sec-Fetch-Dest: document' \ -H 'Accept-Encoding: gzip, deflate, br' \ -H 'Accept-Language: en-US,en;q=0.9' \ --http2 --compressed \ --tlsv1.2 --no-npn --alps \ --cert-compression brotli \ "$@" ``` -------------------------------- ### Build a Single Target Source: https://github.com/lexiforest/curl-impersonate/blob/main/AGENTS.md Builds a specific target dependency, such as `libidn2`. Replace `` with the desired target. ```makefile make target TARGET= ``` -------------------------------- ### HTTP/3 TLS Extension Order Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets TLS extension order for HTTP/3 QUIC TLS. ```APIDOC ## CURLOPT_HTTP3_TLS_EXTENSION_ORDER ### Description Sets TLS extension order for HTTP/3 QUIC TLS. If set, this is used instead of `CURLOPT_TLS_EXTENSION_ORDER` for QUIC connections. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **order** (string) - Required - The TLS extension order. ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http3-tls-extension-order ` ``` -------------------------------- ### HTTP/2 Pseudo-Headers Order Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets the order of HTTP/2 pseudo-headers. The value must contain 'm', 'a', 's', and 'p' in the desired order. ```APIDOC ## CURLOPT_HTTP2_PSEUDO_HEADERS_ORDER ### Description Sets the order of the HTTP/2 pseudo-headers. The value must contain the letters `m`, `a`, `s`, and `p`, representing `:method`, `:authority`, `:scheme`, and `:path` in the desired order of appearance in the HTTP/2 HEADERS frame. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **order** (string) - Required - The desired order of pseudo-headers (e.g., `masp`). ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http2-pseudo-headers-order ` ``` -------------------------------- ### QUIC Transport Parameters Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets QUIC transport parameters. ```APIDOC ## CURLOPT_QUIC_TRANSPORT_PARAMETERS ### Description Sets QUIC transport parameters, in the format `id:value;id:value`. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **params** (string) - Required - The QUIC transport parameters in the format `id:value;id:value`. ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--quic-transport-params ` ``` -------------------------------- ### HTTP/3 Signature Hash Algorithms Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/api.md Sets signature hash algorithms for HTTP/3 QUIC TLS. ```APIDOC ## CURLOPT_HTTP3_SIG_HASH_ALGS ### Description Sets signature hash algorithms for HTTP/3 QUIC TLS. If set, this is used instead of `CURLOPT_SSL_SIG_HASH_ALGS` for QUIC connections. ### Method Not Applicable (Option) ### Endpoint Not Applicable (Option) ### Parameters #### Option Parameters - **algorithm list** (string) - Required - A list of signature hash algorithms. ### Request Example Not Applicable (Option) ### Response Not Applicable (Option) ### Command Line Equivalent `--http3-sig-hash-algs ` ``` -------------------------------- ### Run curl-impersonate using Docker Source: https://github.com/lexiforest/curl-impersonate/blob/main/docs/install.md Execute the curl-impersonate command within a Docker container, using a specific version. ```bash docker run --rm lexiforest/curl-impersonate:1.1.0 curl_chrome110 https://www.example.com ```