OS X compile errors

2007-03-27
2013-05-09
  • libproxychains.c:224: error: conflicting types for `connect'
    /usr/include/sys/socket.h:513: error: previous declaration of `connect'
    libproxychains.c:295: error: conflicting types for `getnameinfo'
    /usr/include/netdb.h:257: error: previous declaration of `getnameinfo'
    libproxychains.c:313: error: conflicting types for `gethostbyaddr'
    /usr/include/netdb.h:225: error: previous declaration of `gethostbyaddr'

    The conflicting declarations are:

    proxychains:
    int connect (int sock, const struct sockaddr *addr, unsigned int len)

    int getnameinfo (const struct sockaddr * sa,
                            socklen_t salen, char * host,
                            socklen_t hostlen, char * serv,
                            socklen_t servlen, unsigned int flags)

    struct hostent *gethostbyaddr (const void *addr, socklen_t len,
                                                          int type)

    OS X:

    int     connect __P((int, const struct sockaddr *, socklen_t));

    int             getnameinfo(const struct sockaddr *, socklen_t, char *,
    size_t, char *, size_t, int);

    struct hostent  *gethostbyaddr(const char *, int, int);

    Any possibility of getting a workaround? I'm just an aging Perl hacker, don't know enough C to have a go at it myself... but I can test. :)

     
    • netcreature
      netcreature
      2007-03-27

      Let's say you fixed prototypes.
      Anyway, it won't work on OSX as is...

      Here is why:
      proxychains uses shared object to intercept TCP/DNS related libc calls.
      the object is loaded by dynamic linker (LD_PRELOAD) which is different on OSX.

      There is more work to do for OSX, beyond prototypes.

       
    • OK, it's an LD_PRELOADer. Thanks - if anybody wants to test an OS X port, just contact me.

       
    • zikman
      zikman
      2007-03-27

      I'd like to test an OS X port. my email is zikman@gmail.com

       
    • I also cannot get a compile to work on OS X (Leopard 10.5). Please send help to craig (AT) lateral.co.za. Many thanks, Craig

       
    • B Harley
      B Harley
      2009-07-12

      does anyone have a version working on os x?  bsoftbhardware  -at-  mac.com

      thanks so much.

       
    • nonono nonono
      nonono nonono
      2009-09-01

      please can I have the source as I am trying to compile for iphone

       
  • bgt
    bgt
    2010-03-24

    With a few minor tweaks ProxyChains does work on OS X (at least 10.6.2).  It's not pretty but I've posted a patch with my mods that work for me here: http://chrootlabs.org/bgt/proxychains_osx.html.

     

  • Anonymous
    2010-05-20

    Before it disappears completely from the net, here is the info on how to patch:

    ProxyChains for Mac OS X patch.

    This patch works against the ProxyChains 3.1 source, which you can get at http://prdownloads.sourceforge.net/proxychains/proxychains-3.1.tar.gz?download.

    I've tested this on OS X 10.6.2 ONLY. I have no idea if this will work on other versions.

    Patch for OS X: proxychains-3.1_osx.diff. From the directory above your source tree, apply with

    patch -p1 < proxychains-3.1_osx.diff

    I've setup the proxychains script to run from the source tree, like so:

    cd proxychains-3.1
    ./configure
    cd proxychains
    make
    ./proxychains

    If you want to run it from somewhere else, copy proxychains-3.1/proxychains/.libs/libproxychains.3.0.0.dylib to wherever you want it and modify the proxychains and proxyresolv scripts with the appropriate path.

    proxyresolv is still a bit iffy, best to use IP addresses.

    24 Mar 2010 bgtchrootlabs.org

    And the patch:

    diff -ruN clean/proxychains-3.1/proxychains/core.c mods/proxychains-3.1/proxychains/core.c
    --- clean/proxychains-3.1/proxychains/core.c    2006-03-15 10:16:59.000000000 -0600
    +++ mods/proxychains-3.1/proxychains/core.c 2010-03-24 10:54:54.000000000 -0500
    @@ -35,12 +35,18 @@
     #include <fcntl.h>
     #include <time.h>
     #include <stdarg.h>
    +#include <dlfcn.h>
     #include "core.h"
    
     extern int tcp_read_time_out;
     extern int tcp_connect_time_out;
     extern int proxychains_quiet_mode;
    -
    +extern connect_t true_connect;
    +extern getaddrinfo_t true_getaddrinfo;
    +extern freeaddrinfo_t true_freeaddrinfo;
    +extern getnameinfo_t true_getnameinfo;
    +extern gethostbyaddr_t true_gethostbyaddr;
    + 
     static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    
     static void encode_base_64(char* src,char* dest,int max_len)
    @@ -159,13 +165,14 @@
    
        pfd[0].fd=sock;
        pfd[0].events=POLLOUT;  
    -   fcntl(sock, F_SETFL, O_NONBLOCK);
    +   fcntl(sock, F_SETFL, O_NONBLOCK); 
        ret=true_connect(sock, addr,  len);
    -// printf("\nconnect ret=%d\n",ret);fflush(stdout);
    +// printf("\nconnect ret=%d\n",ret); fflush(stdout);
    +
        if(ret==-1 && errno==EINPROGRESS)
            {
                ret=poll(pfd,1,tcp_connect_time_out);
    -//             printf("\npoll ret=%d\n",ret);fflush(stdout);
    +//             printf("\npoll ret=%d\n",ret);fflush(stdout);
                if(ret==1)
                {
                        value_len=sizeof(int);
    @@ -388,14 +395,18 @@
                    inet_ntoa(*(struct in_addr*)&pd->ip),
                    htons(pd->port));
        pd->ps=PLAY_STATE;
    +
        bzero(&addr,sizeof(addr));
    +
        addr.sin_family = AF_INET;
        addr.sin_addr.s_addr = pd->ip;
        addr.sin_port = pd->port;
    +
        if (timed_connect (*fd ,(struct sockaddr*)&addr,sizeof(addr))) {
            pd->ps=DOWN_STATE;
            goto error1;
        }
    +
        pd->ps=BUSY_STATE;
        return SUCCESS;
     error1:
    @@ -641,7 +652,7 @@
                dup2(pipe_fd[1],1);
                //dup2(pipe_fd[1],2);
            //  putenv("LD_PRELOAD=");
    -           execlp("proxyresolv","proxyresolv",name,NULL);
    +           execlp("./proxyresolv","proxyresolv",name,NULL);
                perror("can't exec proxyresolv");
                exit(2);
    
    diff -ruN clean/proxychains-3.1/proxychains/core.h mods/proxychains-3.1/proxychains/core.h
    --- clean/proxychains-3.1/proxychains/core.h    2006-03-15 10:16:59.000000000 -0600
    +++ mods/proxychains-3.1/proxychains/core.h 2010-03-24 10:55:01.000000000 -0500
    @@ -66,29 +66,28 @@
     int proxychains_write_log(char *str,...);
     struct hostent* proxy_gethostbyname(const char *name);
    
    +typedef struct hostent* (*gethostbyname_t)(const char *);
    +static gethostbyname_t true_gethostbyname;
    
     typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
    -connect_t true_connect;
    -
    -typedef struct hostent* (*gethostbyname_t)(const char *);
    -gethostbyname_t true_gethostbyname;
    +// connect_t true_connect;
    
     typedef int (*getaddrinfo_t)(const char *, const char *,
            const struct addrinfo *,
            struct addrinfo **);
    -getaddrinfo_t true_getaddrinfo;
    +// getaddrinfo_t true_getaddrinfo;
    
     typedef int (*freeaddrinfo_t)(struct addrinfo *);
    -freeaddrinfo_t true_freeaddrinfo;
    +// freeaddrinfo_t true_freeaddrinfo;
    
     typedef int (*getnameinfo_t) (const struct sockaddr *,
            socklen_t, char *,
            socklen_t, char *,
            socklen_t, unsigned int);
    -getnameinfo_t true_getnameinfo;
    +// getnameinfo_t true_getnameinfo;
    
     typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
    -gethostbyaddr_t true_gethostbyaddr;
    +// gethostbyaddr_t true_gethostbyaddr;
    
     int proxy_getaddrinfo(const char *node, const char *service,
                            const struct addrinfo *hints,
    diff -ruN clean/proxychains-3.1/proxychains/libproxychains.c mods/proxychains-3.1/proxychains/libproxychains.c
    --- clean/proxychains-3.1/proxychains/libproxychains.c  2006-03-15 10:16:59.000000000 -0600
    +++ mods/proxychains-3.1/proxychains/libproxychains.c   2010-03-24 10:54:55.000000000 -0500
    @@ -32,7 +32,6 @@
     #include <sys/fcntl.h>
     #include <dlfcn.h>
    
    -
     #include "core.h"
    
     #define     satosin(x)      ((struct sockaddr_in *) &(x))
    @@ -57,6 +56,13 @@
        unsigned int *proxy_count,
        chain_type *ct);
    
    +connect_t true_connect;
    +getaddrinfo_t true_getaddrinfo;
    +freeaddrinfo_t true_freeaddrinfo;
    +getnameinfo_t true_getnameinfo;
    +gethostbyaddr_t true_gethostbyaddr;
    +
    +
     static void init_lib()
     {
     // proxychains_write_log("ProxyChains-"VERSION
    @@ -291,7 +297,7 @@
     int getnameinfo (const struct sockaddr * sa,
                socklen_t salen, char * host,
                socklen_t hostlen, char * serv,
    -           socklen_t servlen, unsigned int flags)
    +           socklen_t servlen, int flags)
     {
        int ret = 0;
        if(!init_l)
    diff -ruN clean/proxychains-3.1/proxychains/proxychains mods/proxychains-3.1/proxychains/proxychains
    --- clean/proxychains-3.1/proxychains/proxychains   2006-03-15 10:16:59.000000000 -0600
    +++ mods/proxychains-3.1/proxychains/proxychains    2010-03-24 10:55:09.000000000 -0500
    @@ -1,9 +1,11 @@
     #!/bin/sh
     echo "ProxyChains-3.1 (http://proxychains.sf.net)"
    +echo "Mod for OSX - using dylib"
     if [ $# = 0 ] ; then
        echo "  usage:"
        echo "      proxychains <prog> [args]"
        exit
     fi
    -export LD_PRELOAD=libproxychains.so
    +export DYLD_FORCE_FLAT_NAMESPACE=
    +export DYLD_INSERT_LIBRARIES=./.libs/libproxychains.3.0.0.dylib
     exec "$@"
    diff -ruN clean/proxychains-3.1/proxychains/proxyresolv mods/proxychains-3.1/proxychains/proxyresolv
    --- clean/proxychains-3.1/proxychains/proxyresolv   2006-03-15 10:16:59.000000000 -0600
    +++ mods/proxychains-3.1/proxychains/proxyresolv    2010-03-24 10:55:16.000000000 -0500
    @@ -11,6 +11,6 @@
        exit
     fi
    
    -
    -export LD_PRELOAD=libproxychains.so
    +export DYLD_FORCE_FLAT_NAMESPACE=
    +export DYLD_INSERT_LIBRARIES=./.libs/libproxychains.3.0.0.dylib
     dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
    
     

  • Anonymous
    2010-05-20

    To make this working on Mac OS X (I used 10.4, should be the same everywhere), you'll need to move the libraries to a good path for the dynamic libraries (they are wrongly installed in /lib), i chose /usr/local/bin:

    sudo mv /lib/libproxychains.* /usr/local/lib/

    and make sure it's listed in your DYLD_LIBRARY_PATH

    $ echo $DYLD_LIBRARY_PATH
    /usr/local/lib:…

     
  • bgt
    bgt
    2011-06-15

    Quick update: It's been awhile since I used this, but fired it up today and noticed I was getting intermittent "dyld: could not load inserted library" errors.  This was because the library is building x86_64 by default and I have a lot of tools still built with i386.

    I've posted a change to the patch that builds a universal (i386 + x86_64) binary so both architectures are supported by default. The only change is adding  "-arch i386 -arch x86_64" to CFLAGS in the makefile.

     
  • Bar
    Bar
    2013-02-06

    Tried to build this on my iPhone but got this error:

    make
    make  all-recursive
    make: Entering directory `/private/var/mobile/proxychains-3.1'
    Making all in proxychains
    make: Entering directory `/private/var/mobile/proxychains-3.1/proxychains'
    Making all in docs
    make: Entering directory `/private/var/mobile/proxychains-3.1/proxychains/docs'
    Making all in en
    make: Entering directory `/private/var/mobile/proxychains-3.1/proxychains/docs/en'
    make: Nothing to be done for `all'.
    make: Leaving directory `/private/var/mobile/proxychains-3.1/proxychains/docs/en'
    make: Entering directory `/private/var/mobile/proxychains-3.1/proxychains/docs'
    make: Nothing to be done for `all-am'.
    make: Leaving directory `/private/var/mobile/proxychains-3.1/proxychains/docs'
    make: Leaving directory `/private/var/mobile/proxychains-3.1/proxychains/docs'
    make: Entering directory `/private/var/mobile/proxychains-3.1/proxychains'
    /bin/sh ../libtool -mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -arch x86_64 -arch i386  -c libproxychains.c
    gcc -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -arch x86_64 -arch i386 -Wp,-MD,.deps/libproxychains.pp -c libproxychains.c  -fno-common -DPIC -o .libs/libproxychains.o
    cc1: error: unrecognized command line option "-arch"
    cc1: error: unrecognized command line option "-arch"
    make: ***  Error 1
    make: Leaving directory `/private/var/mobile/proxychains-3.1/proxychains'
    make: ***  Error 1
    make: Leaving directory `/private/var/mobile/proxychains-3.1/proxychains'
    make: ***  Error 1
    make: Leaving directory `/private/var/mobile/proxychains-3.1'
    make: ***  Error 2

     
  • rofl0r
    rofl0r
    2013-02-10

    barachy: use https://github.com/rofl0r/proxychains which has OSX support built-in

    no need to apply this ancient and bogus patch