rofl0r / proxychains-ng

proxychains ng (new generation) - a preloader which hooks calls to sockets in dynamically linked programs and redirects it through one or more socks/http proxies. continuation of the unmaintained proxychains project. the sf.net page is currently not updated, use releases from github release page instead.
http://sourceforge.net/projects/proxychains-ng/files
GNU General Public License v2.0
9.82k stars 1.08k forks source link

proxychains-ng should support both 32-bit and 64-bit binaries #71

Open luizluca opened 9 years ago

luizluca commented 9 years ago

Hello,

proxychains-ng does not play nice with different archs. When I try to run a 64-bit program, it works:

$ proxychains4 /usr/bin/fc-cat 2>&1 | grep proxy [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/lib64/libproxychains4.so [proxychains] DLL init: proxychains-ng 4.10

But this is what I get with 32-bit program:

$ proxychains4 /usr/bin/fc-cat32 2>&1 | grep proxy [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/lib64/libproxychains4.so ERROR: ld.so: object '/usr/lib64/libproxychains4.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.

It would be nice if proxychains-ng to not specify full path in its LD_PRELOAD. This would allow any 32-bit or 64-bit program to select its own version of libproxychains4.so. I extracted libproxychains4.so from a 32-bit compilation and installed it together with the full 64-bit proxychains-ng.

$ file /usr/bin/fc-cat32; LD_PRELOAD=libproxychains4.so /usr/bin/fc-cat32 2>&1 | grep proxy /usr/bin/fc-cat32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=bc52842b8a98bfc79fc36a63a1ac91554d5f2249, stripped [proxychains] DLL init: proxychains-ng 4.10 $ file /usr/bin/fc-cat32; LD_PRELOAD=libproxychains4.so /usr/bin/fc-cat 2>&1 | grep proxy /usr/bin/fc-cat32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=bc52842b8a98bfc79fc36a63a1ac91554d5f2249, stripped [proxychains] DLL init: proxychains-ng 4.10

Also, it would be nice to have a ./configure or Makefile argument that allows to compile 32-bit version of libproxychains4.so when compiling proxychains-ng for 64-bit. This would help packagers.

rofl0r commented 9 years ago

proxychains-ng supports user-supplied CFLAGS and CC parameters in the traditional way (i.e. passed to configure). so someone that wants to use a x86 32bit toolchain can pass that to CC or use -m32 in his CFLAGS if his compiler supports multilib.

luizluca commented 9 years ago

OK, the compiling part is the easy one ;-)

And how about not using full path when preloading libproxychains4.so?

rofl0r commented 8 years ago

iirc there's at least one system (i can't remember if it was OS X or GNU/linux) where the dynlinker rejects LD_PRELOAD with relative paths, so it's done the way it works everywhere. you can test it however by just exporting the LD_PRELOAD variable and running your app directly (without using the proxychains4 launcher, which really does just that).

luizluca commented 8 years ago

@rofl0r , it might be OS X because AFAIK, LD_PRELOAD without dirname is the recommended approach for preloading for multiarch libs on Linux.

If not-supplying-dirname does not work in some OS, could it becomes a ./configure option? Preferably, using relative path by default for those OS that support it. It is really complicate to use proxychains program when the target command is a script that calls both 32-bit and 64-bit apps. (Yes, I know that manually preloading as I used in my first example would work, but maybe we could improve the default behavior)