Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

doesn't compile on osx 10.7.3 #11

Closed
franck09 opened this Issue Jan 26, 2012 · 32 comments

Comments

Projects
None yet
3 participants

sh-3.2# make
cc -shared -fPIC -ldl -lpthread -Wl,-soname=libproxychains4.so -o libproxychains4.so src/core.o src/libproxychains.o
ld: unknown option: -soname=libproxychains4.so
collect2: ld returned 1 exit status
make: *** [libproxychains4.so] Error 1

sh-3.2# gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.1525/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.1525/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

Apparently it can be resolved with the install_name switch instead of soname, in the Makefile :

55 $(LDSO_PATHNAME): $(LOBJS)
56 $(CC) $(LDFLAGS) -Wl,-install_name,$(LDSO_PATHNAME) -o $@ $(LOBJS)

sh-3.2# make
cc -shared -fPIC -ldl -lpthread -Wl,-install_name,libproxychains4.so -o libproxychains4.so src/core.o src/libproxychains.o
cc -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -DLIB_DIR="/usr/local/lib" -fPIC -c -o src/main.o src/main.c
cc src/main.o -o proxychains4

However its seems that make install doesn't work

sh-3.2# make install
install -D -m 755 proxychains4 /usr/local/bin/
install: illegal option -- D
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
make: *** [install] Error 64

Contributor

rofl0r commented Jan 26, 2012

for the time being you can just copy the stuff over there manually

Fixed with the simple removal of the -D option

Makefile :

41 #install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
42 install:
43 install -m 755 $(ALL_TOOLS) $(bindir)/
44 install -m 644 $(ALL_LIBS) $(libdir)/
45 install -m 644 src/proxychains.conf $(prefix)/etc/
46

sh-3.2# make install
install -m 755 proxychains4 /usr/local/bin/
install -m 644 libproxychains4.so /usr/local/lib/
install -m 644 src/proxychains.conf /usr/local/etc/
sh-3.2# proxychains4

Usage: proxychains4 -q -f config_file program_name [arguments]
-q makes proxychains quiet - this overrides the config setting
-t allows to manually specify a configfile to use
for example : proxychains telnet somehost.com
More help in README file

Contributor

rofl0r commented Jan 26, 2012

that's quite a success, given that the original proxychains 3.1 did not compile on OSX at all. there were numerous issues.
however, you should try if it really works. i.e. if the DLL gets preloaded correctly.

humm.. I'm not sure it's working correctly, a simple test with ping seems to show that proxychains works (well doesnt crash at least), I receive a real response from Google ;

sh-3.2# proxychains4 -f proxychains.conf ping www.google.com
[proxychains] config file found: proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
PING www.l.google.com (74.125.115.99): 56 data bytes
64 bytes from 74.125.115.99: icmp_seq=0 ttl=51 time=29.227 ms
64 bytes from 74.125.115.99: icmp_seq=1 ttl=51 time=28.809 ms
64 bytes from 74.125.115.99: icmp_seq=2 ttl=51 time=29.545 ms
^C

However, a test with curl to get my ip address with the service ifconfig.me shows that even if I use proxychains4 to anonymize the curl traffic, I still get my real ip...

sh-3.2# proxychains4 -f proxychains.conf curl ifconfig.me/all
[proxychains] config file found: proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
ip_addr: 208.92.18.220
remote_host: dsl-208-92-18-220.cooptel.qc.ca
user_agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
port: 57346
lang:
connection:
keep_alive:
encoding:
mime: /
charset:
via:
forwarded:

sh-3.2# curl ifconfig.me/all
ip_addr: 208.92.18.220
remote_host: dsl-208-92-18-220.cooptel.qc.ca
user_agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
port: 57381
lang:
connection:
keep_alive:
encoding:
mime: /
charset:
via:
forwarded:

Contributor

rofl0r commented Jan 26, 2012

that ping does not work is totally normal. it uses ICMP, and not TCP.
but curl should work, given that OSX supports LD_PRELOAD...
http://en.wikipedia.org/wiki/LD_PRELOAD#Mac_OS_X_and_iOS

Contributor

rofl0r commented Jan 26, 2012

you might want to change the dll file extension from .so to .dylib in both Makefile and main.c
also try this ENV variable: DYLD_INSERT_LIBRARIES (maybe instead of LD_PRELOAD in main.c ? or just before your curl command line)
here's the reference for the mac dynlinker flags
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/dyld.1.html

This is what I changed in main.c

sh-3.2# git diff main.c
diff --git a/src/main.c b/src/main.c
index 9b84b11..1258f9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,7 +46,7 @@ int check_path(char* path) {
}

/* XXX This shouldn't be defined here /
-static const char
dll_name = "libproxychains4.so";
+static const char* dll_name = "libproxychains4.dylib";

static char own_dir[256];
static const char* dll_dirs[] = {
@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
}
if(!quiet) fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);

  •   snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/%s", prefix, dll_name);
    
  •   snprintf(buf, sizeof(buf), "DYLD_INSERT_LIBRARIES=%s/%s", prefix, dll_name);
    
    putenv(buf);
    execvp(argv[start_argv], &argv[start_argv]);
    

and I also changed the extension in the Makefile, recompiled proxychains;

sh-3.2# make install
install -m 755 proxychains4 /usr/local/bin/
install -m 644 libproxychains4.dylib /usr/local/lib/
install -m 644 src/proxychains.conf /usr/local/etc/

but the results from curl are still the same :

sh-3.2# proxychains4 -f proxychains.conf curl ifconfig.me/all
[proxychains] config file found: proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.dylib
ip_addr: 208.92.18.220
remote_host: dsl-208-92-18-220.cooptel.qc.ca
user_agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
port: 57900

Contributor

rofl0r commented Jan 26, 2012

isnt curl a python or perl script ?

proxychains only works with dynamically linked programs which are compiled to machine code.

try something else, i.e. telnet or netcat or wget
$ ./proxychains4 netcat ifconfig.me 80
[proxychains] config file found: ./proxychains.conf
[proxychains] preloading ./libproxychains4.so
[proxychains] DLL init
[proxychains] Strict chain ... 127.0.0.1:9050 ... ifconfig.me:80 ... OK
GET http://ifconfig.me/all HTTP/1.0[press 2 times return]

HTTP/1.1 200 OK
[...]

Owner

haad commented Jan 27, 2012

curl is C program, but I think it uses libcurl to actually fetch data.

Contributor

rofl0r commented Jan 27, 2012

@franck09 i've collected all stuff i learned here and some other info and made a potentially working mac version

https://github.com/rofl0r/proxychains

please check it out and tell me if it works. you shouldnt have to do any hacks anymore.
dont forget to run ./configure !

Owner

haad commented Jan 27, 2012

It should work with this repo now, I have merged rofl0r changes into HEAD. I have done some tests on my mac and it seems to be working now.

How did you get it working  ? I tried again with the lastest version of the repo, and both curl and nc report me my real ip on ifconfig.me ....

Contributor

rofl0r commented Jan 28, 2012

i have no mac to test; i'm just assuming that it should possibly work now.
i was reading this here, for example http://sprocket.io/blog/2005/08/preloading-shared-libraries-in-mac-os-x/
what is potentially missing is the -lSystemStubs he adds to the linker line. you could try to add that to the -ldl stuff.

Contributor

rofl0r commented Jan 28, 2012

other interesting links
https://github.com/sickill/stderred/blob/master/README.md
especially how he calls the "lipo" tool on the .so to generate a .dylib

and http://marc-abramowitz.com/download/tsocks-1.8_macosx.patch however this one here seems to use mediocre techniques

Owner

haad commented Jan 28, 2012

Hi,

Can you please pull and retest it should be working for you now. I did some changes and both shellscript src/proxychains and proxychains binary are working for me now.

I repulled it and it's now working ! Wonderful !

sh-3.2# proxychains4 -f proxychains.conf nc ifconfig.me 80
[proxychains] config file found: proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.dylib
[proxychains] DLL init
[proxychains] Strict chain ... 127.0.0.1:9050 ... ifconfig.me:80 ... OK
GET http://ifconfig.me/all HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 28 Jan 2012 14:44:34 GMT
Server: Apache
Vary: Accept-Encoding
Connection: close
Content-Type: text/plain

ip_addr: 46.105.116.88
remote_host: ns224149.ovh.net
user_agent:
port: 48742
[...]

sh-3.2# proxychains4 -f proxychains.conf curl ifconfig.me/all
[proxychains] config file found: proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.dylib
[proxychains] DLL init
[proxychains] Strict chain ... 127.0.0.1:9050 ... ifconfig.me:80 ... OK
ip_addr: 46.105.116.88
remote_host: ns224149.ovh.net
user_agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
port: 54526
lang:
connection:

Small drawback however, proxychains is searching for the default config file in /etc/, but make install place it in /usr/local/etc

sh-3.2# proxychains4 curl ifconfig.me /all
couldnt find configuration file: No such file or directory

Now that's its working almost perfectly on osx we should create a package for it, on Mac Ports or Homebrew, this would make it easier to install for everybody on osx... what do you think ?

Contributor

rofl0r commented Jan 28, 2012

if you start proxychains4 and not the shellscript it should search in /usr/local/etc before /etc
https://github.com/haad/proxychains/blob/master/src/main.c#L131

Owner

haad commented Jan 28, 2012

That default config regression was introduced by me yesterday when I merged rofl0r changes. It should be fixed now.

It would be great to create a homebrew package for this. After more testing we can make 4.1 release and use it in a package.

If I start the shell script I get another error :

sh-3.2# ./proxychains curl ifconfig.me
ProxyChains-4.0 (http://proxychains.sf.net)
dyld: could not load inserted library: libproxychains4.dylib

Trace/BPT trap: 5

And I just recloned the repo, but proxychains still doesn't seem to find the config file in /usr/local/etc/

sh-3.2# proxychains4 curl ifconfig.me
couldnt find configuration file: No such file or directory

sh-3.2# proxychains4 -f /usr/local/etc/proxychains.conf curl ifconfig.me
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.dylib
[proxychains] DLL init
[proxychains] Strict chain ... 127.0.0.1:9050 ... ifconfig.me:80 ... OK
173.254.216.69

Owner

haad commented Jan 28, 2012

Hmm interesting because it works for me,

[haad@ proxychains]$ ./proxychains4 curl 193.87.174.102
[proxychains] config file found: /tmp/proxychains.conf
[proxychains] preloading ./libproxychains4.dylib
[proxychains] DLL init
[proxychains] Strict chain ... 81.17.24.111:1080 ... 193.87.174.102:80 ... OK

[haad@ proxychains]$ tail -n 3 /usr/local/etc/proxychains.conf
socks4 81.17.24.111 1080

What version of Mac os X do you have ? Can you show me output from make command when you run it in clean repo ?

config file found in /tmp/proxychains.conf ?

I'm on osx 10.7.3, and this is what happens when I do a clean install :

sh-3.2# git clone git://github.com/haad/proxychains.git
Cloning into proxychains...
remote: Counting objects: 385, done.
remote: Compressing objects: 100% (282/282), done.
remote: Total 385 (delta 252), reused 198 (delta 101)
Receiving objects: 100% (385/385), 388.61 KiB | 134 KiB/s, done.
Resolving deltas: 100% (252/252), done.

sh-3.2# cd proxychains/

sh-3.2# ./configure
Darwin
done, now run make && make install

sh-3.2# make
cc -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -DIS_MAC=1 -arch x86_64 -arch i386 -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.dylib" -fPIC -c -o src/core.o src/core.c
cc -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -DIS_MAC=1 -arch x86_64 -arch i386 -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.dylib" -fPIC -c -o src/libproxychains.o src/libproxychains.c
cc -shared -fPIC -ldl -lpthread -Wl,-install_name,libproxychains4.dylib -o libproxychains4.dylib src/core.o src/libproxychains.o
cc -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -DIS_MAC=1 -arch x86_64 -arch i386 -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.dylib" -fPIC -c -o src/main.o src/main.c
cc src/main.o -o proxychains4

sh-3.2# make install
install -m 755 proxychains4 /usr/local/bin/
install -m 644 libproxychains4.dylib /usr/local/lib/
install -m 644 src/proxychains.conf /usr/local/etc/

sh-3.2# cd

sh-3.2# proxychains4 curl ifconfig.me
couldnt find configuration file: No such file or directory

sh-3.2# proxychains4 -f /usr/local/etc/proxychains.conf curl ifconfig.me
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.dylib
[proxychains] DLL init
[proxychains] Strict chain ... 127.0.0.1:9050 ... ifconfig.me:80 ... OK
82.139.93.202

sh-3.2# tail -n 3 /usr/local/etc/proxychains.conf
defaults set to "tor"
socks4 127.0.0.1 9050

Owner

haad commented Jan 28, 2012

Ok this is fixed now. I have one left over in my shell.

Yep. Working fine now !

A Homebrew package would be indeed great, besides that, what kind of new features or roadmap did you guys had in mind for proxychains ?

Other question, I we decide to promote the project, with an easy to install solution, maybe a better documentation, and who knows, a website explaining the purpose of proxychains, do we need to get the approval of the original author ? At what degree is the license permissive ?

Owner

haad commented Jan 28, 2012

Here you go homebrew formula is here https://gist.github.com/1696065. I have opened issue at homebrew repo let's see if we can get this to mainstream.

If you have time a knowledge it would be great to have gh-pages done. Everything
is GPL2 licensed so there should not be any problem with licensing of your changes unless you want to use different license.

Contributor

rofl0r commented Jan 29, 2012

if you refer to my changes, those would be GPL2 to, as required by the existing license.

Wow, nice ! Can't wait to show it to my friends via homebrew ! Again pardon my curiosity, but what future do you envision for proxychains, feature-wise ?

Do you have some plans, or it was simply to make the code a little more up-to-date ?

Personnally, what I would like to create ( that would however require me to learn javascript ), is a tcp proxy, which would be a gateway to a chain of proxies created by proxychains, but a proxy that would include a system, able to gather information about the chains of proxies, like the geographical location of the proxies, and ideally it could display it on a custom web page displaying stats about the chain of proxies.

The route of the traffic bounced on proxies around the globe, could be displayed on a world map like http://workshop.chromeexperiments.com/globe-search

What do you think ?

franck09 commented Feb 2, 2012

Well it would have been interesting to have your feedback, but since the issue is fixed, I'll close it.

@franck09 franck09 closed this Feb 2, 2012

@ddoscomin ddoscomin referenced this issue in rofl0r/proxychains-ng Dec 18, 2012

Closed

Cant make on x86_64-linux-gnu Debian #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment