mirror of
https://github.com/rofl0r/proxychains-ng
synced 2026-05-15 01:52:34 +08:00
Compare commits
1 Commits
@@ -30,7 +30,7 @@ GENH = src/version.h
|
|||||||
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
|
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
|
||||||
NO_AS_NEEDED = -Wl,--no-as-needed
|
NO_AS_NEEDED = -Wl,--no-as-needed
|
||||||
LIBDL = -ldl
|
LIBDL = -ldl
|
||||||
LDFLAGS = -fPIC $(NO_AS_NEEDED) $(LIBDL) $(PTHREAD)
|
LDFLAGS = -fPIC $(NO_AS_NEEDED) $(LIBDL) -lpthread
|
||||||
INC =
|
INC =
|
||||||
PIC = -fPIC
|
PIC = -fPIC
|
||||||
AR = $(CROSS_COMPILE)ar
|
AR = $(CROSS_COMPILE)ar
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ProxyChains-NG ver 4.15 README
|
ProxyChains-NG ver 4.14 README
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||||
@@ -52,18 +52,6 @@ ProxyChains-NG ver 4.15 README
|
|||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
----------
|
----------
|
||||||
Version 4.15
|
|
||||||
- fix configure script for buggy binutils version
|
|
||||||
- initialize rand_seed with nano-second granularity
|
|
||||||
- add support for numeric ipv6 in getaddrinfo
|
|
||||||
- fix bug in getaddrinfo when node is null and !passive
|
|
||||||
- add dnat feature
|
|
||||||
- add raw proxy type
|
|
||||||
- add haiku support
|
|
||||||
- add proxy_dns_old to emulate proxychains 3.1 behaviour
|
|
||||||
- add new proxy_dns_daemon feature (experimental)
|
|
||||||
- various other fixes
|
|
||||||
|
|
||||||
Version 4.14
|
Version 4.14
|
||||||
- allow alternative proto://user:pass@ip:port syntax for proxylist
|
- allow alternative proto://user:pass@ip:port syntax for proxylist
|
||||||
- fix endless loop in round robin mode when all proxies are down (#147)
|
- fix endless loop in round robin mode when all proxies are down (#147)
|
||||||
@@ -248,7 +236,7 @@ Known Problems:
|
|||||||
|
|
||||||
Community:
|
Community:
|
||||||
----------
|
----------
|
||||||
#proxychains on irc.libera.chat
|
#proxychains on irc.freenode.net
|
||||||
|
|
||||||
Donations:
|
Donations:
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -19,12 +19,11 @@ check_compile() {
|
|||||||
printf "checking %s ... " "$1"
|
printf "checking %s ... " "$1"
|
||||||
printf "$3" > "$tmpc"
|
printf "$3" > "$tmpc"
|
||||||
local res=0
|
local res=0
|
||||||
$CC $OUR_CPPFLAGS $CPPFLAGS $2 $CFLAGS "$tmpc" -o "$tmpc".out >/dev/null 2>&1 \
|
$CC $OUR_CPPFLAGS $CPPFLAGS $2 $CFLAGS "$tmpc" -o /dev/null >/dev/null 2>&1 \
|
||||||
|| res=1
|
|| res=1
|
||||||
test x$res = x0 && \
|
test x$res = x0 && \
|
||||||
{ printf "yes\n" ; test x"$2" = x || OUR_CPPFLAGS="$OUR_CPPFLAGS $2" ; } \
|
{ printf "yes\n" ; test x"$2" = x || OUR_CPPFLAGS="$OUR_CPPFLAGS $2" ; } \
|
||||||
|| printf "no\n"
|
|| printf "no\n"
|
||||||
rm -f "$tmpc".out
|
|
||||||
return $res
|
return $res
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +49,7 @@ check_compile_run() {
|
|||||||
|
|
||||||
check_link_silent() {
|
check_link_silent() {
|
||||||
printf "$2" > "$tmpc"
|
printf "$2" > "$tmpc"
|
||||||
$CC $OUR_CPPFLAGS $CPPFLAGS $1 $CFLAGS "$tmpc" -o "$tmpc".out >/dev/null 2>&1
|
$CC $OUR_CPPFLAGS $CPPFLAGS $1 $CFLAGS "$tmpc" -o /dev/null >/dev/null 2>&1
|
||||||
rm -f "$tmpc".out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_link() {
|
check_link() {
|
||||||
@@ -167,9 +165,6 @@ check_compile 'whether we have pipe2() and O_CLOEXEC' "-DHAVE_PIPE2" \
|
|||||||
check_compile 'whether we have SOCK_CLOEXEC' "-DHAVE_SOCK_CLOEXEC" \
|
check_compile 'whether we have SOCK_CLOEXEC' "-DHAVE_SOCK_CLOEXEC" \
|
||||||
'#define _GNU_SOURCE\n#include <sys/socket.h>\nint main() {\nreturn socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);}'
|
'#define _GNU_SOURCE\n#include <sys/socket.h>\nint main() {\nreturn socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);}'
|
||||||
|
|
||||||
check_compile 'whether we have clock_gettime' "-DHAVE_CLOCK_GETTIME" \
|
|
||||||
'#define _GNU_SOURCE\n#include <time.h>\nint main() {\nstruct timespec now;clock_gettime(CLOCK_REALTIME, &now);\nreturn now.tv_sec ^ now.tv_nsec;}'
|
|
||||||
|
|
||||||
check_define __APPLE__ && {
|
check_define __APPLE__ && {
|
||||||
mac_detected=true
|
mac_detected=true
|
||||||
check_define __x86_64__ && mac_64=true
|
check_define __x86_64__ && mac_64=true
|
||||||
@@ -213,15 +208,6 @@ fi
|
|||||||
echo "$LD_SONAME_FLAG"
|
echo "$LD_SONAME_FLAG"
|
||||||
echo "LD_SET_SONAME = -Wl,$LD_SONAME_FLAG," >> config.mak
|
echo "LD_SET_SONAME = -Wl,$LD_SONAME_FLAG," >> config.mak
|
||||||
|
|
||||||
if check_link "checking whether we can use -lpthread" "-lpthread" \
|
|
||||||
"int main(){return 0;}" ; then
|
|
||||||
echo "PTHREAD = -lpthread" >> config.mak
|
|
||||||
else
|
|
||||||
check_link "checking whether we can use -pthread" "-pthread" \
|
|
||||||
"int main(){return 0;}" || fail "no pthread support detected"
|
|
||||||
echo "PTHREAD = -pthread" >> config.mak
|
|
||||||
fi
|
|
||||||
|
|
||||||
make_cmd=make
|
make_cmd=make
|
||||||
if ismac ; then
|
if ismac ; then
|
||||||
echo LDSO_SUFFIX=dylib>>config.mak
|
echo LDSO_SUFFIX=dylib>>config.mak
|
||||||
|
|||||||
+50
-20
@@ -475,7 +475,8 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
|
|||||||
case RANDOMLY:
|
case RANDOMLY:
|
||||||
do {
|
do {
|
||||||
k++;
|
k++;
|
||||||
i = rand() % proxy_count;
|
i = rand() % (proxy_count-proxychains_fixed_chain);
|
||||||
|
i += proxychains_fixed_chain;
|
||||||
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
|
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
|
||||||
break;
|
break;
|
||||||
case FIFOLY:
|
case FIFOLY:
|
||||||
@@ -563,9 +564,38 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
|
|||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int strict_connect(
|
||||||
|
unsigned *alive_count,
|
||||||
|
unsigned *offset,
|
||||||
|
int *ns,
|
||||||
|
proxy_data **p1, proxy_data **p2,
|
||||||
|
unsigned proxy_count, proxy_data * pd)
|
||||||
|
{
|
||||||
|
*alive_count = calc_alive(pd, proxy_count);
|
||||||
|
*offset = 0;
|
||||||
|
if(!(*p1 = select_proxy(FIFOLY, pd, proxy_count, offset))) {
|
||||||
|
PDEBUG("select_proxy failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(SUCCESS != start_chain(ns, *p1, ST)) {
|
||||||
|
PDEBUG("start_chain failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
while(*offset < proxy_count) {
|
||||||
|
if(!(*p2 = select_proxy(FIFOLY, pd, proxy_count, offset)))
|
||||||
|
break;
|
||||||
|
if(SUCCESS != chain_step(*ns, *p1, *p2)) {
|
||||||
|
PDEBUG("chain_step failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*p1 = *p2;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int connect_proxy_chain(int sock, ip_type target_ip,
|
int connect_proxy_chain(int sock, ip_type target_ip,
|
||||||
unsigned short target_port, proxy_data * pd,
|
unsigned short target_port, proxy_data * pd,
|
||||||
unsigned int proxy_count, chain_type ct, unsigned int max_chain) {
|
unsigned int proxy_count, chain_type ct) {
|
||||||
proxy_data p4;
|
proxy_data p4;
|
||||||
proxy_data *p1, *p2, *p3;
|
proxy_data *p1, *p2, *p3;
|
||||||
int ns = -1;
|
int ns = -1;
|
||||||
@@ -575,6 +605,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
unsigned int curr_len = 0;
|
unsigned int curr_len = 0;
|
||||||
unsigned int looped = 0; // went back to start of list in RR mode
|
unsigned int looped = 0; // went back to start of list in RR mode
|
||||||
unsigned int rr_loop_max = 14;
|
unsigned int rr_loop_max = 14;
|
||||||
|
unsigned int max_chain = proxychains_max_chain;
|
||||||
|
|
||||||
p3 = &p4;
|
p3 = &p4;
|
||||||
|
|
||||||
@@ -583,9 +614,14 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
again:
|
again:
|
||||||
rc = -1;
|
rc = -1;
|
||||||
DUMP_PROXY_CHAIN(pd, proxy_count);
|
DUMP_PROXY_CHAIN(pd, proxy_count);
|
||||||
|
if(proxychains_fixed_chain) {
|
||||||
|
if(!strict_connect(&alive_count, &offset, &ns, &p1, &p2, proxychains_fixed_chain, pd))
|
||||||
|
goto error_strict;
|
||||||
|
}
|
||||||
|
|
||||||
switch (ct) {
|
switch (ct) {
|
||||||
case DYNAMIC_TYPE:
|
case DYNAMIC_TYPE:
|
||||||
|
if(proxychains_fixed_chain) goto dyn_fixed_resume;
|
||||||
alive_count = calc_alive(pd, proxy_count);
|
alive_count = calc_alive(pd, proxy_count);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
do {
|
do {
|
||||||
@@ -601,6 +637,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
|
dyn_fixed_resume:;
|
||||||
}
|
}
|
||||||
//proxychains_write_log(TP);
|
//proxychains_write_log(TP);
|
||||||
p3->ip = target_ip;
|
p3->ip = target_ip;
|
||||||
@@ -610,6 +647,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ROUND_ROBIN_TYPE:
|
case ROUND_ROBIN_TYPE:
|
||||||
|
// FIXME: add support for fixed_len
|
||||||
alive_count = calc_alive(pd, proxy_count);
|
alive_count = calc_alive(pd, proxy_count);
|
||||||
offset = proxychains_proxy_offset;
|
offset = proxychains_proxy_offset;
|
||||||
if(alive_count < max_chain)
|
if(alive_count < max_chain)
|
||||||
@@ -660,25 +698,8 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STRICT_TYPE:
|
case STRICT_TYPE:
|
||||||
alive_count = calc_alive(pd, proxy_count);
|
if(!strict_connect(&alive_count, &offset, &ns, &p1, &p2, proxy_count, pd))
|
||||||
offset = 0;
|
|
||||||
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
|
|
||||||
PDEBUG("select_proxy failed\n");
|
|
||||||
goto error_strict;
|
goto error_strict;
|
||||||
}
|
|
||||||
if(SUCCESS != start_chain(&ns, p1, ST)) {
|
|
||||||
PDEBUG("start_chain failed\n");
|
|
||||||
goto error_strict;
|
|
||||||
}
|
|
||||||
while(offset < proxy_count) {
|
|
||||||
if(!(p2 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
|
|
||||||
break;
|
|
||||||
if(SUCCESS != chain_step(ns, p1, p2)) {
|
|
||||||
PDEBUG("chain_step failed\n");
|
|
||||||
goto error_strict;
|
|
||||||
}
|
|
||||||
p1 = p2;
|
|
||||||
}
|
|
||||||
//proxychains_write_log(TP);
|
//proxychains_write_log(TP);
|
||||||
p3->ip = target_ip;
|
p3->ip = target_ip;
|
||||||
p3->port = target_port;
|
p3->port = target_port;
|
||||||
@@ -687,6 +708,12 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RANDOM_TYPE:
|
case RANDOM_TYPE:
|
||||||
|
if(proxychains_fixed_chain) {
|
||||||
|
if(alive_count < max_chain)
|
||||||
|
goto error_more;
|
||||||
|
curr_len = proxychains_fixed_chain - 1;
|
||||||
|
goto random_fixed_resume;
|
||||||
|
}
|
||||||
alive_count = calc_alive(pd, proxy_count);
|
alive_count = calc_alive(pd, proxy_count);
|
||||||
if(alive_count < max_chain)
|
if(alive_count < max_chain)
|
||||||
goto error_more;
|
goto error_more;
|
||||||
@@ -695,6 +722,9 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
if(!(p1 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
|
if(!(p1 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
|
||||||
goto error_more;
|
goto error_more;
|
||||||
} while(SUCCESS != start_chain(&ns, p1, RT) && offset < max_chain);
|
} while(SUCCESS != start_chain(&ns, p1, RT) && offset < max_chain);
|
||||||
|
|
||||||
|
random_fixed_resume:;
|
||||||
|
|
||||||
while(++curr_len < max_chain) {
|
while(++curr_len < max_chain) {
|
||||||
if(!(p2 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
|
if(!(p2 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
|
||||||
goto error_more;
|
goto error_more;
|
||||||
|
|||||||
+4
-2
@@ -84,8 +84,7 @@ typedef struct {
|
|||||||
} proxy_data;
|
} proxy_data;
|
||||||
|
|
||||||
int connect_proxy_chain (int sock, ip_type target_ip, unsigned short target_port,
|
int connect_proxy_chain (int sock, ip_type target_ip, unsigned short target_port,
|
||||||
proxy_data * pd, unsigned int proxy_count, chain_type ct,
|
proxy_data * pd, unsigned int proxy_count, chain_type ct );
|
||||||
unsigned int max_chain );
|
|
||||||
|
|
||||||
void proxychains_write_log(char *str, ...);
|
void proxychains_write_log(char *str, ...);
|
||||||
|
|
||||||
@@ -130,6 +129,9 @@ void proxy_freeaddrinfo(struct addrinfo *res);
|
|||||||
void core_initialize(void);
|
void core_initialize(void);
|
||||||
void core_unload(void);
|
void core_unload(void);
|
||||||
|
|
||||||
|
extern unsigned int proxychains_max_chain;
|
||||||
|
extern unsigned int proxychains_fixed_chain;
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+21
-12
@@ -71,6 +71,7 @@ unsigned int proxychains_proxy_count = 0;
|
|||||||
unsigned int proxychains_proxy_offset = 0;
|
unsigned int proxychains_proxy_offset = 0;
|
||||||
int proxychains_got_chain_data = 0;
|
int proxychains_got_chain_data = 0;
|
||||||
unsigned int proxychains_max_chain = 1;
|
unsigned int proxychains_max_chain = 1;
|
||||||
|
unsigned int proxychains_fixed_chain = 0;
|
||||||
int proxychains_quiet_mode = 0;
|
int proxychains_quiet_mode = 0;
|
||||||
enum dns_lookup_flavor proxychains_resolver = DNSLF_LIBC;
|
enum dns_lookup_flavor proxychains_resolver = DNSLF_LIBC;
|
||||||
localaddr_arg localnet_addr[MAX_LOCALNET];
|
localaddr_arg localnet_addr[MAX_LOCALNET];
|
||||||
@@ -127,18 +128,8 @@ static void setup_hooks(void) {
|
|||||||
static int close_fds[16];
|
static int close_fds[16];
|
||||||
static int close_fds_cnt = 0;
|
static int close_fds_cnt = 0;
|
||||||
|
|
||||||
static unsigned get_rand_seed(void) {
|
|
||||||
#ifdef HAVE_CLOCK_GETTIME
|
|
||||||
struct timespec now;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
|
||||||
return now.tv_sec ^ now.tv_nsec;
|
|
||||||
#else
|
|
||||||
return time(NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_init(void) {
|
static void do_init(void) {
|
||||||
srand(get_rand_seed());
|
srand(time(NULL));
|
||||||
core_initialize();
|
core_initialize();
|
||||||
|
|
||||||
/* read the config file */
|
/* read the config file */
|
||||||
@@ -448,6 +439,16 @@ inv_host:
|
|||||||
}
|
}
|
||||||
len = atoi(++pc);
|
len = atoi(++pc);
|
||||||
proxychains_max_chain = (len ? len : 1);
|
proxychains_max_chain = (len ? len : 1);
|
||||||
|
} else if(STR_STARTSWITH(buff, "fixed_len")) {
|
||||||
|
char *pc;
|
||||||
|
int len;
|
||||||
|
pc = strchr(buff, '=');
|
||||||
|
if(!pc) {
|
||||||
|
fprintf(stderr, "error: missing equals sign '=' in fixed_len directive.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
len = atoi(++pc);
|
||||||
|
proxychains_fixed_chain = (len ? len : 1);
|
||||||
} else if(!strcmp(buff, "quiet_mode")) {
|
} else if(!strcmp(buff, "quiet_mode")) {
|
||||||
proxychains_quiet_mode = 1;
|
proxychains_quiet_mode = 1;
|
||||||
} else if(!strcmp(buff, "proxy_dns_old")) {
|
} else if(!strcmp(buff, "proxy_dns_old")) {
|
||||||
@@ -530,6 +531,14 @@ inv_host:
|
|||||||
fprintf(stderr, "error: no valid proxy found in config\n");
|
fprintf(stderr, "error: no valid proxy found in config\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if(proxychains_max_chain <= proxychains_fixed_chain) {
|
||||||
|
fprintf(stderr, "error: fixed_len needs to be smaller than chain_len\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if(proxychains_fixed_chain > count) {
|
||||||
|
fprintf(stderr, "error: fixed_len > proxycount\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
*proxy_count = count;
|
*proxy_count = count;
|
||||||
proxychains_got_chain_data = 1;
|
proxychains_got_chain_data = 1;
|
||||||
PDEBUG("proxy_dns: %s\n", rdns_resolver_string(proxychains_resolver));
|
PDEBUG("proxy_dns: %s\n", rdns_resolver_string(proxychains_resolver));
|
||||||
@@ -640,7 +649,7 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
|||||||
ret = connect_proxy_chain(sock,
|
ret = connect_proxy_chain(sock,
|
||||||
dest_ip,
|
dest_ip,
|
||||||
htons(port),
|
htons(port),
|
||||||
proxychains_pd, proxychains_proxy_count, proxychains_ct, proxychains_max_chain);
|
proxychains_pd, proxychains_proxy_count, proxychains_ct);
|
||||||
|
|
||||||
fcntl(sock, F_SETFL, flags);
|
fcntl(sock, F_SETFL, flags);
|
||||||
if(ret != SUCCESS)
|
if(ret != SUCCESS)
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ strict_chain
|
|||||||
# Make sense only if random_chain or round_robin_chain
|
# Make sense only if random_chain or round_robin_chain
|
||||||
#chain_len = 2
|
#chain_len = 2
|
||||||
|
|
||||||
|
# use this if you want to use e.g. random_chain but always have
|
||||||
|
# e.g. tor as first proxy. in that case only chain_len - fixed_len proxies
|
||||||
|
# will be used for random chain.
|
||||||
|
# currently only implemented for dynamic_chain and random_chain.
|
||||||
|
#fixed_len = 1
|
||||||
|
|
||||||
# Quiet mode (no output from library)
|
# Quiet mode (no output from library)
|
||||||
#quiet_mode
|
#quiet_mode
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user