mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-01-23 01:12:59 +08:00
Compare commits
No commits in common. "04f66223a44d5cf24aadfa667056543f036d9912" and "14ba73189c865fd3b9a0a6d3145288f5772257b3" have entirely different histories.
04f66223a4
...
14ba73189c
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ prefix = /usr/local/
|
||||
includedir = $(prefix)/include
|
||||
libdir = $(prefix)/lib
|
||||
sysconfdir = $(prefix)/etc
|
||||
zshcompletiondir = $(prefix)/share/zsh/site-functions
|
||||
zshcompletiondir = $(prefix)/share/zsh/site_functions
|
||||
|
||||
OBJS = src/common.o src/main.o
|
||||
|
||||
|
11
README
11
README
@ -1,4 +1,4 @@
|
||||
ProxyChains-NG ver 4.17 README
|
||||
ProxyChains-NG ver 4.16 README
|
||||
=============================
|
||||
|
||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||
@ -52,15 +52,6 @@ ProxyChains-NG ver 4.17 README
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
Version 4.17
|
||||
- add hook for close_range function, fixing newer versions of openssh
|
||||
- fat-binary-m1 option for mac
|
||||
- fix DNS error handling in proxy_dns_old
|
||||
- simplify init code
|
||||
- fix openbsd preloading
|
||||
- fix double-close in multithreaded apps
|
||||
- various improvements to configure script
|
||||
|
||||
Version 4.16
|
||||
- fix regression in configure script linker flag detection
|
||||
- remove 10 year old workaround for wrong glibc getnameinfo signature
|
||||
|
12
configure
vendored
12
configure
vendored
@ -87,7 +87,6 @@ usage() {
|
||||
echo " to preload from current dir (possibly insecure, but handy)"
|
||||
echo "--fat-binary : build for both i386 and x86_64 architectures on 64-bit Macs"
|
||||
echo "--fat-binary-m1 : build for both arm64e and x86_64 architectures on M1 Macs"
|
||||
echo "--fat-binary-m2 : build for arm64, arm64e and x86_64 architectures on M2+ Macs"
|
||||
echo "--hookmethod=dlsym|dyld hook method for osx. default: auto"
|
||||
echo " if OSX >= 12 is detected, dyld method will be used if auto."
|
||||
echo "--help : show this text"
|
||||
@ -103,7 +102,6 @@ spliteq() {
|
||||
|
||||
fat_binary=
|
||||
fat_binary_m1=
|
||||
fat_binary_m2=
|
||||
ignore_cve=no
|
||||
hookmethod=auto
|
||||
|
||||
@ -120,7 +118,6 @@ parsearg() {
|
||||
--hookmethod=*) hookmethod=`spliteq $1`;;
|
||||
--fat-binary) fat_binary=1;;
|
||||
--fat-binary-m1) fat_binary_m1=1;;
|
||||
--fat-binary-m2) fat_binary_m2=1;;
|
||||
--help) usage;;
|
||||
esac
|
||||
}
|
||||
@ -292,12 +289,6 @@ if ismac ; then
|
||||
echo "FAT_LDFLAGS=-arch arm64 -arch arm64e -arch x86_64">>config.mak
|
||||
echo "FAT_BIN_LDFLAGS=-arch arm64 -arch x86_64">>config.mak
|
||||
fi
|
||||
if [ "$fat_binary_m2" = 1 ] ; then
|
||||
echo "Configuring a fat binary for arm64[e] and x86_64"
|
||||
echo "MAC_CFLAGS+=-arch arm64 -arch arm64e -arch x86_64">>config.mak
|
||||
echo "FAT_LDFLAGS=-arch arm64 -arch arm64e -arch x86_64">>config.mak
|
||||
echo "FAT_BIN_LDFLAGS=-arch arm64 -arch arm64e -arch x86_64">>config.mak
|
||||
fi
|
||||
elif isbsd ; then
|
||||
echo LIBDL=>>config.mak
|
||||
echo "CFLAGS+=-DIS_BSD">>config.mak
|
||||
@ -311,6 +302,3 @@ elif ishaiku ; then
|
||||
fi
|
||||
|
||||
echo "Done, now run $make_cmd && $make_cmd install"
|
||||
if [ "$fat_binary_m2" = 1 ] ; then
|
||||
echo "Don't forget to run csrutil disable and sudo nvram boot-args=-arm64e_preview_abi"
|
||||
fi
|
||||
|
49
src/core.c
49
src/core.c
@ -985,10 +985,8 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
|
||||
error1:
|
||||
proxychains_write_log(TP " timeout\n");
|
||||
error:
|
||||
if(*fd != -1) {
|
||||
if(*fd != -1)
|
||||
true_close(*fd);
|
||||
*fd = -1;
|
||||
}
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
@ -1046,9 +1044,9 @@ static unsigned int calc_alive(proxy_data * pd, unsigned int proxy_count) {
|
||||
}
|
||||
|
||||
|
||||
static int chain_step(int *ns, proxy_data * pfrom, proxy_data * pto) {
|
||||
static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
|
||||
int retcode = -1;
|
||||
char *hostname, *errmsg = 0;
|
||||
char *hostname;
|
||||
char hostname_buf[MSG_LEN_MAX];
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
int v6 = pto->ip.is_v6;
|
||||
@ -1062,34 +1060,31 @@ static int chain_step(int *ns, proxy_data * pfrom, proxy_data * pto) {
|
||||
usenumericip:
|
||||
if(!inet_ntop(v6?AF_INET6:AF_INET,pto->ip.addr.v6,ip_buf,sizeof ip_buf)) {
|
||||
pto->ps = DOWN_STATE;
|
||||
errmsg = "<--ip conversion error!\n";
|
||||
retcode = SOCKET_ERROR;
|
||||
goto err;
|
||||
proxychains_write_log("<--ip conversion error!\n");
|
||||
true_close(ns);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
hostname = ip_buf;
|
||||
}
|
||||
|
||||
proxychains_write_log(TP " %s:%d ", hostname, htons(pto->port));
|
||||
retcode = tunnel_to(*ns, pto->ip, pto->port, pfrom->pt, pfrom->user, pfrom->pass);
|
||||
retcode = tunnel_to(ns, pto->ip, pto->port, pfrom->pt, pfrom->user, pfrom->pass);
|
||||
switch (retcode) {
|
||||
case SUCCESS:
|
||||
pto->ps = BUSY_STATE;
|
||||
break;
|
||||
case BLOCKED:
|
||||
pto->ps = BLOCKED_STATE;
|
||||
errmsg = "<--denied\n";
|
||||
goto err;
|
||||
proxychains_write_log("<--denied\n");
|
||||
true_close(ns);
|
||||
break;
|
||||
case SOCKET_ERROR:
|
||||
pto->ps = DOWN_STATE;
|
||||
errmsg = "<--socket error or timeout!\n";
|
||||
goto err;
|
||||
proxychains_write_log("<--socket error or timeout!\n");
|
||||
true_close(ns);
|
||||
break;
|
||||
}
|
||||
return retcode;
|
||||
err:
|
||||
if(errmsg) proxychains_write_log(errmsg);
|
||||
if(*ns != -1) true_close(*ns);
|
||||
*ns = -1;
|
||||
return retcode;
|
||||
}
|
||||
|
||||
int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
@ -1125,7 +1120,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
p2 = select_proxy(FIFOLY, pd, proxy_count, &offset);
|
||||
if(!p2)
|
||||
break;
|
||||
if(SUCCESS != chain_step(&ns, p1, p2)) {
|
||||
if(SUCCESS != chain_step(ns, p1, p2)) {
|
||||
PDEBUG("GOTO AGAIN 1\n");
|
||||
goto again;
|
||||
}
|
||||
@ -1134,7 +1129,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
//proxychains_write_log(TP);
|
||||
p3->ip = target_ip;
|
||||
p3->port = target_port;
|
||||
if(SUCCESS != chain_step(&ns, p1, p3))
|
||||
if(SUCCESS != chain_step(ns, p1, p3))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
@ -1172,7 +1167,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
/* Try from the beginning to where we started */
|
||||
offset = 0;
|
||||
continue;
|
||||
} else if(SUCCESS != chain_step(&ns, p1, p2)) {
|
||||
} else if(SUCCESS != chain_step(ns, p1, p2)) {
|
||||
PDEBUG("GOTO AGAIN 1\n");
|
||||
goto again;
|
||||
} else
|
||||
@ -1184,7 +1179,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
p3->port = target_port;
|
||||
proxychains_proxy_offset = offset+1;
|
||||
PDEBUG("pd_offset = %d, curr_len = %d\n", proxychains_proxy_offset, curr_len);
|
||||
if(SUCCESS != chain_step(&ns, p1, p3))
|
||||
if(SUCCESS != chain_step(ns, p1, p3))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
@ -1202,7 +1197,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
while(offset < proxy_count) {
|
||||
if(!(p2 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
|
||||
break;
|
||||
if(SUCCESS != chain_step(&ns, p1, p2)) {
|
||||
if(SUCCESS != chain_step(ns, p1, p2)) {
|
||||
PDEBUG("chain_step failed\n");
|
||||
goto error_strict;
|
||||
}
|
||||
@ -1211,7 +1206,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
//proxychains_write_log(TP);
|
||||
p3->ip = target_ip;
|
||||
p3->port = target_port;
|
||||
if(SUCCESS != chain_step(&ns, p1, p3))
|
||||
if(SUCCESS != chain_step(ns, p1, p3))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
@ -1227,7 +1222,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
while(++curr_len < max_chain) {
|
||||
if(!(p2 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
|
||||
goto error_more;
|
||||
if(SUCCESS != chain_step(&ns, p1, p2)) {
|
||||
if(SUCCESS != chain_step(ns, p1, p2)) {
|
||||
PDEBUG("GOTO AGAIN 2\n");
|
||||
goto again;
|
||||
}
|
||||
@ -1236,7 +1231,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
//proxychains_write_log(TP);
|
||||
p3->ip = target_ip;
|
||||
p3->port = target_port;
|
||||
if(SUCCESS != chain_step(&ns, p1, p3))
|
||||
if(SUCCESS != chain_step(ns, p1, p3))
|
||||
goto error;
|
||||
|
||||
}
|
||||
@ -1310,7 +1305,7 @@ int add_node_to_chain(proxy_data * pd, udp_relay_chain * chain){
|
||||
}
|
||||
// Connect to the rest of the chain
|
||||
while(tmp->next != NULL){
|
||||
if(SUCCESS != chain_step(&(new_node->tcp_sockfd), &(tmp->pd), &(tmp->next->pd))){
|
||||
if(SUCCESS != chain_step(new_node->tcp_sockfd, &(tmp->pd), &(tmp->next->pd))){
|
||||
PDEBUG("chain step failed\n");
|
||||
new_node->tcp_sockfd = -1;
|
||||
goto err;
|
||||
|
@ -155,7 +155,7 @@ typedef int (*close_range_t)(unsigned, unsigned, int);
|
||||
typedef void (*uv_close_t)(uv_handle_t* , uv_close_cb);
|
||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||
typedef struct hostent* (*gethostbyname_t)(const char *);
|
||||
typedef void (*freeaddrinfo_t)(struct addrinfo *);
|
||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
||||
|
||||
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
||||
|
14
src/main.c
14
src/main.c
@ -135,20 +135,16 @@ int main(int argc, char *argv[]) {
|
||||
if(!quiet)
|
||||
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
||||
|
||||
#if defined(IS_MAC) || defined(IS_OPENBSD)
|
||||
#define LD_PRELOAD_SEP ":"
|
||||
#else
|
||||
/* Dynlinkers for Linux and most BSDs seem to support space
|
||||
as LD_PRELOAD separator, with colon added only recently.
|
||||
We use the old syntax for maximum compat */
|
||||
#define LD_PRELOAD_SEP " "
|
||||
#endif
|
||||
|
||||
#ifdef IS_MAC
|
||||
putenv("DYLD_FORCE_FLAT_NAMESPACE=1");
|
||||
#define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES"
|
||||
#define LD_PRELOAD_SEP ":"
|
||||
#else
|
||||
#define LD_PRELOAD_ENV "LD_PRELOAD"
|
||||
/* all historic implementations of BSD and linux dynlinkers seem to support
|
||||
space as LD_PRELOAD separator, with colon added only recently.
|
||||
we use the old syntax for maximum compat */
|
||||
#define LD_PRELOAD_SEP " "
|
||||
#endif
|
||||
char *old_val = getenv(LD_PRELOAD_ENV);
|
||||
snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s%s%s",
|
||||
|
Loading…
Reference in New Issue
Block a user