mirror of
https://github.com/haad/proxychains
synced 2026-06-08 14:30:41 +00:00
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5294214150 | |||
| 385b349a8e | |||
| 2320f6608a | |||
| 251fd7cd4a | |||
| b0d9d1da41 | |||
| a7831a8f53 | |||
| 229eb7cc5a | |||
| c9b8ce35b2 | |||
| 63c3a4b0d2 | |||
| 45f50ac754 | |||
| d72e668767 | |||
| 561679fbcd | |||
| bc23ef8f46 | |||
| 88a54e872a | |||
| caed782652 | |||
| f55c6bc4d5 | |||
| 49293b180d | |||
| 3260ee812a | |||
| 1000366f88 | |||
| 598a41a671 | |||
| 65471b750c | |||
| 4d40a4790f | |||
| 50820ce80d | |||
| b6746997d2 | |||
| 6dda28a2c8 | |||
| fb3d8e04a1 | |||
| 03b49f529e | |||
| e99dd76941 | |||
| 0ee539f31c | |||
| f4e4c8c2b1 | |||
| 0938a940c5 | |||
| 788ffd9d26 | |||
| 99dcfe085e | |||
| dbb172b510 | |||
| 48373ab7a5 | |||
| 89e8bfddf4 | |||
| adb13c7e79 | |||
| 2250ef66a8 | |||
| e991cabb94 | |||
| 070051bb73 | |||
| c36db11ebc | |||
| 6d25f5d89e | |||
| 9c83402d37 | |||
| 5b5cc604a6 | |||
| 526fb8b410 | |||
| 2acdcd9707 | |||
| 3bb03892fa | |||
| e32ef26fec | |||
| 80817dbf6f | |||
| 73c4195ce3 | |||
| cce902b301 | |||
| d28cf03c61 | |||
| 952a039801 | |||
| 8d9bb5545c | |||
| f512779539 | |||
| f53119773a | |||
| 2f9a9cf0b0 | |||
| cdec339f11 | |||
| fe8672eab6 | |||
| d9341a8c74 | |||
| af5163bccf | |||
| b618a4ece3 | |||
| 4da71e1b44 | |||
| 75d41dea3d | |||
| 75bd465038 |
@@ -8,6 +8,7 @@
|
|||||||
prefix = /usr/local
|
prefix = /usr/local
|
||||||
includedir = $(prefix)/include
|
includedir = $(prefix)/include
|
||||||
libdir = $(prefix)/lib
|
libdir = $(prefix)/lib
|
||||||
|
confdir = $(prefix)/etc
|
||||||
|
|
||||||
exec_prefix = $(prefix)
|
exec_prefix = $(prefix)
|
||||||
bindir = $(exec_prefix)/bin
|
bindir = $(exec_prefix)/bin
|
||||||
@@ -16,33 +17,41 @@ SRCS = $(sort $(wildcard src/*.c))
|
|||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
LOBJS = src/core.o src/libproxychains.o
|
LOBJS = src/core.o src/libproxychains.o
|
||||||
|
|
||||||
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE
|
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
|
||||||
LDFLAGS = -shared -fPIC -ldl -lpthread
|
LDFLAGS = -shared -fPIC -ldl -lpthread
|
||||||
INC =
|
INC =
|
||||||
PIC = -fPIC
|
PIC = -fPIC
|
||||||
AR = $(CROSS_COMPILE)ar
|
AR = $(CROSS_COMPILE)ar
|
||||||
RANLIB = $(CROSS_COMPILE)ranlib
|
RANLIB = $(CROSS_COMPILE)ranlib
|
||||||
|
|
||||||
LDSO_PATHNAME = libproxychains4.so
|
LDSO_SUFFIX = so
|
||||||
|
LD_SET_SONAME = -Wl,-soname=
|
||||||
|
INSTALL_FLAGS = -D -m
|
||||||
|
|
||||||
|
-include config.mak
|
||||||
|
|
||||||
|
LDSO_PATHNAME = libproxychains4.$(LDSO_SUFFIX)
|
||||||
|
|
||||||
SHARED_LIBS = $(LDSO_PATHNAME)
|
SHARED_LIBS = $(LDSO_PATHNAME)
|
||||||
ALL_LIBS = $(SHARED_LIBS)
|
ALL_LIBS = $(SHARED_LIBS)
|
||||||
PXCHAINS = proxychains4
|
PXCHAINS = proxychains4
|
||||||
ALL_TOOLS = $(PXCHAINS)
|
ALL_TOOLS = $(PXCHAINS)
|
||||||
|
|
||||||
-include config.mak
|
|
||||||
|
|
||||||
CFLAGS+=$(USER_CFLAGS)
|
CCFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
|
||||||
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\"
|
LDFLAGS+=$(USER_LDFLAGS) $(MAC_LDFLAGS)
|
||||||
|
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(MAC_CFLAGS)
|
||||||
|
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\"
|
||||||
|
|
||||||
|
|
||||||
all: $(ALL_LIBS) $(ALL_TOOLS)
|
all: $(ALL_LIBS) $(ALL_TOOLS)
|
||||||
|
|
||||||
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
|
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
|
||||||
install:
|
install:
|
||||||
install -D -m 755 $(ALL_TOOLS) $(bindir)/
|
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(libdir) $(DESTDIR)/$(confdir) $(DESTDIR)/$(includedir)
|
||||||
install -D -m 644 $(ALL_LIBS) $(libdir)/
|
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) $(DESTDIR)/$(bindir)/
|
||||||
install -D -m 644 src/proxychains.conf $(prefix)/etc/
|
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
|
||||||
|
install $(INSTALL_FLAGS) 644 src/proxychains.conf $(DESTDIR)/$(confdir)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALL_LIBS)
|
rm -f $(ALL_LIBS)
|
||||||
@@ -50,13 +59,12 @@ clean:
|
|||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||||
|
|
||||||
$(LDSO_PATHNAME): $(LOBJS)
|
$(LDSO_PATHNAME): $(LOBJS)
|
||||||
$(CC) $(LDFLAGS) -Wl,-soname=$(LDSO_PATHNAME) -o $@ $(LOBJS)
|
$(CC) $(LDFLAGS) $(LD_SET_SONAME)$(LDSO_PATHNAME) -o $@ $(LOBJS)
|
||||||
|
|
||||||
$(ALL_TOOLS): $(OBJS)
|
$(ALL_TOOLS): $(OBJS)
|
||||||
$(CC) src/main.o -o $(PXCHAINS)
|
$(CC) src/main.o -o $(PXCHAINS)
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all clean install
|
.PHONY: all clean install
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
ProxyChains ver 3.1 TODO
|
ProxyChains ver 4.0 TODO
|
||||||
===================
|
===================
|
||||||
|
|
||||||
stable DNS resolver .... currently gnu dig is used, which is an ugly hack
|
|
||||||
also it is required to link it with the same libc as proxychains
|
|
||||||
|
|
||||||
hooks for reentrant dns functions, i.e. gethostbyaddr_r
|
hooks for reentrant dns functions, i.e. gethostbyaddr_r
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,19 @@ spliteq() {
|
|||||||
|
|
||||||
parsearg() {
|
parsearg() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--prefix=*) prefix=$(spliteq "$1");;
|
--prefix=*) prefix=`spliteq $1`;;
|
||||||
--exec_prefix=*) exec_prefix=`spliteq $1`;;
|
--exec_prefix=*) exec_prefix=`spliteq $1`;;
|
||||||
--bindir=*) bindir=`spliteq $1`;;
|
--bindir=*) bindir=`spliteq $1`;;
|
||||||
--libdir=*) libdir=`spliteq $1`;;
|
--libdir=*) libdir=`spliteq $1`;;
|
||||||
--includedir=*) includedir=`spliteq $1`;;
|
--includedir=*) includedir=`spliteq $1`;;
|
||||||
|
--sysconfdir=*) sysconfdir=`spliteq $1`;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ismac() {
|
||||||
|
uname -s | grep Darwin
|
||||||
|
}
|
||||||
|
|
||||||
while true ; do
|
while true ; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-*) parsearg "$1"; shift;;
|
-*) parsearg "$1"; shift;;
|
||||||
@@ -26,23 +31,27 @@ while true ; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! $exec_prefix ] ; then
|
if [ -z "$exec_prefix" ] ; then
|
||||||
exec_prefix=$prefix
|
exec_prefix=$prefix
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $libdir ] ; then
|
if [ -z "$libdir" ] ; then
|
||||||
libdir=$prefix/lib
|
libdir=$prefix/lib
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $includedir ] ; then
|
if [ -z "$includedir" ] ; then
|
||||||
includedir=$prefix/include
|
includedir=$prefix/include
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $bindir ] ; then
|
if [ -z "$sysconfdir" ] ; then
|
||||||
|
sysconfdir=$prefix/etc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$bindir" ] ; then
|
||||||
bindir=$exec_prefix/bin
|
bindir=$exec_prefix/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $CC ] ; then
|
if [ -z "$CC" ] ; then
|
||||||
CC=cc
|
CC=cc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -54,6 +63,14 @@ echo exec_prefix=$exec_prefix>>config.mak
|
|||||||
echo bindir=$bindir>>config.mak
|
echo bindir=$bindir>>config.mak
|
||||||
echo libdir=$libdir>>config.mak
|
echo libdir=$libdir>>config.mak
|
||||||
echo includedir=$includedir>>config.mak
|
echo includedir=$includedir>>config.mak
|
||||||
|
echo sysconfdir=$sysconfdir>>config.mak
|
||||||
|
if ismac ; then
|
||||||
|
echo LDSO_SUFFIX=dylib>>config.mak
|
||||||
|
echo MAC_CFLAGS+=-DIS_MAC=1 -arch x86_64 -arch i386 >>config.mak
|
||||||
|
echo MAC_LDFLAGS+=-arch x86_64 -arch i386 >>config.mak
|
||||||
|
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
|
||||||
|
echo INSTALL_FLAGS=-m>>config.mak
|
||||||
|
fi
|
||||||
|
|
||||||
echo done, now run make \&\& make install
|
echo done, now run make \&\& make install
|
||||||
|
|
||||||
|
|||||||
+509
-540
File diff suppressed because it is too large
Load Diff
+18
-26
@@ -18,7 +18,7 @@
|
|||||||
#ifndef __CORE_HEADER
|
#ifndef __CORE_HEADER
|
||||||
#define __CORE_HEADER
|
#define __CORE_HEADER
|
||||||
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
||||||
#define MAX_LOCALNET 1024
|
#define MAX_LOCALNET 64
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char octet[4];
|
unsigned char octet[4];
|
||||||
@@ -37,9 +37,17 @@ typedef struct {
|
|||||||
} internal_ip_lookup_table;
|
} internal_ip_lookup_table;
|
||||||
|
|
||||||
extern internal_ip_lookup_table internal_ips;
|
extern internal_ip_lookup_table internal_ips;
|
||||||
|
|
||||||
#ifdef THREAD_SAFE
|
#ifdef THREAD_SAFE
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
extern pthread_mutex_t internal_ips_lock;
|
pthread_mutex_t internal_ips_lock;
|
||||||
|
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
|
||||||
|
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
|
||||||
|
# define MUTEX_INIT(x,y) pthread_mutex_init(x, y)
|
||||||
|
#else
|
||||||
|
# define MUTEX_LOCK(x)
|
||||||
|
# define MUTEX_UNLOCK(x)
|
||||||
|
# define MUTEX_INIT(x,y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*error codes*/
|
/*error codes*/
|
||||||
@@ -52,7 +60,6 @@ typedef enum {
|
|||||||
BLOCKED // target's port blocked on last proxy in the chain
|
BLOCKED // target's port blocked on last proxy in the chain
|
||||||
} ERR_CODE;
|
} ERR_CODE;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HTTP_TYPE,
|
HTTP_TYPE,
|
||||||
SOCKS4_TYPE,
|
SOCKS4_TYPE,
|
||||||
@@ -91,27 +98,11 @@ typedef struct {
|
|||||||
char pass[256];
|
char pass[256];
|
||||||
} proxy_data;
|
} proxy_data;
|
||||||
|
|
||||||
typedef struct {
|
int connect_proxy_chain (int sock, ip_type target_ip, unsigned short target_port,
|
||||||
proxy_data *pd;
|
proxy_data * pd, unsigned int proxy_count, chain_type ct,
|
||||||
chain_type ct;
|
unsigned int max_chain );
|
||||||
unsigned int proxy_count;
|
|
||||||
int sock;
|
|
||||||
struct sockaddr addr;
|
|
||||||
int flags;
|
|
||||||
} thread_arg;
|
|
||||||
|
|
||||||
int connect_proxy_chain (
|
|
||||||
int sock,
|
|
||||||
ip_type target_ip,
|
|
||||||
unsigned short target_port,
|
|
||||||
proxy_data * pd,
|
|
||||||
unsigned int proxy_count,
|
|
||||||
chain_type ct,
|
|
||||||
unsigned int max_chain );
|
|
||||||
|
|
||||||
int proxychains_write_log(char *str,...);
|
int proxychains_write_log(char *str,...);
|
||||||
struct hostent* proxy_gethostbyname(const char *name);
|
|
||||||
|
|
||||||
|
|
||||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||||
connect_t true_connect;
|
connect_t true_connect;
|
||||||
@@ -130,22 +121,23 @@ freeaddrinfo_t true_freeaddrinfo;
|
|||||||
typedef int (*getnameinfo_t) (const struct sockaddr *,
|
typedef int (*getnameinfo_t) (const struct sockaddr *,
|
||||||
socklen_t, char *,
|
socklen_t, char *,
|
||||||
socklen_t, char *,
|
socklen_t, char *,
|
||||||
socklen_t, unsigned int);
|
socklen_t, int);
|
||||||
getnameinfo_t true_getnameinfo;
|
getnameinfo_t true_getnameinfo;
|
||||||
|
|
||||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
||||||
gethostbyaddr_t true_gethostbyaddr;
|
gethostbyaddr_t true_gethostbyaddr;
|
||||||
|
|
||||||
|
struct hostent* proxy_gethostbyname(const char *name);
|
||||||
|
|
||||||
int proxy_getaddrinfo(const char *node, const char *service,
|
int proxy_getaddrinfo(const char *node, const char *service,
|
||||||
const struct addrinfo *hints,
|
const struct addrinfo *hints,
|
||||||
struct addrinfo **res);
|
struct addrinfo **res);
|
||||||
|
|
||||||
struct hostent* proxy_gethostbyname(const char *name);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
|
# define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
|
||||||
#else
|
#else
|
||||||
# define PDEBUG(fmt, args...)
|
# define PDEBUG(fmt, args...) do {} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+248
-303
@@ -18,20 +18,20 @@
|
|||||||
#undef _GNU_SOURCE
|
#undef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <netdb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -41,145 +41,118 @@
|
|||||||
#define SOCKADDR_2(x) (satosin(x)->sin_addr)
|
#define SOCKADDR_2(x) (satosin(x)->sin_addr)
|
||||||
#define SOCKPORT(x) (satosin(x)->sin_port)
|
#define SOCKPORT(x) (satosin(x)->sin_port)
|
||||||
#define SOCKFAMILY(x) (satosin(x)->sin_family)
|
#define SOCKFAMILY(x) (satosin(x)->sin_family)
|
||||||
#define MAX_CHAIN 30*1024
|
#define MAX_CHAIN 512
|
||||||
|
|
||||||
int tcp_read_time_out;
|
int tcp_read_time_out;
|
||||||
int tcp_connect_time_out;
|
int tcp_connect_time_out;
|
||||||
chain_type proxychains_ct;
|
|
||||||
proxy_data proxychains_pd[MAX_CHAIN];
|
|
||||||
unsigned int proxychains_proxy_count = 0;
|
|
||||||
int proxychains_got_chain_data = 0;
|
int proxychains_got_chain_data = 0;
|
||||||
unsigned int proxychains_max_chain = 1;
|
|
||||||
int proxychains_quiet_mode = 0;
|
int proxychains_quiet_mode = 0;
|
||||||
int proxychains_resolver = 0;
|
int proxychains_resolver = 0;
|
||||||
static int init_l = 0;
|
|
||||||
|
unsigned int proxychains_proxy_count = 0;
|
||||||
|
unsigned int proxychains_max_chain = 1;
|
||||||
|
unsigned int remote_dns_subnet = 224;
|
||||||
|
|
||||||
localaddr_arg localnet_addr[MAX_LOCALNET];
|
localaddr_arg localnet_addr[MAX_LOCALNET];
|
||||||
|
chain_type proxychains_ct;
|
||||||
|
proxy_data proxychains_pd[MAX_CHAIN];
|
||||||
|
|
||||||
size_t num_localnet_addr = 0;
|
size_t num_localnet_addr = 0;
|
||||||
|
|
||||||
static inline void get_chain_data(proxy_data *pd, unsigned int *proxy_count,
|
|
||||||
chain_type *ct);
|
|
||||||
static void init_lib(void);
|
|
||||||
|
|
||||||
static void init_lib(void)
|
|
||||||
{
|
|
||||||
#ifdef THREAD_SAFE
|
#ifdef THREAD_SAFE
|
||||||
pthread_mutex_init(&internal_ips_lock, NULL);
|
pthread_once_t init_once = PTHREAD_ONCE_INIT;
|
||||||
#endif
|
#endif
|
||||||
/* read the config file */
|
static int init_l = 0;
|
||||||
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
|
||||||
|
|
||||||
proxychains_write_log(LOG_PREFIX "DLL init\n");
|
|
||||||
|
|
||||||
true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
|
|
||||||
|
|
||||||
if (!true_connect) {
|
static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
|
||||||
fprintf(stderr, "Cannot load symbol 'connect' %s\n", dlerror());
|
|
||||||
|
static void load_sym(void** funcptr, char* symname, void* proxyfunc) {
|
||||||
|
|
||||||
|
*funcptr = dlsym(RTLD_NEXT, symname);
|
||||||
|
|
||||||
|
if(!(*funcptr)) {
|
||||||
|
fprintf(stderr, "Cannot load symbol '%s' %s\n", symname, dlerror());
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
PDEBUG("loaded symbol '%s'" " real addr %p wrapped addr %p\n", symname, (*funcptr), proxyfunc);
|
||||||
PDEBUG( "loaded symbol 'connect'"
|
|
||||||
" real addr %p wrapped addr %p\n",
|
|
||||||
true_connect, connect);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if(connect==true_connect) {
|
if((*funcptr) == proxyfunc) {
|
||||||
#ifdef DEBUG
|
|
||||||
PDEBUG("circular reference detected, aborting!\n");
|
PDEBUG("circular reference detected, aborting!\n");
|
||||||
#endif
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
true_gethostbyname = (gethostbyname_t)
|
|
||||||
dlsym(RTLD_NEXT, "gethostbyname");
|
|
||||||
|
|
||||||
if (!true_gethostbyname) {
|
#define INIT() init_lib_wrapper(__FUNCTION__)
|
||||||
fprintf(stderr, "Cannot load symbol 'gethostbyname' %s\n",
|
|
||||||
dlerror());
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUG
|
|
||||||
PDEBUG( "loaded symbol 'gethostbyname'"
|
|
||||||
" real addr %p wrapped addr %p\n",
|
|
||||||
true_gethostbyname, gethostbyname);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
true_getaddrinfo = (getaddrinfo_t)
|
|
||||||
dlsym(RTLD_NEXT, "getaddrinfo");
|
|
||||||
|
|
||||||
if (!true_getaddrinfo) {
|
static void do_init(void) {
|
||||||
fprintf(stderr, "Cannot load symbol 'getaddrinfo' %s\n",
|
static const struct override_info {
|
||||||
dlerror());
|
void* funcptr;
|
||||||
exit(1);
|
char* symname;
|
||||||
} else {
|
void* proxyfunc;
|
||||||
#ifdef DEBUG
|
} override_symbols[] = {
|
||||||
PDEBUG( "loaded symbol 'getaddrinfo'"
|
#define SYM_ENTRY(X) { .funcptr = &true_ ## X, .symname = # X, .proxyfunc = X,}
|
||||||
" real addr %p wrapped addr %p\n",
|
SYM_ENTRY(connect),
|
||||||
true_getaddrinfo, getaddrinfo);
|
SYM_ENTRY(gethostbyname),
|
||||||
#endif
|
SYM_ENTRY(getaddrinfo),
|
||||||
}
|
SYM_ENTRY(freeaddrinfo),
|
||||||
true_freeaddrinfo = (freeaddrinfo_t)
|
SYM_ENTRY(gethostbyaddr),
|
||||||
dlsym(RTLD_NEXT, "freeaddrinfo");
|
SYM_ENTRY(getnameinfo),
|
||||||
|
#undef SYM_ENTRY
|
||||||
|
};
|
||||||
|
unsigned i;
|
||||||
|
MUTEX_INIT(&internal_ips_lock, NULL);
|
||||||
|
/* read the config file */
|
||||||
|
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
||||||
|
|
||||||
if (!true_freeaddrinfo) {
|
proxychains_write_log(LOG_PREFIX "DLL init\n");
|
||||||
fprintf(stderr, "Cannot load symbol 'freeaddrinfo' %s\n",
|
|
||||||
dlerror());
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUG
|
|
||||||
PDEBUG( "loaded symbol 'freeaddrinfo'"
|
|
||||||
" real addr %p wrapped addr %p\n",
|
|
||||||
true_freeaddrinfo, freeaddrinfo);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
true_gethostbyaddr = (gethostbyaddr_t)
|
|
||||||
dlsym(RTLD_NEXT, "gethostbyaddr");
|
|
||||||
|
|
||||||
if (!true_gethostbyaddr) {
|
for (i = 0; i < (sizeof(override_symbols) / sizeof(override_symbols[0])); i++) {
|
||||||
fprintf(stderr, "Cannot load symbol 'gethostbyaddr' %s\n",
|
load_sym(override_symbols[i].funcptr, override_symbols[i].symname, override_symbols[i].proxyfunc);
|
||||||
dlerror());
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUG
|
|
||||||
PDEBUG( "loaded symbol 'gethostbyaddr'"
|
|
||||||
" real addr %p wrapped addr %p\n",
|
|
||||||
true_gethostbyaddr, gethostbyaddr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
true_getnameinfo = (getnameinfo_t)
|
|
||||||
dlsym(RTLD_NEXT, "getnameinfo");
|
|
||||||
|
|
||||||
if (!true_getnameinfo) {
|
|
||||||
fprintf(stderr, "Cannot load symbol 'getnameinfo' %s\n",
|
|
||||||
dlerror());
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUG
|
|
||||||
PDEBUG( "loaded symbol 'getnameinfo'"
|
|
||||||
" real addr %p wrapped addr %p\n",
|
|
||||||
true_getnameinfo, getnameinfo);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
init_l = 1;
|
init_l = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void get_chain_data(
|
static void init_lib_wrapper(const char* caller) {
|
||||||
proxy_data *pd,
|
#ifndef DEBUG
|
||||||
unsigned int *proxy_count,
|
(void) caller;
|
||||||
chain_type *ct)
|
#endif
|
||||||
{
|
#ifndef THREAD_SAFE
|
||||||
int count=0,port_n=0,list=0;
|
if(init_l) return;
|
||||||
char buff[1024],type[1024],host[1024],user[1024];
|
PDEBUG("%s called from %s\n", __FUNCTION__, caller);
|
||||||
|
do_init();
|
||||||
|
#else
|
||||||
|
if(!init_l) PDEBUG("%s called from %s\n", __FUNCTION__, caller);
|
||||||
|
pthread_once(&init_once, do_init);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if we use gcc >= 3, we can instruct the dynamic loader
|
||||||
|
* to call init_lib at link time. otherwise it gets loaded
|
||||||
|
* lazily, which has the disadvantage that there's a potential
|
||||||
|
* race condition if 2 threads call it before init_l is set
|
||||||
|
* and PTHREAD support was disabled */
|
||||||
|
#if __GNUC__ > 2
|
||||||
|
__attribute__((constructor))
|
||||||
|
static void gcc_init(void) {
|
||||||
|
INIT();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* get configuration from config file */
|
||||||
|
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
|
||||||
|
int count = 0, port_n = 0, list = 0;
|
||||||
|
char buff[1024], type[1024], host[1024], user[1024];
|
||||||
char *env;
|
char *env;
|
||||||
char local_in_addr_port[32];
|
char local_in_addr_port[32];
|
||||||
char local_in_addr[32], local_in_port[32], local_netmask[32];
|
char local_in_addr[32], local_in_port[32], local_netmask[32];
|
||||||
FILE* file;
|
FILE *file;
|
||||||
|
|
||||||
if(proxychains_got_chain_data)
|
if(proxychains_got_chain_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Some defaults
|
//Some defaults
|
||||||
tcp_read_time_out = 4*1000;
|
tcp_read_time_out = 4 * 1000;
|
||||||
tcp_connect_time_out = 10*1000;
|
tcp_connect_time_out = 10 * 1000;
|
||||||
*ct = DYNAMIC_TYPE;
|
*ct = DYNAMIC_TYPE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -188,113 +161,119 @@ static inline void get_chain_data(
|
|||||||
*/
|
*/
|
||||||
env = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
env = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||||
|
|
||||||
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
snprintf(buff, 256, "%s/.proxychains/proxychains.conf", getenv("HOME"));
|
||||||
|
|
||||||
|
if(!env || (!(file = fopen(env, "r"))))
|
||||||
|
if(!(file = fopen("./proxychains.conf", "r")))
|
||||||
|
if(!(file = fopen(buff, "r")))
|
||||||
|
if(!(file = fopen("/etc/proxychains.conf", "r"))) {
|
||||||
|
perror("Can't locate proxychains.conf");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if(!env || (!(file=fopen(env,"r"))))
|
|
||||||
if(!(file=fopen("./proxychains.conf","r")))
|
|
||||||
if(!(file=fopen(buff,"r")))
|
|
||||||
if(!(file=fopen("/etc/proxychains.conf","r")))
|
|
||||||
{
|
|
||||||
perror("Can't locate proxychains.conf");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
|
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
|
||||||
if(env && *env == '1') proxychains_quiet_mode = 1;
|
if(env && *env == '1')
|
||||||
|
proxychains_quiet_mode = 1;
|
||||||
|
|
||||||
while(fgets(buff,sizeof(buff),file)) {
|
while(fgets(buff, sizeof(buff), file)) {
|
||||||
if(buff[0] != '\n' && buff[strspn(buff," ")]!='#') {
|
if(buff[0] != '\n' && buff[strspn(buff, " ")] != '#') {
|
||||||
|
/* proxylist has to come last */
|
||||||
if(list) {
|
if(list) {
|
||||||
|
if(count >= MAX_CHAIN)
|
||||||
|
break;
|
||||||
|
|
||||||
memset(&pd[count], 0, sizeof(proxy_data));
|
memset(&pd[count], 0, sizeof(proxy_data));
|
||||||
|
|
||||||
pd[count].ps = PLAY_STATE;
|
pd[count].ps = PLAY_STATE;
|
||||||
port_n = 0;
|
port_n = 0;
|
||||||
|
|
||||||
sscanf(buff,"%s %s %d %s %s", type, host, &port_n,
|
sscanf(buff, "%s %s %d %s %s", type, host, &port_n, pd[count].user, pd[count].pass);
|
||||||
pd[count].user, pd[count].pass);
|
|
||||||
|
|
||||||
pd[count].ip.as_int = (uint32_t) inet_addr(host);
|
pd[count].ip.as_int = (uint32_t) inet_addr(host);
|
||||||
pd[count].port = htons((unsigned short)port_n);
|
pd[count].port = htons((unsigned short) port_n);
|
||||||
|
|
||||||
if(!strcmp(type,"http")) {
|
if(!strcmp(type, "http")) {
|
||||||
pd[count].pt = HTTP_TYPE;
|
pd[count].pt = HTTP_TYPE;
|
||||||
} else if(!strcmp(type,"socks4")) {
|
} else if(!strcmp(type, "socks4")) {
|
||||||
pd[count].pt = SOCKS4_TYPE;
|
pd[count].pt = SOCKS4_TYPE;
|
||||||
} else if(!strcmp(type,"socks5")) {
|
} else if(!strcmp(type, "socks5")) {
|
||||||
pd[count].pt = SOCKS5_TYPE;
|
pd[count].pt = SOCKS5_TYPE;
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(pd[count].ip.as_int && port_n &&
|
if(pd[count].ip.as_int && port_n && pd[count].ip.as_int != (uint32_t) - 1)
|
||||||
pd[count].ip.as_int != (uint32_t) -1)
|
count++;
|
||||||
if(++count==MAX_CHAIN)
|
} else {
|
||||||
break;
|
if(strstr(buff, "[ProxyList]")) {
|
||||||
} else {
|
list = 1;
|
||||||
if(strstr(buff,"[ProxyList]")) {
|
} else if(strstr(buff, "random_chain")) {
|
||||||
list=1;
|
*ct = RANDOM_TYPE;
|
||||||
} else if(strstr(buff,"random_chain")) {
|
} else if(strstr(buff, "strict_chain")) {
|
||||||
*ct=RANDOM_TYPE;
|
*ct = STRICT_TYPE;
|
||||||
} else if(strstr(buff,"strict_chain")) {
|
} else if(strstr(buff, "dynamic_chain")) {
|
||||||
*ct=STRICT_TYPE;
|
*ct = DYNAMIC_TYPE;
|
||||||
} else if(strstr(buff,"dynamic_chain")) {
|
} else if(strstr(buff, "tcp_read_time_out")) {
|
||||||
*ct=DYNAMIC_TYPE;
|
sscanf(buff, "%s %d", user, &tcp_read_time_out);
|
||||||
} else if(strstr(buff,"tcp_read_time_out")){
|
} else if(strstr(buff, "tcp_connect_time_out")) {
|
||||||
sscanf(buff,"%s %d",user,&tcp_read_time_out) ;
|
sscanf(buff, "%s %d", user, &tcp_connect_time_out);
|
||||||
} else if(strstr(buff,"tcp_connect_time_out")){
|
} else if(strstr(buff, "remote_dns_subnet")) {
|
||||||
sscanf(buff,"%s %d",user,&tcp_connect_time_out) ;
|
sscanf(buff, "%s %d", user, &remote_dns_subnet);
|
||||||
} else if(strstr(buff,"localnet")) {
|
if(remote_dns_subnet >= 256) {
|
||||||
if (sscanf(buff,"%s %21[^/]/%15s", user,
|
fprintf(stderr,
|
||||||
local_in_addr_port, local_netmask) < 3) {
|
"remote_dns_subnet: invalid value. requires a number between 0 and 255.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else if(strstr(buff, "localnet")) {
|
||||||
|
if(sscanf(buff, "%s %21[^/]/%15s", user, local_in_addr_port, local_netmask) < 3) {
|
||||||
fprintf(stderr, "localnet format error");
|
fprintf(stderr, "localnet format error");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
/* clean previously used buffer */
|
/* clean previously used buffer */
|
||||||
memset(local_in_port, 0,
|
memset(local_in_port, 0, sizeof(local_in_port) / sizeof(local_in_port[0]));
|
||||||
sizeof(local_in_port) / sizeof(local_in_port[0]));
|
|
||||||
|
|
||||||
if (sscanf(local_in_addr_port, "%15[^:]:%5s",
|
if(sscanf(local_in_addr_port, "%15[^:]:%5s", local_in_addr, local_in_port) < 2) {
|
||||||
local_in_addr, local_in_port) < 2) {
|
PDEBUG("added localnet: netaddr=%s, netmask=%s\n",
|
||||||
PDEBUG("added localnet: netaddr=%s, port=%s\n",
|
local_in_addr, local_netmask);
|
||||||
local_in_addr, local_netmask);
|
|
||||||
} else {
|
} else {
|
||||||
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
|
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
|
||||||
local_in_addr, local_in_port, local_netmask);
|
local_in_addr, local_in_port, local_netmask);
|
||||||
}
|
}
|
||||||
if (num_localnet_addr < MAX_LOCALNET)
|
if(num_localnet_addr < MAX_LOCALNET) {
|
||||||
{
|
|
||||||
int error;
|
int error;
|
||||||
error = inet_pton(AF_INET, local_in_addr, &localnet_addr[num_localnet_addr].in_addr);
|
error =
|
||||||
if (error <= 0)
|
inet_pton(AF_INET, local_in_addr,
|
||||||
{
|
&localnet_addr[num_localnet_addr].in_addr);
|
||||||
|
if(error <= 0) {
|
||||||
fprintf(stderr, "localnet address error\n");
|
fprintf(stderr, "localnet address error\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
error = inet_pton(AF_INET, local_netmask, &localnet_addr[num_localnet_addr].netmask);
|
error =
|
||||||
if (error <= 0)
|
inet_pton(AF_INET, local_netmask,
|
||||||
{
|
&localnet_addr[num_localnet_addr].netmask);
|
||||||
|
if(error <= 0) {
|
||||||
fprintf(stderr, "localnet netmask error\n");
|
fprintf(stderr, "localnet netmask error\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (local_in_port[0]) {
|
if(local_in_port[0]) {
|
||||||
localnet_addr[num_localnet_addr].port = (short)atoi(local_in_port);
|
localnet_addr[num_localnet_addr].port =
|
||||||
|
(short) atoi(local_in_port);
|
||||||
} else {
|
} else {
|
||||||
localnet_addr[num_localnet_addr].port = 0;
|
localnet_addr[num_localnet_addr].port = 0;
|
||||||
}
|
}
|
||||||
++num_localnet_addr;
|
++num_localnet_addr;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "# of localnet exceed %d.\n", MAX_LOCALNET);
|
fprintf(stderr, "# of localnet exceed %d.\n", MAX_LOCALNET);
|
||||||
}
|
}
|
||||||
} else if(strstr(buff,"chain_len")){
|
} else if(strstr(buff, "chain_len")) {
|
||||||
char *pc;int len;
|
char *pc;
|
||||||
pc=strchr(buff,'=');
|
int len;
|
||||||
len=atoi(++pc);
|
pc = strchr(buff, '=');
|
||||||
proxychains_max_chain=(len?len:1);
|
len = atoi(++pc);
|
||||||
} else if(strstr(buff,"quiet_mode")){
|
proxychains_max_chain = (len ? len : 1);
|
||||||
proxychains_quiet_mode=1;
|
} else if(strstr(buff, "quiet_mode")) {
|
||||||
} else if(strstr(buff,"proxy_dns")){
|
proxychains_quiet_mode = 1;
|
||||||
proxychains_resolver=1;
|
} else if(strstr(buff, "proxy_dns")) {
|
||||||
|
proxychains_resolver = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,11 +283,10 @@ static inline void get_chain_data(
|
|||||||
proxychains_got_chain_data = 1;
|
proxychains_got_chain_data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******* HOOK FUNCTIONS *******/
|
||||||
|
|
||||||
|
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
||||||
int connect (int sock, const struct sockaddr *addr, unsigned int len)
|
int socktype = 0, flags = 0, ret = 0;
|
||||||
{
|
|
||||||
int socktype=0, flags=0, ret=0;
|
|
||||||
socklen_t optlen = 0;
|
socklen_t optlen = 0;
|
||||||
ip_type dest_ip;
|
ip_type dest_ip;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -317,177 +295,145 @@ int connect (int sock, const struct sockaddr *addr, unsigned int len)
|
|||||||
struct in_addr *p_addr_in;
|
struct in_addr *p_addr_in;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int remote_dns_connect = 0;
|
||||||
|
|
||||||
if(!init_l)
|
INIT();
|
||||||
init_lib();
|
optlen = sizeof(socktype);
|
||||||
optlen=sizeof(socktype);
|
getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &optlen);
|
||||||
getsockopt(sock,SOL_SOCKET,SO_TYPE,&socktype,&optlen);
|
if(!(SOCKFAMILY(*addr) == AF_INET && socktype == SOCK_STREAM))
|
||||||
if (! (SOCKFAMILY(*addr)==AF_INET && socktype==SOCK_STREAM))
|
return true_connect(sock, addr, len);
|
||||||
return true_connect(sock,addr,len);
|
|
||||||
|
|
||||||
p_addr_in = &((struct sockaddr_in *)addr)->sin_addr;
|
p_addr_in = &((struct sockaddr_in *) addr)->sin_addr;
|
||||||
port = ntohs(((struct sockaddr_in *)addr)->sin_port);
|
port = ntohs(((struct sockaddr_in *) addr)->sin_port);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// PDEBUG("localnet: %s; ", inet_ntop(AF_INET,&in_addr_localnet, str, sizeof(str)));
|
// PDEBUG("localnet: %s; ", inet_ntop(AF_INET,&in_addr_localnet, str, sizeof(str)));
|
||||||
// PDEBUG("netmask: %s; " , inet_ntop(AF_INET, &in_addr_netmask, str, sizeof(str)));
|
// PDEBUG("netmask: %s; " , inet_ntop(AF_INET, &in_addr_netmask, str, sizeof(str)));
|
||||||
PDEBUG("target: %s\n", inet_ntop(AF_INET, p_addr_in, str, sizeof(str)));
|
PDEBUG("target: %s\n", inet_ntop(AF_INET, p_addr_in, str, sizeof(str)));
|
||||||
PDEBUG("port: %d\n", port);
|
PDEBUG("port: %d\n", port);
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < num_localnet_addr; i++) {
|
|
||||||
if ((localnet_addr[i].in_addr.s_addr & localnet_addr[i].netmask.s_addr)
|
// check if connect called from proxydns
|
||||||
== (p_addr_in->s_addr & localnet_addr[i].netmask.s_addr))
|
remote_dns_connect = (ntohl(p_addr_in->s_addr) >> 24 == remote_dns_subnet);
|
||||||
{
|
|
||||||
if (localnet_addr[i].port || localnet_addr[i].port == port) {
|
for(i = 0; i < num_localnet_addr && !remote_dns_connect; i++) {
|
||||||
|
if((localnet_addr[i].in_addr.s_addr & localnet_addr[i].netmask.s_addr)
|
||||||
|
== (p_addr_in->s_addr & localnet_addr[i].netmask.s_addr)) {
|
||||||
|
if(!localnet_addr[i].port || localnet_addr[i].port == port) {
|
||||||
PDEBUG("accessing localnet using true_connect\n");
|
PDEBUG("accessing localnet using true_connect\n");
|
||||||
return true_connect(sock,addr,len);
|
return true_connect(sock, addr, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = fcntl(sock, F_GETFL, 0);
|
flags = fcntl(sock, F_GETFL, 0);
|
||||||
if(flags & O_NONBLOCK)
|
if(flags & O_NONBLOCK)
|
||||||
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
||||||
|
|
||||||
dest_ip.as_int = SOCKADDR(*addr);
|
dest_ip.as_int = SOCKADDR(*addr);
|
||||||
|
|
||||||
ret = connect_proxy_chain(
|
ret = connect_proxy_chain(sock,
|
||||||
sock,
|
dest_ip,
|
||||||
dest_ip,
|
SOCKPORT(*addr),
|
||||||
SOCKPORT(*addr),
|
proxychains_pd, proxychains_proxy_count, proxychains_ct, proxychains_max_chain);
|
||||||
proxychains_pd,
|
|
||||||
proxychains_proxy_count,
|
|
||||||
proxychains_ct,
|
|
||||||
proxychains_max_chain );
|
|
||||||
|
|
||||||
fcntl(sock, F_SETFL, flags);
|
fcntl(sock, F_SETFL, flags);
|
||||||
if(ret != SUCCESS)
|
if(ret != SUCCESS)
|
||||||
errno = ECONNREFUSED;
|
errno = ECONNREFUSED;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name)
|
struct hostent *gethostbyname(const char *name) {
|
||||||
{
|
INIT();
|
||||||
if(!init_l)
|
|
||||||
init_lib();
|
PDEBUG("gethostbyname: %s\n", name);
|
||||||
|
|
||||||
PDEBUG("gethostbyname: %s\n",name);
|
|
||||||
|
|
||||||
if(proxychains_resolver)
|
if(proxychains_resolver)
|
||||||
return proxy_gethostbyname(name);
|
return proxy_gethostbyname(name);
|
||||||
else
|
else
|
||||||
return true_gethostbyname(name);
|
return true_gethostbyname(name);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getaddrinfo(const char *node, const char *service,
|
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||||
const struct addrinfo *hints,
|
|
||||||
struct addrinfo **res)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(!init_l)
|
INIT();
|
||||||
init_lib();
|
|
||||||
|
PDEBUG("getaddrinfo: %s %s\n", node, service);
|
||||||
PDEBUG("getaddrinfo: %s %s\n",node ,service);
|
|
||||||
|
|
||||||
if(proxychains_resolver)
|
if(proxychains_resolver)
|
||||||
ret = proxy_getaddrinfo(node, service, hints, res);
|
ret = proxy_getaddrinfo(node, service, hints, res);
|
||||||
else
|
else
|
||||||
ret = true_getaddrinfo(node, service, hints, res);
|
ret = true_getaddrinfo(node, service, hints, res);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeaddrinfo(struct addrinfo *res)
|
void freeaddrinfo(struct addrinfo *res) {
|
||||||
{
|
INIT();
|
||||||
if(!init_l)
|
|
||||||
init_lib();
|
PDEBUG("freeaddrinfo %p \n", res);
|
||||||
|
|
||||||
PDEBUG("freeaddrinfo %p \n",res);
|
|
||||||
|
|
||||||
if(!proxychains_resolver)
|
if(!proxychains_resolver)
|
||||||
true_freeaddrinfo(res);
|
true_freeaddrinfo(res);
|
||||||
else {
|
else {
|
||||||
free(res->ai_addr);
|
if (res != NULL) {
|
||||||
free(res);
|
free(res->ai_addr);
|
||||||
|
free(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// work around a buggy prototype in GLIBC. according to the bugtracker it has been fixed in git at 02 May 2011.
|
// work around a buggy prototype in GLIBC. according to the bugtracker it has been fixed in git at 02 May 2011.
|
||||||
// 2.14 came out in June 2011 so that should be the first fixed version
|
// 2.14 came out in June 2011 so that should be the first fixed version
|
||||||
#if defined(__GLIBC__) && (__GLIBC__ < 3) && (__GLIBC_MINOR__ < 14)
|
#if defined(__GLIBC__) && (__GLIBC__ < 3) && (__GLIBC_MINOR__ < 14)
|
||||||
int getnameinfo (const struct sockaddr * sa,
|
int getnameinfo(const struct sockaddr *sa,
|
||||||
socklen_t salen, char * host,
|
socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags)
|
||||||
socklen_t hostlen, char * serv,
|
|
||||||
socklen_t servlen, unsigned int flags)
|
|
||||||
#else
|
#else
|
||||||
int getnameinfo (const struct sockaddr * sa,
|
int getnameinfo(const struct sockaddr *sa,
|
||||||
socklen_t salen, char * host,
|
socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
|
||||||
socklen_t hostlen, char * serv,
|
|
||||||
socklen_t servlen, int flags)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
char ip_buf[16];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(!init_l)
|
INIT();
|
||||||
init_lib();
|
|
||||||
|
|
||||||
PDEBUG("getnameinfo: %s %s\n", host, serv);
|
PDEBUG("getnameinfo: %s %s\n", host, serv);
|
||||||
|
|
||||||
if(!proxychains_resolver) {
|
if(!proxychains_resolver) {
|
||||||
ret = true_getnameinfo(sa,salen,host,hostlen,
|
ret = true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
||||||
serv,servlen,flags);
|
|
||||||
} else {
|
} else {
|
||||||
if(hostlen)
|
if(hostlen) {
|
||||||
strncpy(host, inet_ntoa(SOCKADDR_2(*sa)),hostlen);
|
inet_ntop(AF_INET, (unsigned char*) &(SOCKADDR_2(*sa)), ip_buf, sizeof(ip_buf));
|
||||||
if(servlen)
|
strncpy(host, ip_buf, hostlen);
|
||||||
snprintf(serv, servlen,"%d",ntohs(SOCKPORT(*sa)));
|
}
|
||||||
|
if(servlen)
|
||||||
|
snprintf(serv, servlen, "%d", ntohs(SOCKPORT(*sa)));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stolen from libulz (C) rofl0r
|
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
||||||
static void pc_stringfromipv4(unsigned char* ip_buf_4_bytes, char* outbuf_16_bytes) {
|
|
||||||
unsigned char* p;
|
|
||||||
char *o = outbuf_16_bytes;
|
|
||||||
unsigned char n;
|
|
||||||
for(p = ip_buf_4_bytes; p < ip_buf_4_bytes + 4; p++) {
|
|
||||||
n = *p;
|
|
||||||
if(*p >= 100) {
|
|
||||||
if(*p >= 200) *(o++) = '2';
|
|
||||||
else *(o++) = '1';
|
|
||||||
n %= 100;
|
|
||||||
}
|
|
||||||
if(*p >= 10) {
|
|
||||||
*(o++) = (n / 10) + '0';
|
|
||||||
n %= 10;
|
|
||||||
}
|
|
||||||
*(o++) = n + '0';
|
|
||||||
*(o++) = '.';
|
|
||||||
}
|
|
||||||
o[-1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
|
|
||||||
{
|
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
static char ipv4[4];
|
static char ipv4[4];
|
||||||
static char* list[2];
|
static char *list[2];
|
||||||
static struct hostent he;
|
static struct hostent he;
|
||||||
|
|
||||||
if(!init_l)
|
INIT();
|
||||||
init_lib();
|
|
||||||
|
|
||||||
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
||||||
|
|
||||||
if(!proxychains_resolver)
|
if(!proxychains_resolver)
|
||||||
return true_gethostbyaddr(addr,len,type);
|
return true_gethostbyaddr(addr, len, type);
|
||||||
else {
|
else {
|
||||||
|
|
||||||
PDEBUG("len %u\n", len);
|
PDEBUG("len %u\n", len);
|
||||||
if(len != 4) return NULL;
|
if(len != 4)
|
||||||
|
return NULL;
|
||||||
he.h_name = buf;
|
he.h_name = buf;
|
||||||
memcpy(ipv4, addr, 4);
|
memcpy(ipv4, addr, 4);
|
||||||
list[0] = ipv4;
|
list[0] = ipv4;
|
||||||
@@ -496,9 +442,8 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
|
|||||||
he.h_addrtype = AF_INET;
|
he.h_addrtype = AF_INET;
|
||||||
he.h_aliases = NULL;
|
he.h_aliases = NULL;
|
||||||
he.h_length = 4;
|
he.h_length = 4;
|
||||||
pc_stringfromipv4((unsigned char*)addr, buf);
|
inet_ntop(AF_INET, addr, buf, sizeof(buf));
|
||||||
return &he;
|
return &he;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+82
-59
@@ -18,37 +18,38 @@
|
|||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#undef _XOPEN_SOURCE
|
#undef _XOPEN_SOURCE
|
||||||
#define _XOPEN_SOURCE 700
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
extern char *optarg;
|
#include <sys/wait.h>
|
||||||
extern int optind, opterr, optopt;
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static int usage(char** argv) {
|
static int usage(char **argv) {
|
||||||
printf( "\nUsage:\t%s -q -f config_file program_name [arguments]\n"
|
printf("\nUsage:\t%s -q -f config_file program_name [arguments]\n"
|
||||||
"\t-q makes proxychains quiet - this overrides the config setting\n"
|
"\t-q makes proxychains quiet - this overrides the config setting\n"
|
||||||
"\t-t allows to manually specify a configfile to use\n"
|
"\t-t allows to manually specify a configfile to use\n"
|
||||||
"\tfor example : proxychains telnet somehost.com\n"
|
"\tfor example : proxychains telnet somehost.com\n" "More help in README file\n\n", argv[0]);
|
||||||
"More help in README file\n\n", argv[0]);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_path(char* path) {
|
int check_path(char *path) {
|
||||||
if(!path) return 0;
|
if(!path)
|
||||||
|
return 0;
|
||||||
return access(path, R_OK) != -1;
|
return access(path, R_OK) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* dll_name = "libproxychains4.so";
|
static const char *dll_name = DLL_NAME;
|
||||||
|
|
||||||
static char own_dir[256];
|
static char own_dir[256];
|
||||||
static const char* dll_dirs[] = {
|
static const char *dll_dirs[] = {
|
||||||
".",
|
".",
|
||||||
own_dir,
|
own_dir,
|
||||||
LIB_DIR,
|
LIB_DIR,
|
||||||
@@ -59,9 +60,10 @@ static const char* dll_dirs[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_own_dir(const char* argv0) {
|
static void set_own_dir(const char *argv0) {
|
||||||
size_t l = strlen(argv0);
|
size_t l = strlen(argv0);
|
||||||
while(l && argv0[l - 1] != '/') l--;
|
while(l && argv0[l - 1] != '/')
|
||||||
|
l--;
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
memcpy(own_dir, ".", 2);
|
memcpy(own_dir, ".", 2);
|
||||||
else {
|
else {
|
||||||
@@ -70,76 +72,90 @@ static void set_own_dir(const char* argv0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_COMMANDLINE_FLAGS 2
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char buf[256];
|
char buf[PATH_MAX];
|
||||||
char pbuf[256];
|
char pbuf[PATH_MAX];
|
||||||
int opt;
|
|
||||||
int start_argv = 1;
|
int start_argv = 1;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
|
size_t i;
|
||||||
if(argc == 1) return usage(argv);
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "qf:")) != -1) {
|
const char *prefix = NULL;
|
||||||
switch (opt) {
|
|
||||||
case 'q':
|
for(i = 0; i < MAX_COMMANDLINE_FLAGS; i++) {
|
||||||
|
if(start_argv < argc && argv[start_argv][0] == '-') {
|
||||||
|
if(argv[start_argv][1] == 'q') {
|
||||||
quiet = 1;
|
quiet = 1;
|
||||||
start_argv++;
|
start_argv++;
|
||||||
break;
|
} else if(argv[start_argv][1] == 'f') {
|
||||||
case 'f':
|
|
||||||
path = (char *)optarg;
|
if(start_argv + 1 < argc)
|
||||||
if(!path) {
|
path = argv[start_argv + 1];
|
||||||
fprintf(stderr, "error: no path supplied.\n");
|
else
|
||||||
return EXIT_FAILURE;
|
return usage(argv);
|
||||||
}
|
|
||||||
start_argv += 2;
|
start_argv += 2;
|
||||||
break;
|
|
||||||
default: /* '?' */
|
|
||||||
return usage(argv);
|
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(start_argv >= argc) return usage(argv);
|
if(start_argv >= argc)
|
||||||
|
return usage(argv);
|
||||||
|
|
||||||
/* check if path of config file has not been passed via command line */
|
/* check if path of config file has not been passed via command line */
|
||||||
if(!path) {
|
if(!path) {
|
||||||
// priority 1: env var PROXYCHAINS_CONF_FILE
|
// priority 1: env var PROXYCHAINS_CONF_FILE
|
||||||
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||||
if(check_path(path)) goto have;
|
|
||||||
|
if(check_path(path))
|
||||||
|
goto have;
|
||||||
|
|
||||||
// priority 2; proxychains conf in actual dir
|
// priority 2; proxychains conf in actual dir
|
||||||
path = getcwd(buf, sizeof(buf));
|
path = getcwd(buf, sizeof(buf));
|
||||||
snprintf(pbuf, sizeof(pbuf), "%s/%s", path, PROXYCHAINS_CONF_FILE);
|
snprintf(pbuf, sizeof(pbuf), "%s/%s", path, PROXYCHAINS_CONF_FILE);
|
||||||
path = pbuf;
|
path = pbuf;
|
||||||
if(check_path(path)) goto have;
|
|
||||||
|
if(check_path(path))
|
||||||
|
goto have;
|
||||||
|
|
||||||
// priority 3; $HOME/.proxychains/proxychains.conf
|
// priority 3; $HOME/.proxychains/proxychains.conf
|
||||||
path = getenv("HOME");
|
path = getenv("HOME");
|
||||||
snprintf(pbuf, sizeof(pbuf), "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
|
snprintf(pbuf, sizeof(pbuf), "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
|
||||||
path = pbuf;
|
path = pbuf;
|
||||||
if(check_path(path)) goto have;
|
if(check_path(path))
|
||||||
|
goto have;
|
||||||
// priority 4: /etc/proxychains.conf
|
|
||||||
path = "/etc/proxychains.conf";
|
/* Check for default config file in two locations {install_prefix}/etc /etc */
|
||||||
if(check_path(path)) goto have;
|
// priority 4: $INSTALL_PREFIX/etc/proxychains.conf
|
||||||
perror("couldnt find configuration file");
|
snprintf(pbuf, sizeof(pbuf), "%s/etc/%s", INSTALL_PREFIX, PROXYCHAINS_CONF_FILE);
|
||||||
|
path = pbuf;
|
||||||
|
if(check_path(path))
|
||||||
|
goto have;
|
||||||
|
|
||||||
|
// priority 5: /etc/proxychains.conf
|
||||||
|
snprintf(pbuf, sizeof(pbuf), "/etc/%s", PROXYCHAINS_CONF_FILE);
|
||||||
|
path = pbuf;
|
||||||
|
if(check_path(path))
|
||||||
|
goto have;
|
||||||
|
perror("Couldn't find configuration file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
have:
|
have:
|
||||||
|
|
||||||
if(!quiet) fprintf(stderr, LOG_PREFIX "config file found: %s\n", path);
|
if(!quiet)
|
||||||
|
fprintf(stderr, LOG_PREFIX "config file found: %s\n", path);
|
||||||
|
|
||||||
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to use new config file. */
|
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to use new config file. */
|
||||||
setenv(PROXYCHAINS_CONF_FILE_ENV_VAR, path, 1);
|
setenv(PROXYCHAINS_CONF_FILE_ENV_VAR, path, 1);
|
||||||
|
|
||||||
if(quiet) setenv(PROXYCHAINS_QUIET_MODE_ENV_VAR, "1", 1);
|
|
||||||
|
|
||||||
|
if(quiet)
|
||||||
|
setenv(PROXYCHAINS_QUIET_MODE_ENV_VAR, "1", 1);
|
||||||
|
|
||||||
// search DLL
|
// search DLL
|
||||||
size_t i = 0;
|
|
||||||
const char* prefix = NULL;
|
|
||||||
|
|
||||||
set_own_dir(argv[0]);
|
set_own_dir(argv[0]);
|
||||||
|
|
||||||
while(dll_dirs[i]) {
|
while(dll_dirs[i]) {
|
||||||
@@ -155,11 +171,18 @@ int main(int argc, char *argv[]) {
|
|||||||
fprintf(stderr, "couldnt locate %s\n", dll_name);
|
fprintf(stderr, "couldnt locate %s\n", dll_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(!quiet) fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/%s", prefix, dll_name);
|
|
||||||
|
|
||||||
putenv(buf);
|
if(!quiet)
|
||||||
|
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
||||||
|
|
||||||
|
#ifndef IS_MAC
|
||||||
|
snprintf(buf, sizeof(buf), "%s/%s", prefix, dll_name);
|
||||||
|
setenv("LD_PRELOAD", buf, 1);
|
||||||
|
#else
|
||||||
|
snprintf(buf, sizeof(buf), "%s/%s", prefix, dll_name);
|
||||||
|
setenv("DYLD_INSERT_LIBRARIES", buf, 1);
|
||||||
|
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
|
||||||
|
#endif
|
||||||
execvp(argv[start_argv], &argv[start_argv]);
|
execvp(argv[start_argv], &argv[start_argv]);
|
||||||
perror("proxychains can't load process....");
|
perror("proxychains can't load process....");
|
||||||
|
|
||||||
|
|||||||
+93
-13
@@ -1,26 +1,106 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
|
echo "ProxyChains-4.0 (https://github.com/haad/proxychains)"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
|
||||||
echo " usage:"
|
echo " usage:"
|
||||||
echo " $0 [h] [f config-file] <prog> [args]"
|
echo " $0 [hq] [-f config-file] <prog> [args]"
|
||||||
|
echo " -q make proxychains quiet"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_proxy_conf() {
|
||||||
|
|
||||||
|
show_proxy_env
|
||||||
|
if [ -f "/usr/local/etc/proxychains.conf" ]; then
|
||||||
|
export PROXYCHAINS_CONF_FILE="/usr/local/etc/proxychains.conf"
|
||||||
|
else
|
||||||
|
if [ -f "/etc/proxychains.conf" ];then
|
||||||
|
PROXYCHAINS_CONF_FILE="/etc/proxychains.conf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX We should not overide possible user settings here. Just add libproxychains to it.
|
||||||
|
#
|
||||||
|
setup_proxy_env() {
|
||||||
|
|
||||||
|
if [ -z "$PROXYCHAINS_CONF_FILE" ]; then
|
||||||
|
find_proxy_conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(uname -s) = "Darwin" ]; then
|
||||||
|
export DYLD_FORCE_FLAT_NAMESPACE=
|
||||||
|
export DYLD_INSERT_LIBRARIES=libproxychains4.dylib
|
||||||
|
else
|
||||||
|
export LD_PRELOAD=libproxychains.so.4
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
disable_proxy_env() {
|
||||||
|
|
||||||
|
if [ $(uname -s) = "Darwin" ]; then
|
||||||
|
unset DYLD_FORCE_FLAT_NAMESPACE
|
||||||
|
export DYLD_INSERT_LIBRARIES=$(echo $DYLD_INSERT_LIBRARIES | sed -e 's/libproxychains4.dylib//g')
|
||||||
|
if [ -z $DYLD_INSERT_LIBRARIES ]; then
|
||||||
|
unset DYLD_INSERT_LIBRARIES
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
export LD_PRELOAD=$(echo $DYLD_INSERT_LIBRARIES | sed -e 's/libproxychains.so.4//g')
|
||||||
|
if [ -z $LD_PRELOAD ]; then
|
||||||
|
unset LD_PRELOAD
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
show_proxy_env() {
|
||||||
|
|
||||||
|
echo "Proxified environment setup"
|
||||||
|
echo "PROXYCHAINS_CONF_FILE = $PROXYCHAINS_CONF_FILE"
|
||||||
|
|
||||||
|
if [ $(uname -s) = "Darwin" ]; then
|
||||||
|
echo "DYLD_FORCE_FLAT_NAMESPACE = $DYLD_FORCE_FLAT_NAMESPACE"
|
||||||
|
echo "DYLD_INSERT_LIBRARIES = $DYLD_INSERT_LIBRARIES"
|
||||||
|
else
|
||||||
|
echo "LD_PRELOAD = $LD_PRELOAD"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ $# = 0 ] ; then
|
if [ $# = 0 ] ; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $1 = "-h" ]; then
|
case "$1" in
|
||||||
usage
|
-h)
|
||||||
fi
|
usage
|
||||||
|
;;
|
||||||
|
-f)
|
||||||
|
export PROXYCHAINS_CONF_FILE=$2;
|
||||||
|
shift;
|
||||||
|
shift;
|
||||||
|
;;
|
||||||
|
-q)
|
||||||
|
export PROXYCHAINS_QUIET_MODE=1;
|
||||||
|
shift;
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
show_proxy_env
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ "$1" = "-f" ]; then
|
case "$1" in
|
||||||
export PROXYCHAINS_CONF_FILE=$2;
|
on)
|
||||||
shift;
|
setup_proxy_env
|
||||||
shift;
|
show_proxy_env
|
||||||
fi
|
;;
|
||||||
|
off)
|
||||||
export LD_PRELOAD=libproxychains.so.3
|
disable_proxy_env
|
||||||
exec "$@"
|
show_proxy_env
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
setup_proxy_env
|
||||||
|
exec "$@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
+23
-1
@@ -1,4 +1,4 @@
|
|||||||
# proxychains.conf VER 3.1
|
# proxychains.conf VER 4
|
||||||
#
|
#
|
||||||
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
|
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
|
||||||
#
|
#
|
||||||
@@ -37,10 +37,32 @@ strict_chain
|
|||||||
# Proxy DNS requests - no leak for DNS data
|
# Proxy DNS requests - no leak for DNS data
|
||||||
proxy_dns
|
proxy_dns
|
||||||
|
|
||||||
|
# set the class A subnet number to usefor use of the internal remote DNS mapping
|
||||||
|
# we use the reserved 224.x.x.x range by default,
|
||||||
|
# if the proxified app does a DNS request, we will return an IP from that range.
|
||||||
|
# on further accesses to this ip we will send the saved DNS name to the proxy.
|
||||||
|
# in case some control-freak app checks the returned ip, and denies to
|
||||||
|
# connect, you can use another subnet, e.g. 10.x.x.x or 127.x.x.x.
|
||||||
|
# of course you should make sure that the proxified app does not need
|
||||||
|
# *real* access to this subnet.
|
||||||
|
# i.e. dont use the same subnet then in the localnet section
|
||||||
|
#remote_dns_subnet 127
|
||||||
|
#remote_dns_subnet 10
|
||||||
|
remote_dns_subnet 224
|
||||||
|
|
||||||
# Some timeouts in milliseconds
|
# Some timeouts in milliseconds
|
||||||
tcp_read_time_out 15000
|
tcp_read_time_out 15000
|
||||||
tcp_connect_time_out 8000
|
tcp_connect_time_out 8000
|
||||||
|
|
||||||
|
# By default enable localnet for loopback address ranges
|
||||||
|
# RFC5735 Loopback address range
|
||||||
|
localnet 127.0.0.0/255.0.0.0
|
||||||
|
# RFC1918 Private Address Ranges
|
||||||
|
# localnet 10.0.0.0/255.0.0.0
|
||||||
|
# localnet 172.16.0.0/255.240.0.0
|
||||||
|
# localnet 192.168.0.0/255.255.0.0
|
||||||
|
|
||||||
|
|
||||||
# Example for localnet exclusion
|
# Example for localnet exclusion
|
||||||
## Exclude connections to 192.168.1.0/24 with port 80
|
## Exclude connections to 192.168.1.0/24 with port 80
|
||||||
# localnet 192.168.1.0:80/255.255.255.0
|
# localnet 192.168.1.0:80/255.255.255.0
|
||||||
|
|||||||
Reference in New Issue
Block a user