lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.45k stars 229 forks source link

curl: /usr/local/lib/libcurl.so.4: no version information available (required by curl) #69

Open momala454 opened 2 years ago

momala454 commented 2 years ago

When using libcurl-impersonate.so (not sure which one to use, there is .so, .so.4, .so.4.7.0) compiled and replaced, curl will show an error with version not available. I'm not sure if I did something wrong ? I compiled it using the docker instructions.

curl --version
curl: /usr/local/lib/libcurl.so.4: no version information available (required by curl)
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 BoringSSL zlib/1.2.11 brotli/1.0.9 nghttp2/1.46.0
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL UnixSockets
WARNING: curl and libcurl versions do not match. Functionality may be affected.
ldd /usr/bin/curl
/usr/bin/curl: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/curl)
        linux-vdso.so.1 (0x00007ffc4bf3c000)
        libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007f68424ca000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f68424a4000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6842481000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f684228f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f68427c3000)
momala454 commented 2 years ago

also, what's the proper way to replace a library for libcurl in linux using /usr/local/lib ?

It looks like renaming to /usr/local/lib/libcurl.so.4 doesn't work, even after running ldconfig, it looks like it know it is "libcurl-impersonate" and not "libcurl".

Libcurl impersonate only works in conjonction of LD_LIBRARY_PATH or LD_PRELOAD, but that's not great. Do you know a better way using ldconfig ?

Directly replacing /usr/lib/x86_64-linux-gnu/libcurl.so.4 only works until a package is updated on the system

momala454 commented 2 years ago

Actually, LD_PRELOAD doesn't work due to SONAME

LD_PRELOAD=/home/libcurl-impersonate.so php script.php

script.php content : print_r(curl_version());

will show [ssl_version] => OpenSSL/1.1.1n

if I replace /usr/lib/x86_64-linux-gnu/libcurl.so.4 with libcurl-impersonate.so (after renaming), it works [ssl_version] => BoringSSL

instead of replacing /usr/lib/x86_64-linux-gnu/libcurl.so.4, i can do this : LD_PRELOAD will only work if I do this before patchelf --set-soname libcurl.so.4 /home/libcurl-impersonate.so

lwthiker commented 2 years ago

When using libcurl-impersonate.so (not sure which one to use, there is .so, .so.4, .so.4.7.0) compiled and replaced, curl will show an error with version not available

libcurl-impersonate is intentionally built without the version information. If I remember correctly, when I built it with version information it wouldn't work since the symbol version information contains the TLS library used. Then you get a mismatch (i.e OpenSSL vs. BoringSSL). I think it is better to leave libcurl-impersonate without versioning info, and I believe you can safely ignore this error.

Libcurl impersonate only works in conjonction of LD_LIBRARY_PATH or LD_PRELOAD, but that's not great. Do you know a better way using ldconfig ?

I think these methods should be preferred. I would consider them less hacky than replacing the system's libcurl, which is not really a good way to do this as you mentioned. LD_PRELOAD exists for exactly these kind of situations :)

Actually, LD_PRELOAD doesn't work due to SONAME

LD_PRELOAD definitely works even without changing the SONAME. Try doing LD_PRELOAD=/path/to/libcurl-impersonate-chrome.so curl --version and it will output:

curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 BoringSSL zlib/1.2.11 brotli/1.0.9 nghttp2/1.46.0

If I had to guess, what you are seeing is some PHP-specific quirk. My guess would be that PHP loads libcurl dynamically at runtime and somehow uses its symbols instead of libcurl-impersonate

momala454 commented 2 years ago

Is it possible to use the libcurl soname so it will work for every situation without requiring to tweak with patchelf ?

steamboatid commented 3 weeks ago

is there any way to suppress this kind of error?