Merge pull request #1 from haad/master

parent repo commits
This commit is contained in:
tomsawyer 2012-10-15 03:20:27 -07:00
commit ed717c378d
5 changed files with 94 additions and 30 deletions

View File

@ -17,9 +17,9 @@ SRCS = $(sort $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o)
LOBJS = src/core.o src/common.o src/libproxychains.o
CCFLAGS = -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
LDFLAGS = -shared -Wl,--no-as-needed -fPIC -pthread -ldl
INC =
CCFLAGS = -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
LDFLAGS = -shared -fPIC
INC =
PIC = -fPIC
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
@ -37,9 +37,9 @@ ALL_LIBS = $(SHARED_LIBS)
PXCHAINS = proxychains4
ALL_TOOLS = $(PXCHAINS)
CCFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
LDFLAGS+=$(USER_LDFLAGS) $(MAC_LDFLAGS)
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(MAC_CFLAGS)
CCFLAGS+=$(USER_CFLAGS) $(OS_CFLAGS)
LDFLAGS+=$(USER_LDFLAGS) $(OS_LDFLAGS)
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(OS_CFLAGS)
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\" -DSYSCONFDIR=\"$(confdir)\"
all: $(ALL_LIBS) $(ALL_TOOLS)

33
README
View File

@ -37,13 +37,19 @@ ProxyChains ver 4.2.0 README
**** Using release version ****
Proxychains-4.2.0 are available with pkgsrc to everyone using it on Linux,
NetBSD, FreeBSD, OpenBSD, DragonFlyBSD or Mac OS X. You just need to install
pkgsrc-wip repository and run
pkgsrc-wip repository and run
make install
in a wip/proxychains directory.
You can find out more about pkgsrc on [www.pkgsrc.org] and about pkgsrc-wip on
You can find out more about pkgsrc on [www.pkgsrc.org] and about pkgsrc-wip on
[http://pkgsrc-wip.sourceforge.net].
**** Installing on Mac OS X with homebrew ****
You can install current proxychains on Mac OS X with an homebrew. You have to download unofficial homebrew formula from [https://gist.github.com/3792521] to your BREW_HOME
by default /usr/local/Library/Formula/ and run
brew install proxychains
**** Running Current Source code version ****
# needs a working C compiler, preferably gcc
./configure
@ -62,7 +68,7 @@ there's a ./configure script though for convenience.
it also adds support for a config file passed via command line switches/
environment variables.
Version (3.x) introduces support for DNS resolving through proxy
Version (3.x) introduces support for DNS resolving through proxy
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
Auth-types: socks - "user/pass" , http - "basic".
@ -94,12 +100,14 @@ Some cool features:
Configuration:
--------------
proxychains looks for config file in following order:
1) file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
proxychains looks for configuration in the following order:
1) SOCKS5 proxy port in environment variable ${PROXYCHAINS_SOCKS5}
(if set, no further configuration will be searched)
2) file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
provided as a -f argument to proxychains script or binary.
2) ./proxychains.conf
3) $(HOME)/.proxychains/proxychains.conf
4) /etc/proxychains.conf **
3) ./proxychains.conf
4) $(HOME)/.proxychains/proxychains.conf
5) /etc/proxychains.conf **
**see more in /etc/proxychains.conf
@ -114,7 +122,7 @@ Usage Example:
$ proxychains -f /etc/proxychains-other.conf targethost2.com
in this example it will use different configuration file then proxychains.conf
in this example it will use different configuration file then proxychains.conf
to connect to targethost2.com host.
Usage Example:
@ -124,3 +132,10 @@ Usage Example:
in this example it will resolve targethost.com through proxy(or chained proxies)
specified by proxychains.conf
Usage Example:
$ ssh -fN -D 4321 some.example.com
$ PROXYCHAINS_SOCKS5=4321 proxychains zsh
in this example, it will run a shell with all traffic proxied through
OpenSSH's "dynamic proxy" (SOCKS5 proxy) on localhost port 4321.

19
configure vendored
View File

@ -86,25 +86,32 @@ fi
echo CC?=$CC>config.mak
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
[ -z "$LDFLAGS" ] || echo USER_LDFLAGS?=$LDFLAGS>>config.mak
echo prefix=$prefix>>config.mak
echo exec_prefix=$exec_prefix>>config.mak
echo bindir=$bindir>>config.mak
echo libdir=$libdir>>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=-ldl -Wl,-install_name,>>config.mak
echo OS_CFLAGS+=-DIS_MAC=1 -arch x86_64 -arch i386 >>config.mak
echo OS_LDFLAGS+=-arch x86_64 -arch i386 -lpthread -ldl>>config.mak
echo LD_SET_SONAME=-Wl, -install_name,>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
fi
if islinux ; then
echo LD_SET_SONAME=-ldl
if islinux ; then
#echo OS_CFLAGS=
echo OS_LDFLAGS=-pthread -ldl >>config.mak
echo LD_SET_SONAME=-Wl,--no-as-needed -install_name, >>config.mak
fi
if isbsd ; then
if isbsd ; then
#echo OS_LDFLAGS=
#echo OS_CFLAGS
echo INSTALL_FLAGS=-m>>config.mak
echo LD_SET_SONAME=-Wl,-rpath,$libdir -install_name,>>config.mak
fi

View File

@ -1,6 +1,8 @@
#define PROXYCHAINS_CONF_FILE_ENV_VAR "PROXYCHAINS_CONF_FILE"
#define PROXYCHAINS_QUIET_MODE_ENV_VAR "PROXYCHAINS_QUIET_MODE"
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
#define PROXYCHAINS_SOCKS5_ENV_VAR "PROXYCHAINS_SOCKS5"
#define PROXYCHAINS_DNS_ENV_VAR "PROXYCHAINS_DNS"
#define LOG_PREFIX "[proxychains] "
#define PROXYCHAINS_VERSION_MAJOR 4

View File

@ -72,7 +72,9 @@ pthread_once_t init_once = PTHREAD_ONCE_INIT;
#endif
static int init_l = 0;
static void load_default_settings(chain_type *ct);
static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
static void simple_socks5_env(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
static void* load_sym(char* symname, void* proxyfunc) {
@ -101,6 +103,9 @@ static void do_init(void) {
MUTEX_INIT(&internal_getsrvbyname_lock, NULL);
#endif
/* check for simple SOCKS5 proxy setup */
simple_socks5_env(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
/* read the config file */
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
@ -162,6 +167,19 @@ open_config_file() {
return file;
}
/* default settings common to get_chain_data and simple_socks5_env */
static void load_default_settings(chain_type *ct) {
char *env;
tcp_read_time_out = 4 * 1000;
tcp_connect_time_out = 10 * 1000;
*ct = DYNAMIC_TYPE;
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
if(env && *env == '1')
proxychains_quiet_mode = 1;
}
/* get configuration from config file */
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
unsigned int count = 0;
@ -175,17 +193,11 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
if(proxychains_got_chain_data)
return;
//Some defaults
tcp_read_time_out = 4 * 1000;
tcp_connect_time_out = 10 * 1000;
*ct = DYNAMIC_TYPE;
load_default_settings(ct);
env = get_config_path(getenv(PROXYCHAINS_CONF_FILE_ENV_VAR), buff, sizeof(buff));
file = fopen(env, "r");
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
if(env && *env == '1')
proxychains_quiet_mode = 1;
while(fgets(buff, sizeof(buff), file)) {
if(buff[0] != '\n' && buff[strspn(buff, " ")] != '#') {
/* proxylist has to come last */
@ -294,9 +306,37 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
proxychains_got_chain_data = 1;
}
static void simple_socks5_env(proxy_data *pd, unsigned int *proxy_count, chain_type *ct) {
char *port_string;
if(proxychains_got_chain_data)
return;
load_default_settings(ct);
port_string = getenv(PROXYCHAINS_SOCKS5_ENV_VAR);
if(!port_string)
return;
memset(pd, 0, sizeof(proxy_data));
pd[0].ps = PLAY_STATE;
pd[0].ip.as_int = (uint32_t) inet_addr("127.0.0.1");
pd[0].port = htons((unsigned short) strtol(port_string, NULL, 0));
pd[0].pt = SOCKS5_TYPE;
proxychains_max_chain = 1;
if(getenv(PROXYCHAINS_DNS_ENV_VAR))
proxychains_resolver = 1;
*proxy_count = 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, socklen_t len) {
int socktype = 0, flags = 0, ret = 0;
socklen_t optlen = 0;
ip_type dest_ip;