mirror of
https://github.com/rofl0r/proxychains-ng
synced 2026-05-14 17:42:36 +08:00
Compare commits
6 Commits
+12
@@ -0,0 +1,12 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
.deps/
|
||||||
|
.libs/
|
||||||
|
|
||||||
|
# Autoconf stuff
|
||||||
|
libtool
|
||||||
|
config.*
|
||||||
|
Makefile
|
||||||
|
stamp-h
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ProxyChains ver 3.1 README
|
ProxyChains ver 3.1 README
|
||||||
======================
|
==========================
|
||||||
|
|
||||||
This is Unix version only.
|
This is Unix version only.
|
||||||
|
|
||||||
@@ -40,9 +40,11 @@ Some cool features:
|
|||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
proxychains looks for config file in following order:
|
proxychains looks for config file in following order:
|
||||||
1) ./proxychains.conf
|
1) file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
|
||||||
2) $(HOME)/.proxychains/proxychains.conf
|
provided as a -f argument to proxychains script or binary.
|
||||||
3) /etc/proxychains.conf **
|
2) ./proxychains.conf
|
||||||
|
3) $(HOME)/.proxychains/proxychains.conf
|
||||||
|
4) /etc/proxychains.conf **
|
||||||
|
|
||||||
**see more in /etc/proxychains.conf
|
**see more in /etc/proxychains.conf
|
||||||
|
|
||||||
@@ -53,6 +55,13 @@ Usage Example:
|
|||||||
in this example it will run telnet through proxy(or chained proxies)
|
in this example it will run telnet through proxy(or chained proxies)
|
||||||
specified by proxychains.conf
|
specified by proxychains.conf
|
||||||
|
|
||||||
|
Usage Example:
|
||||||
|
|
||||||
|
bash$ proxychains -f /etc/proxychains-other.conf targethost2.com
|
||||||
|
|
||||||
|
in this example it will use different configuration file then proxychains.conf
|
||||||
|
to connect to targethost2.com host.
|
||||||
|
|
||||||
Usage Example:
|
Usage Example:
|
||||||
|
|
||||||
bash$ proxyresolv targethost.com
|
bash$ proxyresolv targethost.com
|
||||||
@@ -60,5 +69,3 @@ Usage Example:
|
|||||||
in this example it will resolve targethost.com through proxy(or chained proxies)
|
in this example it will resolve targethost.com through proxy(or chained proxies)
|
||||||
specified by proxychains.conf
|
specified by proxychains.conf
|
||||||
|
|
||||||
NOTE:
|
|
||||||
to run suid/sgid programs(like ssh) through proxychains you have to be root
|
|
||||||
|
|||||||
+43
-21
@@ -43,6 +43,33 @@ extern int proxychains_quiet_mode;
|
|||||||
|
|
||||||
static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
int time_remain = timeout;
|
||||||
|
int time_elapsed = 0;
|
||||||
|
|
||||||
|
struct timeval start_time;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday(&start_time, NULL);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
//printf("Time elapsed %d\n", time_elapsed);
|
||||||
|
time_remain = timeout - time_elapsed;
|
||||||
|
}
|
||||||
|
while (ret == -1 && errno == EINTR && time_remain > 0);
|
||||||
|
//if (ret == -1)
|
||||||
|
//printf("Return %d %d %s\n", ret, errno, strerror(errno));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void encode_base_64(char* src,char* dest,int max_len)
|
static void encode_base_64(char* src,char* dest,int max_len)
|
||||||
{
|
{
|
||||||
int n,l,i;
|
int n,l,i;
|
||||||
@@ -123,7 +150,7 @@ static int read_line(int fd, char *buff, size_t size)
|
|||||||
for(i=0;i<size-1;i++)
|
for(i=0;i<size-1;i++)
|
||||||
{
|
{
|
||||||
pfd[0].revents=0;
|
pfd[0].revents=0;
|
||||||
ready=poll(pfd,1,tcp_read_time_out);
|
ready=poll_retry(pfd,1,tcp_read_time_out);
|
||||||
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
||||||
return -1;
|
return -1;
|
||||||
else if(buff[i]=='\n')
|
else if(buff[i]=='\n')
|
||||||
@@ -142,10 +169,9 @@ static int read_n_bytes(int fd,char *buff, size_t size)
|
|||||||
|
|
||||||
pfd[0].fd=fd;
|
pfd[0].fd=fd;
|
||||||
pfd[0].events=POLLIN;
|
pfd[0].events=POLLIN;
|
||||||
for(i=0;i<size;i++)
|
for(i=0; i < size; i++) {
|
||||||
{
|
|
||||||
pfd[0].revents=0;
|
pfd[0].revents=0;
|
||||||
ready=poll(pfd,1,tcp_read_time_out);
|
ready=poll_retry(pfd,1,tcp_read_time_out);
|
||||||
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -162,31 +188,27 @@ static int timed_connect(int sock, const struct sockaddr *addr, unsigned int len
|
|||||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||||
ret=true_connect(sock, addr, len);
|
ret=true_connect(sock, addr, len);
|
||||||
// printf("\nconnect ret=%d\n",ret);fflush(stdout);
|
// printf("\nconnect ret=%d\n",ret);fflush(stdout);
|
||||||
if(ret==-1 && errno==EINPROGRESS)
|
if(ret==-1 && errno==EINPROGRESS) {
|
||||||
{
|
ret=poll_retry(pfd,1,tcp_connect_time_out);
|
||||||
ret=poll(pfd,1,tcp_connect_time_out);
|
//printf("\npoll ret=%d\n",ret);fflush(stdout);
|
||||||
// printf("\npoll ret=%d\n",ret);fflush(stdout);
|
if(ret == 1) {
|
||||||
if(ret==1)
|
|
||||||
{
|
|
||||||
value_len=sizeof(int);
|
value_len=sizeof(int);
|
||||||
getsockopt(sock,SOL_SOCKET,SO_ERROR,&value,&value_len) ;
|
getsockopt(sock,SOL_SOCKET,SO_ERROR,&value,&value_len) ;
|
||||||
// printf("\nvalue=%d\n",value);fflush(stdout);
|
//printf("\nvalue=%d\n",value);fflush(stdout);
|
||||||
if(!value)
|
if(!value)
|
||||||
ret=0;
|
ret=0;
|
||||||
else
|
else
|
||||||
ret=-1;
|
ret=-1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
ret=-1;
|
ret=-1;
|
||||||
}
|
}
|
||||||
else if (ret==0)
|
} else {
|
||||||
;
|
if (ret != 0)
|
||||||
else
|
|
||||||
ret=-1;
|
ret=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
||||||
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tunnel_to(int sock, unsigned int ip, unsigned short port, proxy_type pt,char *user,char *pass)
|
static int tunnel_to(int sock, unsigned int ip, unsigned short port, proxy_type pt,char *user,char *pass)
|
||||||
|
|||||||
@@ -138,16 +138,20 @@ static void init_lib(void)
|
|||||||
init_l = 1;
|
init_l = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX. Same thing is defined in proxychains main.c it
|
||||||
|
* needs to be changed, too.
|
||||||
|
*/
|
||||||
|
#define PROXYCHAINS_CONF_FILE "PROXYCHAINS_CONF_FILE"
|
||||||
|
|
||||||
static inline void get_chain_data(
|
static inline void get_chain_data(
|
||||||
proxy_data *pd,
|
proxy_data *pd,
|
||||||
unsigned int *proxy_count,
|
unsigned int *proxy_count,
|
||||||
chain_type *ct)
|
chain_type *ct)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int count=0,port_n=0,list=0;
|
int count=0,port_n=0,list=0;
|
||||||
char buff[1024],type[1024],host[1024],user[1024];
|
char buff[1024],type[1024],host[1024],user[1024];
|
||||||
|
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;
|
||||||
@@ -160,8 +164,17 @@ static inline void get_chain_data(
|
|||||||
tcp_connect_time_out=10*1000;
|
tcp_connect_time_out=10*1000;
|
||||||
*ct=DYNAMIC_TYPE;
|
*ct=DYNAMIC_TYPE;
|
||||||
|
|
||||||
|
env = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get path to configuration file from env this file has priority
|
||||||
|
* if it's defined.
|
||||||
|
*/
|
||||||
|
env = getenv(PROXYCHAINS_CONF_FILE);
|
||||||
|
|
||||||
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
||||||
|
|
||||||
|
if(!(file=fopen(env,"r")))
|
||||||
if(!(file=fopen("./proxychains.conf","r")))
|
if(!(file=fopen("./proxychains.conf","r")))
|
||||||
if(!(file=fopen(buff,"r")))
|
if(!(file=fopen(buff,"r")))
|
||||||
if(!(file=fopen("/etc/proxychains.conf","r")))
|
if(!(file=fopen("/etc/proxychains.conf","r")))
|
||||||
|
|||||||
+44
-7
@@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
main.c - description
|
main.c - description
|
||||||
-------------------
|
q -------------------
|
||||||
begin : Tue May 14 2002
|
begin : Tue May 14 2002
|
||||||
copyright : netcreature (C) 2002
|
copyright : netcreature (C) 2002
|
||||||
email : netcreature@users.sourceforge.net
|
email : netcreature@users.sourceforge.net
|
||||||
@@ -32,17 +32,54 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
extern char *optarg;
|
||||||
|
extern int optind, opterr, optopt
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX. Same thing is defined in proxychains main.c it
|
||||||
|
* needs to be changed, too.
|
||||||
|
*/
|
||||||
|
#define PROXYCHAINS_CONF_FILE "PROXYCHAINS_CONF_FILE"
|
||||||
|
|
||||||
|
static usage(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("\nUsage: %s [h] [f] config_file program_name [arguments]\n"
|
||||||
|
"\t for example : proxychains telnet somehost.com\n"
|
||||||
|
"More help in README file\n", argv[0], );
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if(argc<2)
|
char *path;
|
||||||
{
|
|
||||||
printf("\nUsage: proxychains program_name [arguments]\n"
|
path = NULL;
|
||||||
"\t for example : proxychains telnet somehost.com\n"
|
|
||||||
"More help in README file\n");
|
while ((opt = getopt(argc, argv, "fh:")) != -1) {
|
||||||
return 0 ;
|
switch (opt) {
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
path = (char *)optarg;
|
||||||
|
break;
|
||||||
|
default: /* '?' */
|
||||||
|
usage();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Proxychains are going to use %s as config file.\n", path);
|
||||||
|
printf("argv = %s\n", argv[1]);
|
||||||
|
|
||||||
|
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to
|
||||||
|
use new config file. */
|
||||||
|
setenv(PROXYCHAINS_CONF_FILE, path, 1);
|
||||||
|
|
||||||
|
/*XXX. proxychains might be installed in some different location */
|
||||||
putenv("LD_PRELOAD=/usr/lib/libproxychains.so");
|
putenv("LD_PRELOAD=/usr/lib/libproxychains.so");
|
||||||
execvp(argv[1],&argv[1]);
|
execvp(argv[1],&argv[1]);
|
||||||
perror("proxychains can't load process....");
|
perror("proxychains can't load process....");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-3
@@ -1,9 +1,26 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
|
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
|
||||||
if [ $# = 0 ] ; then
|
|
||||||
|
usage() {
|
||||||
|
|
||||||
echo " usage:"
|
echo " usage:"
|
||||||
echo " proxychains <prog> [args]"
|
echo " $0 [h] [f config-file] <prog> [args]"
|
||||||
exit
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# = 0 ] ; then
|
||||||
|
usage
|
||||||
fi
|
fi
|
||||||
export LD_PRELOAD=libproxychains.so
|
|
||||||
|
if [ $1 = "-h" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "-f" ]; then
|
||||||
|
export PROXYCHAINS_CONF_FILE=$2;
|
||||||
|
shift;
|
||||||
|
shift;
|
||||||
|
fi
|
||||||
|
|
||||||
|
export LD_PRELOAD=libproxychains.so.3
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user