33 Commits

Author SHA1 Message Date
Adam Hamsik 1c020ced1e Port Proxychains to NetBSD. 2012-08-09 22:36:29 +00:00
Adam Hamsik 361889a2d2 Add option to do a development build with --devel configure flag. Rename proxy_getserverbyname to proxy_getservbyname. 2012-08-05 15:07:37 +02:00
Adam Hamsik 025840930b Add more files to ignore. 2012-07-29 12:09:53 +02:00
Adam Hamsik cca0cea44a Fix couple of problems introduced/detected by clang checker and new -fno-common compiler flag. 2012-07-29 12:09:11 +02:00
Adam Hamsik 462e34f447 Add more strict warnings, make proxychains build with -Wconversion 2012-07-25 02:39:30 +02:00
Adam Hamsik e5ad6e53c3 Add more info, about last work, versions. 2012-07-25 02:34:52 +02:00
Adam Hamsik 5b7270d75b Add new thread-safe getsrvbyname for MacOS X 2012-07-24 14:37:20 +02:00
Adam Hamsik e6b5f245f7 Merge branch 'rofl0r-master'
Conflicts:
	Makefile
	proxychains.lsm
	src/core.h
	src/libproxychains.c
	src/main.c
2012-07-24 14:02:18 +02:00
Adam Hamsik 17dbc76577 Add more binary stuff 2012-07-24 11:51:41 +02:00
Adam Hamsik 7599bdfdfe Update this file to last version. 2012-06-22 21:59:21 +02:00
Adam Hamsik c1f0c68abd Extract configuration file opening to separate routine. 2012-06-22 21:58:57 +02:00
Adam Hamsik 877e1844ea Remove trailing white space. 2012-06-22 21:57:50 +02:00
Adam Hamsik 69ab0415ac Merge branch 'testing' 2012-06-22 21:35:41 +02:00
Adam Hamsik c14bf58cd7 Add support for both i386 and amd64 in mac os x binary. 2012-06-18 15:46:41 +02:00
Adam Hamsik 5294214150 Fix merge error. 2012-06-18 15:46:22 +02:00
Adam Hamsik 385b349a8e Add support for both i386 and amd64 in mac os x binary. 2012-06-18 15:45:45 +02:00
Adam Hamsik 2320f6608a Merge rofl0r changes to main stream. 2012-06-16 12:10:41 +02:00
Michel Oosterhof 251fd7cd4a Only enable loopback localnet by default, not private address range. 2012-06-16 12:04:28 +02:00
Michel Oosterhof b0d9d1da41 Enable localnet by default for loopback and private address ranges. 2012-06-16 12:04:23 +02:00
Michel Oosterhof a7831a8f53 Typo fix. 2012-06-16 12:02:51 +02:00
Adam Hamsik c9b8ce35b2 Merge pull request #16 from jahrome/master
Hi ! Nice job with localnet, just what I was needing, here is just a small fix. Hope this helps.
2012-05-22 06:07:35 -07:00
Jahrome 63c3a4b0d2 bugfix: localnet never used if no port specified. Fix typo. 2012-05-22 14:25:53 +02:00
Adam Hamsik 4d40a4790f Merge pull request #15 from jianingy/master
bugfix: localnet conflicts with proxydns
2012-03-04 23:21:43 -08:00
Jianing Yang 50820ce80d new: added DESTDIR option to Makefile so that packaging will be easier 2012-03-03 14:57:49 +08:00
Jianing Yang b6746997d2 bugfix: localnet conflicts with proxydns (fixed bytes-order) 2012-03-03 14:30:14 +08:00
Jianing Yang 6dda28a2c8 bugfix: localnet conflicts with proxydns 2012-03-03 14:24:05 +08:00
Adam Hamsik fb3d8e04a1 Change example config version to 4. 2012-03-02 12:57:05 +01:00
Adam Hamsik 0938a940c5 Create install destionation directories first with install -d. 2012-01-28 23:10:40 +01:00
Adam Hamsik 788ffd9d26 Use standard PROXYCHAINS_CONF_FILE instead of hardcoded config name. 2012-01-28 19:51:23 +01:00
Adam Hamsik 99dcfe085e Change proxychains script to add different ways of usage.
To run a command from shell use
proxychains -f {config_file} {command}

To turn proxychains on for all processes inside your shell use
. proxychains on
. proxychains off
2012-01-28 19:47:56 +01:00
Adam Hamsik 89e8bfddf4 Add etc/ to path where we search for config file. 2012-01-28 18:18:58 +01:00
Adam Hamsik adb13c7e79 Check for default config file in 2 locations /etc/ and {install_prefix}/etc. 2012-01-28 16:56:47 +01:00
Adam Hamsik 2250ef66a8 Make proxychains working on Mac OS X, build universal binaries to make older
versions of Mac OS X working. Make both proxychains shell script and proxychains program working.

Tested on my 10.7.3
2012-01-28 14:01:28 +01:00
14 changed files with 334 additions and 116 deletions
+3
View File
@@ -4,8 +4,11 @@
*.lo
.deps/
.libs/
.*
# Autoconf stuff
libtool
config.*
stamp-h
proxychains4
*.dylib
+1 -1
View File
@@ -7,7 +7,7 @@ main.c, remote-dns, thread safety, bugfixes, build system, cleanups
rofl0r.
https://github.com/rofl0r/proxychains
localnet, bugfixes
localnet, bugfixes, macos x support
adam hamsik.
https://github.com/haad/proxychains
+15
View File
@@ -1,6 +1,21 @@
ProxyChains version history (public releases)
====================
ver 4.1
* Mac OS X support, create install script.
* thread-safe fixes by @rofl0r
-------------------------------------------------------------------------
ver 4.0
changed:
* Add a lot of fixes
* localnet-patch
* remote-dns
* thread-safe
-------------------------------------------------------------------------
ver 3.1
changed:
+13 -13
View File
@@ -17,8 +17,8 @@ SRCS = $(sort $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o)
LOBJS = src/core.o src/common.o src/libproxychains.o
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
LDFLAGS = -shared -fPIC -ldl -lpthread
CCFLAGS = -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
LDFLAGS = -shared -fPIC -lpthread
INC =
PIC = -fPIC
AR = $(CROSS_COMPILE)ar
@@ -37,22 +37,23 @@ ALL_LIBS = $(SHARED_LIBS)
PXCHAINS = proxychains4
ALL_TOOLS = $(PXCHAINS)
CFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DSYSCONFDIR=\"$(confdir)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\"
CCFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
LDFLAGS+=$(USER_LDFLAGS) $(MAC_LDFLAGS)
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(MAC_CFLAGS)
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\" -DSYSCONFDIR=\"$(confdir)\"
all: $(ALL_LIBS) $(ALL_TOOLS)
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
install:
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(libdir) $(DESTDIR)/$(confdir) $(DESTDIR)/$(includedir)
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) $(DESTDIR)/$(bindir)/
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
install-config:
install -d $(DESTDIR)/$(confdir)
install $(INSTALL_FLAGS) 644 src/proxychains.conf $(DESTDIR)/$(confdir)/
install:
install -d $(DESTDIR)/$(bindir)/ $(DESTDIR)/$(libdir)/
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) $(DESTDIR)/$(bindir)/
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
clean:
rm -f $(ALL_LIBS)
rm -f $(ALL_TOOLS)
@@ -67,5 +68,4 @@ $(LDSO_PATHNAME): $(LOBJS)
$(ALL_TOOLS): $(OBJS)
$(CC) src/main.o src/common.o -o $(PXCHAINS)
.PHONY: all clean install
.PHONY: all clean install install-config
Vendored
+27 -2
View File
@@ -1,6 +1,7 @@
#!/bin/sh
prefix=/usr/local
develflg=0
usage() {
echo "supported arguments"
@@ -10,6 +11,7 @@ usage() {
echo "--libdir=/path default: $prefix/lib"
echo "--includedir=/path default: $prefix/include"
echo "--sysconfdir=/path default: $prefix/etc"
echo "--devel default:no (set development mode)"
echo "--help : show this text"
exit 1
}
@@ -29,6 +31,7 @@ parsearg() {
--libdir=*) libdir=`spliteq $1`;;
--includedir=*) includedir=`spliteq $1`;;
--sysconfdir=*) sysconfdir=`spliteq $1`;;
--devel) develflg=1;;
--help) usage;;
esac
}
@@ -37,6 +40,14 @@ ismac() {
uname -s | grep Darwin
}
isbsd() {
uname -s | grep BSD
}
islinux() {
uname -s | grep Linux
}
while true ; do
case $1 in
-*) parsearg "$1"; shift;;
@@ -68,6 +79,10 @@ if [ -z "$CC" ] ; then
CC=cc
fi
if [ $develflg -eq 1 ]; then
CFLAGS="-Wextra -Wunused -Wuninitialized -Wconversion -fno-common -g -O0"
fi
echo CC?=$CC>config.mak
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
@@ -79,10 +94,20 @@ 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>>config.mak
echo LD_SET_SONAME=-Wl,-install_name,>>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=-ldl -Wl,-install_name,>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
fi
if islinux ; then
echo LD_SET_SONAME=-ldl
fi
if isbsd ; then
echo INSTALL_FLAGS=-m>>config.mak
echo LD_SET_SONAME=-Wl,-rpath,$libdir -install_name,>>config.mak
fi
echo done, now run make \&\& make install
+14
View File
@@ -0,0 +1,14 @@
Begin3
Title: ProxyChains
Version: 4.0
Entered-date:
Description:
Keywords:
Author: <N37CR347UR3>
Maintained-by: <haad@netbsd.org>
Primary-site:
Home-page: http://proxychains.sourceforge.net
Original-site:
Platforms: Linux and other Unices
Copying-policy: GNU Public License
End
+8 -12
View File
@@ -14,41 +14,37 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
// top priority: user defined path
char *path = default_path;
if(check_path(path))
goto have;
return path;
// priority 1: env var PROXYCHAINS_CONF_FILE
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
if(check_path(path))
goto have;
return path;
// priority 2; proxychains conf in actual dir
path = getcwd(buf, sizeof(buf));
snprintf(pbuf, bufsize, "%s/%s", path, PROXYCHAINS_CONF_FILE);
path = pbuf;
if(check_path(path))
goto have;
return path;
// priority 3; $HOME/.proxychains/proxychains.conf
path = getenv("HOME");
snprintf(pbuf, bufsize, "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
path = pbuf;
if(check_path(path))
goto have;
return path;
// priority 4: $SYSCONFDIR/proxychains.conf
path = SYSCONFDIR "/" PROXYCHAINS_CONF_FILE;
if(check_path(path))
goto have;
return path;
// priority 5: /etc/proxychains.conf
path = "/etc/" PROXYCHAINS_CONF_FILE;
if(check_path(path))
goto have;
return path;
perror("couldnt find configuration file");
exit(1);
return NULL;
have:
return path;
}
+5 -1
View File
@@ -3,6 +3,10 @@
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
#define LOG_PREFIX "[proxychains] "
#define PROXYCHAINS_VERSION_MAJOR 4
#define PROXYCHAINS_VERSION_MINOR 1
#define PROXYCHAINS_VERSION_BUGFIX 0
#include <stddef.h>
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
+76 -43
View File
@@ -15,6 +15,7 @@
* *
***************************************************************************/
#include <sys/types.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <unistd.h>
@@ -34,10 +35,15 @@
#include <sys/time.h>
#include <stdarg.h>
#include <assert.h>
#ifdef THREAD_SAFE
#include <pthread.h>
pthread_mutex_t internal_ips_lock;
#endif
#ifdef __APPLE__
pthread_mutex_t internal_getsrvbyname_lock;
#endif /* __APPLE__ */
#endif /* THREAD_SAFE */
#include "core.h"
#include "common.h"
@@ -62,7 +68,7 @@ uint32_t dalias_hash(char *s0) {
uint32_t index_from_internal_ip(ip_type internalip) {
ip_type tmp = internalip;
uint32_t ret;
ret = tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16);
ret = (uint32_t) (tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16));
ret -= 1;
return ret;
}
@@ -106,7 +112,7 @@ static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout)
//printf("Retry %d\n", time_remain);
ret = poll(fds, nfsd, time_remain);
gettimeofday(&tv, NULL);
time_elapsed = ((tv.tv_sec - start_time.tv_sec) * 1000 + (tv.tv_usec - start_time.tv_usec) / 1000);
time_elapsed = ((int)(tv.tv_sec - start_time.tv_sec) * 1000 + (int)(tv.tv_usec - start_time.tv_usec) / 1000);
//printf("Time elapsed %d\n", time_elapsed);
time_remain = timeout - time_elapsed;
} while(ret == -1 && errno == EINTR && time_remain > 0);
@@ -118,7 +124,9 @@ static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout)
static void encode_base_64(char *src, char *dest, int max_len) {
int n, l, i;
int n, i;
size_t l;
l = strlen(src);
max_len = (max_len - 1) / 4;
for(i = 0; i < max_len; i++, src += 3, l -= 3) {
@@ -164,11 +172,11 @@ void proxychains_write_log(char *str, ...) {
}
}
static int write_n_bytes(int fd, char *buff, size_t size) {
int i = 0;
static size_t write_n_bytes(int fd, char *buff, size_t size) {
size_t i = 0;
size_t wrote = 0;
for(;;) {
i = write(fd, &buff[wrote], size - wrote);
i = (size_t) write(fd, &buff[wrote], size - wrote);
if(i <= 0)
return i;
wrote += i;
@@ -177,7 +185,7 @@ static int write_n_bytes(int fd, char *buff, size_t size) {
}
}
static int read_n_bytes(int fd, char *buff, size_t size) {
static size_t read_n_bytes(int fd, char *buff, size_t size) {
int ready;
size_t i;
struct pollfd pfd[1];
@@ -188,9 +196,9 @@ static int read_n_bytes(int fd, char *buff, size_t size) {
pfd[0].revents = 0;
ready = poll_retry(pfd, 1, tcp_read_time_out);
if(ready != 1 || !(pfd[0].revents & POLLIN) || 1 != read(fd, &buff[i], 1))
return -1;
return 0;
}
return (int) size;
return size;
}
static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
@@ -203,7 +211,7 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
fcntl(sock, F_SETFL, O_NONBLOCK);
ret = true_connect(sock, addr, len);
PDEBUG("\nconnect ret=%d\n", ret);
if(ret == -1 && errno == EINPROGRESS) {
ret = poll_retry(pfd, 1, tcp_connect_time_out);
PDEBUG("\npoll ret=%d\n", ret);
@@ -253,7 +261,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
if(!dns_len)
goto err;
}
PDEBUG("host dns %s\n", dns_name ? dns_name : "<NULL>");
size_t ulen = strlen(user);
@@ -264,10 +272,9 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
goto err;
}
int len;
size_t len;
unsigned char buff[BUFF_SIZE];
char ip_buf[16];
//memset (buff, 0, sizeof(buff));
switch (pt) {
@@ -299,7 +306,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
len = strlen((char *) buff);
if(len != send(sock, buff, len, 0))
if(len != (size_t) send(sock, buff, len, 0))
goto err;
len = 0;
@@ -393,15 +400,15 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
int c;
*cur++ = 1; // version
c = ulen & 0xFF;
*cur++ = c;
memcpy(cur, user, c);
*cur++ = (char)c;
memcpy(cur, user, (size_t)c);
cur += c;
c = passlen & 0xFF;
*cur++ = c;
memcpy(cur, pass, c);
*cur++ = (char)c;
memcpy(cur, pass, (size_t)c);
cur += c;
if((cur - out) != write_n_bytes(sock, out, cur - out))
if((size_t)(cur - out) != write_n_bytes(sock, out, (size_t) (cur - out)))
goto err;
@@ -414,7 +421,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
return BLOCKED;
}
}
int buff_iter = 0;
size_t buff_iter = 0;
buff[buff_iter++] = 5; // version
buff[buff_iter++] = 1; // connect
buff[buff_iter++] = 0; // reserved
@@ -515,7 +522,7 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
return NULL;
switch (how) {
case RANDOMLY:
srand(time(NULL));
srand((unsigned int)time(NULL));
do {
k++;
i = 0 + (unsigned int) (proxy_count * 1.0 * rand() / (RAND_MAX + 1.0));
@@ -553,8 +560,7 @@ static void release_busy(proxy_data * pd, unsigned int proxy_count) {
}
static unsigned int calc_alive(proxy_data * pd, unsigned int proxy_count) {
unsigned int i;
int alive_count = 0;
unsigned int i, alive_count = 0;
release_busy(pd, proxy_count);
for(i = 0; i < proxy_count; i++)
if(pd[i].ps == PLAY_STATE)
@@ -617,7 +623,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
switch (ct) {
case DYNAMIC_TYPE:
alive_count = calc_alive(pd, proxy_count);
calc_alive(pd, proxy_count);
offset = 0;
do {
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
@@ -641,7 +647,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
break;
case STRICT_TYPE:
alive_count = calc_alive(pd, proxy_count);
calc_alive(pd, proxy_count);
offset = 0;
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
PDEBUG("select_proxy failed\n");
@@ -706,7 +712,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
proxychains_write_log("\n!!!need more proxies!!!\n");
error_strict:
PDEBUG("error\n");
release_all(pd, proxy_count);
if(ns != -1)
close(ns);
@@ -820,6 +826,31 @@ void proxy_freeaddrinfo(struct addrinfo *res) {
free(res);
}
void proxy_getservbyname(const char * service, struct servent *se_buf,
char * buf, size_t buf_len, struct servent **se_result)
{
#ifdef __linux__
getservbyname_r(service, NULL, se_buf, buf, buf_len, se_result);
#endif
#ifdef __APPLE__
struct servent *se;
MUTEX_LOCK(&internal_getsrvbyname_lock);
if(service) {
se = getservbyname(service, NULL);
if ( se != NULL ) {
memcpy(se_buf, se, buf_len);
*se_result = se_buf;
} else {
*se_result = NULL;
}
}
MUTEX_UNLOCK(&internal_getsrvbyname_lock);
#endif /* __APPLE__ */
}
int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
struct gethostbyname_data ghdata;
@@ -833,24 +864,28 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
// printf("proxy_getaddrinfo node %s service %s\n",node,service);
space = calloc(1, sizeof(struct addrinfo_data));
if(!space) goto err1;
if(!space)
return 1;
if(node && !inet_aton(node, &((struct sockaddr_in *) &space->sockaddr_space)->sin_addr)) {
hp = proxy_gethostbyname(node, &ghdata);
if(hp)
if(hp) {
memcpy(&((struct sockaddr_in *) &space->sockaddr_space)->sin_addr,
*(hp->h_addr_list), sizeof(in_addr_t));
else
goto err2;
} else {
free(space);
return 1;
}
}
if(service) getservbyname_r(service, NULL, &se_buf, buf, sizeof(buf), &se);
if(service)
proxy_getservbyname(service, &se_buf, buf, sizeof(buf), &se);
port = se ? se->s_port : htons(atoi(service ? service : "0"));
((struct sockaddr_in *) &space->sockaddr_space)->sin_port = port;
((struct sockaddr_in *) &space->sockaddr_space)->sin_port = (in_port_t)port;
*res = p = &space->addrinfo_space;
assert((size_t)p == (size_t) space);
p->ai_addr = &space->sockaddr_space;
if(node)
strncpy(space->addr_name, node, sizeof(space->addr_name));
@@ -864,14 +899,12 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
p->ai_flags = hints->ai_flags;
p->ai_protocol = hints->ai_protocol;
} else {
#ifdef BSD
p->ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG);
#else
p->ai_flags = (AI_ADDRCONFIG);
#endif
}
goto out;
err2:
free(space);
err1:
return 1;
out:
return 0;
}
+18 -13
View File
@@ -41,7 +41,10 @@ extern internal_ip_lookup_table internal_ips;
#ifdef THREAD_SAFE
#include <pthread.h>
pthread_mutex_t internal_ips_lock;
extern pthread_mutex_t internal_ips_lock;
extern pthread_mutex_t internal_getsrvbyname_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)
@@ -99,21 +102,24 @@ typedef struct {
char pass[256];
} proxy_data;
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 connect_proxy_chain (int, ip_type, unsigned short, proxy_data *, unsigned int,
chain_type, unsigned int);
void proxychains_write_log(char *str, ...);
void proxychains_write_log(char *, ...);
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
typedef struct hostent* (*gethostbyname_t)(const char *);
typedef int (*freeaddrinfo_t)(struct addrinfo *);
#if (defined __linux__) || (defined __APPLE__)
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
#else
typedef struct hostent *(*gethostbyaddr_t) (const char *, socklen_t, int);
#endif
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
struct addrinfo **);
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int);
@@ -131,11 +137,10 @@ struct gethostbyname_data {
char addr_name[1024 * 8];
};
struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);
int proxy_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res);
void proxy_freeaddrinfo(struct addrinfo *res);
struct hostent* proxy_gethostbyname(const char *, struct gethostbyname_data *);
void proxy_getservbyname(const char *, struct servent *, char *, size_t, struct servent **);
int proxy_getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
void proxy_freeaddrinfo(struct addrinfo *);
#ifdef DEBUG
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
+46 -11
View File
@@ -19,6 +19,7 @@
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <errno.h>
@@ -55,6 +56,11 @@ int tcp_connect_time_out;
int proxychains_got_chain_data = 0;
int proxychains_quiet_mode = 0;
int proxychains_resolver = 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];
chain_type proxychains_ct;
proxy_data proxychains_pd[MAX_CHAIN];
@@ -71,7 +77,6 @@ static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, ch
static void* load_sym(char* symname, void* proxyfunc) {
void *funcptr = dlsym(RTLD_NEXT, symname);
if(!funcptr) {
fprintf(stderr, "Cannot load symbol '%s' %s\n", symname, dlerror());
exit(1);
@@ -91,18 +96,21 @@ static void* load_sym(char* symname, void* proxyfunc) {
static void do_init(void) {
MUTEX_INIT(&internal_ips_lock, NULL);
#ifdef __APPLE__
MUTEX_INIT(&internal_getsrvbyname_lock, NULL);
#endif
/* read the config file */
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
proxychains_write_log(LOG_PREFIX "DLL init\n");
SETUP_SYM(connect);
SETUP_SYM(gethostbyname);
SETUP_SYM(getaddrinfo);
SETUP_SYM(freeaddrinfo);
SETUP_SYM(gethostbyaddr);
SETUP_SYM(getnameinfo);
init_l = 1;
}
@@ -120,10 +128,10 @@ static void init_lib_wrapper(const char* caller) {
#endif
}
/* if we use gcc >= 3, we can instruct the dynamic loader
/* 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
* race condition if 2 threads call it before init_l is set
* and PTHREAD support was disabled */
#if __GNUC__ > 2
__attribute__((constructor))
@@ -132,9 +140,32 @@ static void gcc_init(void) {
}
#endif
FILE *
open_config_file() {
char home_conf[MAXPATHLEN], prefix_conf[MAXPATHLEN];
FILE *file;
snprintf(home_conf, 256, "%s/.proxychains/proxychains.conf", getenv("HOME"));
snprintf(prefix_conf, 256, "%s/etc/proxychains.conf", INSTALL_PREFIX);
if(!(file = fopen("./proxychains.conf", "r"))) {
if(!(file = fopen(home_conf, "r"))) {
if(!(file = fopen(prefix_conf, "r"))) {
if(!(file = fopen("/etc/proxychains.conf", "r"))) {
perror("Can't locate proxychains.conf");
exit(1);
}
}
}
}
return file;
}
/* 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;
unsigned int count = 0;
int port_n = 0, list = 0;
char buff[1024], type[1024], host[1024], user[1024];
char *env;
char local_in_addr_port[32];
@@ -148,7 +179,6 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
tcp_read_time_out = 4 * 1000;
tcp_connect_time_out = 10 * 1000;
*ct = DYNAMIC_TYPE;
env = get_config_path(getenv(PROXYCHAINS_CONF_FILE_ENV_VAR), buff, sizeof(buff));
file = fopen(env, "r");
@@ -162,7 +192,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
if(list) {
if(count >= MAX_CHAIN)
break;
memset(&pd[count], 0, sizeof(proxy_data));
pd[count].ps = PLAY_STATE;
@@ -237,7 +267,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
}
if(local_in_port[0]) {
localnet_addr[num_localnet_addr].port =
(short) atoi(local_in_port);
(unsigned short) atoi(local_in_port);
} else {
localnet_addr[num_localnet_addr].port = 0;
}
@@ -250,7 +280,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
int len;
pc = strchr(buff, '=');
len = atoi(++pc);
proxychains_max_chain = (len ? len : 1);
proxychains_max_chain = (unsigned int) (len ? len : 1);
} else if(strstr(buff, "quiet_mode")) {
proxychains_quiet_mode = 1;
} else if(strstr(buff, "proxy_dns")) {
@@ -277,6 +307,7 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
unsigned short port;
size_t i;
int remote_dns_connect = 0;
INIT();
optlen = sizeof(socktype);
getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &optlen);
@@ -378,7 +409,7 @@ int getnameinfo(const struct sockaddr *sa,
int ret = 0;
INIT();
PDEBUG("getnameinfo: %s %s\n", host, serv);
if(!proxychains_resolver) {
@@ -394,7 +425,11 @@ int getnameinfo(const struct sockaddr *sa,
return ret;
}
#if (defined __linux__) || (defined __APPLE__)
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
#else
struct hostent *gethostbyaddr(const char *addr, socklen_t len, int type) {
#endif
static char buf[16];
static char ipv4[4];
static char *list[2];
+5 -6
View File
@@ -94,7 +94,6 @@ int main(int argc, char *argv[]) {
/* check if path of config file has not been passed via command line */
path = get_config_path(path, pbuf, sizeof(pbuf));
if(!quiet)
fprintf(stderr, LOG_PREFIX "config file found: %s\n", path);
@@ -125,12 +124,12 @@ int main(int argc, char *argv[]) {
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
#ifndef IS_MAC
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/%s", prefix, dll_name);
putenv(buf);
snprintf(buf, sizeof(buf), "%s/%s", prefix, dll_name);
setenv("LD_PRELOAD", buf, 1);
#else
snprintf(buf, sizeof(buf), "DYLD_INSERT_LIBRARIES=%s/%s", prefix, dll_name);
putenv(buf);
putenv("DYLD_FORCE_FLAT_NAMESPACE=1");
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]);
perror("proxychains can't load process....");
+93 -13
View File
@@ -1,26 +1,106 @@
#!/bin/sh
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
echo "ProxyChains-4.0 (https://github.com/haad/proxychains)"
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
}
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
usage
fi
if [ $1 = "-h" ]; then
usage
fi
case "$1" in
-h)
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
export PROXYCHAINS_CONF_FILE=$2;
shift;
shift;
fi
export LD_PRELOAD=libproxychains.so.3
exec "$@"
case "$1" in
on)
setup_proxy_env
show_proxy_env
;;
off)
disable_proxy_env
show_proxy_env
;;
*)
setup_proxy_env
exec "$@"
;;
esac
+10 -1
View File
@@ -1,4 +1,4 @@
# proxychains.conf VER 3.1
# proxychains.conf VER 4
#
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#
@@ -54,6 +54,15 @@ remote_dns_subnet 224
tcp_read_time_out 15000
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
## Exclude connections to 192.168.1.0/24 with port 80
# localnet 192.168.1.0:80/255.255.255.0