mirror of
https://github.com/haad/proxychains
synced 2026-06-08 14:30:41 +00:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7a2b9d79a | |||
| f1ffbd4b94 | |||
| 87ec01c762 | |||
| 8df5b3f11d | |||
| 0416c2b7ea | |||
| 98e9326534 | |||
| 14e15aa2c1 | |||
| 9f99278525 | |||
| f3b07370fb | |||
| dbe328efdd | |||
| f88610077c | |||
| fbfdd995db | |||
| bd207014a2 | |||
| 2bdf74d5a6 | |||
| e8e0b93b37 | |||
| c38374ab5b | |||
| 67aa8eae24 | |||
| 0f61bd0713 | |||
| 581f0ff31a | |||
| 7d160b9015 | |||
| 138481b410 | |||
| bf833e216b | |||
| 60bcee08c9 | |||
| 8623b26a72 | |||
| 3b52a10c54 | |||
| ec404a9e61 | |||
| fdbce6cf24 | |||
| 0c39bb25a6 | |||
| a1ff3e0426 | |||
| 86dfc828f1 | |||
| 33805b3375 | |||
| dcbafb0279 | |||
| 93bbad6ccb | |||
| f52a3001e1 | |||
| 92ab117a9e | |||
| fb30a834a7 | |||
| caa76df519 | |||
| 2ac7066abd | |||
| d3516a1c28 | |||
| 7aa95f9304 | |||
| c4decf6da2 | |||
| 2eb641758b | |||
| 4678bae604 | |||
| 6fe50f2b29 | |||
| d69f46afc5 | |||
| f9a2ac0456 | |||
| 1c020ced1e | |||
| 361889a2d2 | |||
| 025840930b | |||
| cca0cea44a | |||
| 462e34f447 | |||
| e5ad6e53c3 |
@@ -4,6 +4,7 @@
|
||||
*.lo
|
||||
.deps/
|
||||
.libs/
|
||||
.*
|
||||
|
||||
# Autoconf stuff
|
||||
libtool
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
# Enable C support
|
||||
language: c
|
||||
|
||||
# OS selection
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
# Compiler selection
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
# Build steps
|
||||
script:
|
||||
- ./configure
|
||||
- make
|
||||
@@ -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, bsd support, packaging
|
||||
adam hamsik.
|
||||
https://github.com/haad/proxychains
|
||||
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
ProxyChains version history (public releases)
|
||||
====================
|
||||
|
||||
ver 4.2
|
||||
* Introduce BSD support make proxychains available on (NetBSD, FreeBSD ,OpenBSD and DragonFlyBSD)
|
||||
* Update pkgsrc-wip proxychains package to 4.2.0 release and make easy to install and use
|
||||
proxychains
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
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:
|
||||
|
||||
@@ -16,10 +16,11 @@ bindir = $(exec_prefix)/bin
|
||||
SRCS = $(sort $(wildcard src/*.c))
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
LOBJS = src/core.o src/common.o src/libproxychains.o
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
|
||||
LDFLAGS = -shared -fPIC -ldl -lpthread
|
||||
INC =
|
||||
CCFLAGS = -MD -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 +38,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)
|
||||
@@ -58,6 +59,7 @@ clean:
|
||||
rm -f $(ALL_LIBS)
|
||||
rm -f $(ALL_TOOLS)
|
||||
rm -f $(OBJS)
|
||||
rm -f $(DEPS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||
@@ -68,4 +70,6 @@ $(LDSO_PATHNAME): $(LOBJS)
|
||||
$(ALL_TOOLS): $(OBJS)
|
||||
$(CC) src/main.o src/common.o -o $(PXCHAINS)
|
||||
|
||||
.PHONY: all clean install install-config
|
||||
.PHONY: all clean install install-config
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
ProxyChains ver 4.0 README
|
||||
==========================
|
||||
|
||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||
in dynamically linked programs via a preloaded DLL and redirects the
|
||||
connections through SOCKS4a/5 or HTTP proxies.
|
||||
|
||||
*********** ATTENTION ***********
|
||||
|
||||
this program works only on dynamically linked programs.
|
||||
also both proxychains and the program to call must use
|
||||
the same dynamic linker (i.e. same libc)
|
||||
|
||||
*********************************
|
||||
|
||||
*** Known limitations of the current version: ***
|
||||
|
||||
when a process forks, does a DNS lookup in the child, and then uses
|
||||
the ip in the parent, the corresponding ip mapping will not be found.
|
||||
this is because the fork can't write back into the parents mapping table.
|
||||
IRSSI shows this behaviour, so you have to pass the resolved ip address
|
||||
to it. (you can use the proxyresolv script (requires "dig") to do so)
|
||||
|
||||
this means that you can't currently use tor onion urls for irssi.
|
||||
to solve this issue, an external data store (file, pipe, ...) has to
|
||||
manage the dns <-> ip mapping. of course there has to be proper locking.
|
||||
shm_open, mkstemp, are possible candidates for a file based approach,
|
||||
the other option is to spawn some kind of server process that manages the
|
||||
map lookups. since connect() etc are hooked, this must not be a TCP server.
|
||||
|
||||
I am reluctant on doing this change, because the described behaviour
|
||||
seems pretty idiotic (doing a fork only for a DNS lookup), and irssi
|
||||
is currently the only known affected program.
|
||||
|
||||
*** Installation ***
|
||||
|
||||
# needs a working C compiler, preferably gcc
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
|
||||
Version (4.x) removes the dnsresolver script which required a dynamically
|
||||
linked "dig" binary to be present with remote DNS lookup.
|
||||
this speeds up any operation involving DNS, as the old script had to use TCP.
|
||||
additionally it allows to use .onion urls when used with TOR.
|
||||
also it removed the broken autoconf build system with a simple Makefile.
|
||||
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
|
||||
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
|
||||
Auth-types: socks - "user/pass" , http - "basic".
|
||||
|
||||
When to use it ?
|
||||
1) When the only way to get "outside" from your LAN is through proxy server.
|
||||
2) To get out from behind restrictive firewall which filters outgoing ports.
|
||||
3) To use two (or more) proxies in chain:
|
||||
like: your_host <--> proxy1 <--> proxy2 <--> target_host
|
||||
4) To "proxify" some program with no proxy support built-in (like telnet)
|
||||
5) Access intranet from outside via proxy.
|
||||
5) To use DNS behind proxy.
|
||||
|
||||
Some cool features:
|
||||
|
||||
* This program can mix different proxy types in the same chain
|
||||
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
|
||||
* Different chaining options supported
|
||||
random order from the list ( user defined length of chain ).
|
||||
exact order (as they appear in the list )
|
||||
dynamic order (smart exclude dead proxies from chain)
|
||||
* You can use it with any TCP client application, even network scanners
|
||||
yes, yes - you can make portscan via proxy (or chained proxies)
|
||||
for example with Nmap scanner by fyodor (www.insecire.org/nmap).
|
||||
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
|
||||
* You can use it with servers, like squid, sendmail, or whatever.
|
||||
* DNS resolving through proxy.
|
||||
|
||||
|
||||
Configuration:
|
||||
--------------
|
||||
|
||||
proxychains looks for config file in following order:
|
||||
1) 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 **
|
||||
|
||||
**see more in /etc/proxychains.conf
|
||||
|
||||
Usage Example:
|
||||
|
||||
$ proxychains telnet targethost.com
|
||||
|
||||
in this example it will run telnet through proxy(or chained proxies)
|
||||
specified by proxychains.conf
|
||||
|
||||
Usage Example:
|
||||
|
||||
$ 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:
|
||||
|
||||
$ proxyresolv targethost.com
|
||||
|
||||
in this example it will resolve targethost.com through proxy(or chained proxies)
|
||||
specified by proxychains.conf
|
||||
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
= ProxyChains ver. 4.2.0 README
|
||||
|
||||
image:https://travis-ci.org/haad/proxychains.svg?branch=master["Build Status", link="https://travis-ci.org/haad/proxychains"]
|
||||
|
||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||
in dynamically linked programs via a preloaded DLL and redirects the
|
||||
connections through SOCKS4a/5 or HTTP proxies.
|
||||
|
||||
WARNING: this program works only on dynamically linked programs.
|
||||
also both proxychains and the program to call must use
|
||||
the same dynamic linker (i.e. same libc)
|
||||
|
||||
== Known limitations of the current version
|
||||
|
||||
when a process forks, does a DNS lookup in the child, and then uses
|
||||
the ip in the parent, the corresponding ip mapping will not be found,
|
||||
this is because the fork can't write back into the parents mapping table.
|
||||
IRSSI shows this behaviour, so you have to pass the resolved ip address
|
||||
to it. (you can use the proxyresolv script (requires "dig") to do so)
|
||||
|
||||
this means that you can't currently use tor onion urls for irssi.
|
||||
to solve this issue, an external data store (file, pipe, ...) has to
|
||||
manage the dns <-> ip mapping. of course there has to be proper locking.
|
||||
shm_open, mkstemp, are possible candidates for a file based approach,
|
||||
the other option is to spawn some kind of server process that manages the
|
||||
map lookups. since connect() etc are hooked, this must not be a TCP server.
|
||||
|
||||
I am reluctant on doing this change, because the described behaviour
|
||||
seems pretty idiotic (doing a fork only for a DNS lookup), and irssi
|
||||
is currently the only known affected program.
|
||||
|
||||
== Installation
|
||||
|
||||
=== 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
|
||||
make install
|
||||
in a wip/proxychains directory.
|
||||
|
||||
You can find out more about pkgsrc on link:www.pkgsrc.org[pkgsrc] and about pkgsrc-wip on
|
||||
link:http://pkgsrc-wip.sourceforge.net[Pkgsrc-wip homepage]
|
||||
|
||||
=== Installing on Mac OS X with homebrew
|
||||
|
||||
You can install current proxychains on Mac OS X with an homebrew. You have to
|
||||
download unofficial link:https://gist.github.com/3792521[homebrew formula] from
|
||||
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
|
||||
make
|
||||
sudo make install
|
||||
----
|
||||
|
||||
== Changelog
|
||||
|
||||
*Version (4.x)* removes the dnsresolver script which required a dynamically
|
||||
linked "dig" binary to be present with remote DNS lookup.
|
||||
this speeds up any operation involving DNS, as the old script had to use TCP.
|
||||
additionally it allows to use .onion urls when used with TOR.
|
||||
also it removed the broken autoconf build system with a simple Makefile.
|
||||
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
|
||||
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
|
||||
|
||||
* Auth-types
|
||||
** socks - "user/pass",
|
||||
** http - "basic"
|
||||
|
||||
== When to use it
|
||||
|
||||
* When the only way to get "outside" from your LAN is through proxy server.
|
||||
* To get out from behind restrictive firewall which filters outgoing ports.
|
||||
* To use two (or more) proxies in chain:
|
||||
----
|
||||
like: your_host <--> proxy1 <--> proxy2 <--> target_host
|
||||
----
|
||||
* To "proxify" some program with no proxy support built-in (like telnet)
|
||||
* Access intranet from outside via proxy.
|
||||
* To use DNS behind proxy.
|
||||
|
||||
=== Some cool features
|
||||
|
||||
* This program can mix different proxy types in the same chain
|
||||
----
|
||||
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
|
||||
----
|
||||
* Different chaining options supported
|
||||
random order from the list ( user defined length of chain ).
|
||||
exact order (as they appear in the list )
|
||||
dynamic order (smart exclude dead proxies from chain)
|
||||
* You can use it with any TCP client application, even network scanners
|
||||
yes, yes - you can make portscan via proxy (or chained proxies)
|
||||
for example with Nmap scanner by fyodor (www.insecire.org/nmap).
|
||||
----
|
||||
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
|
||||
----
|
||||
* You can use it with servers, like squid, sendmail, or whatever.
|
||||
* DNS resolving through proxy.
|
||||
|
||||
== Configuration
|
||||
|
||||
proxychains looks for configuration in the following order:
|
||||
|
||||
* SOCKS5 proxy port in environment variable ${PROXYCHAINS_SOCKS5}
|
||||
(if set, no further configuration will be searched)
|
||||
* file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
|
||||
provided as a -f argument to proxychains script or binary.
|
||||
* ./proxychains.conf
|
||||
* $(HOME)/.proxychains/proxychains.conf
|
||||
* /etc/proxychains.conf
|
||||
|
||||
see more in */etc/proxychains.conf*
|
||||
|
||||
=== Usage Example
|
||||
|
||||
----
|
||||
$ proxychains telnet targethost.com
|
||||
----
|
||||
|
||||
in this example it will run telnet through proxy(or chained proxies)
|
||||
specified by *proxychains.conf*
|
||||
|
||||
=== Usage Example
|
||||
|
||||
----
|
||||
$ 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
|
||||
|
||||
----
|
||||
$ proxyresolv targethost.com
|
||||
----
|
||||
|
||||
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.
|
||||
|
||||
=== Usage Example:
|
||||
|
||||
----
|
||||
$ export PROXY_DNS_SERVER=8.8.8.8
|
||||
$ proxychains telnet targethost.com
|
||||
----
|
||||
|
||||
in this example, it will telnet to targethost.com using the 8.8.8.8
|
||||
nameserver supplied by the user through the PROXY_DNS_SERVER
|
||||
@@ -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,22 +79,41 @@ 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
|
||||
[ -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=-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 -Wl,>>config.mak
|
||||
echo LD_SET_SONAME=-install_name,>>config.mak
|
||||
echo INSTALL_FLAGS=-m>>config.mak
|
||||
fi
|
||||
|
||||
if islinux ; then
|
||||
echo OS_LDFLAGS=-pthread -ldl -Wl,--no-as-needed>>config.mak
|
||||
echo LD_SET_SONAME=-Wl,-soname= >>config.mak
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
echo done, now run make \&\& make install
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
|
||||
char *path = default_path;
|
||||
if(check_path(path))
|
||||
return path;
|
||||
if (!pbuf)
|
||||
goto err;
|
||||
|
||||
// priority 1: env var PROXYCHAINS_CONF_FILE
|
||||
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||
@@ -45,6 +47,7 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
|
||||
if(check_path(path))
|
||||
return path;
|
||||
|
||||
err:
|
||||
perror("couldnt find configuration file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+8
-1
@@ -1,8 +1,15 @@
|
||||
#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_PORT_ENV_VAR "PROXYCHAINS_SOCKS5_PORT"
|
||||
#define PROXYCHAINS_SOCKS5_HOST_ENV_VAR "PROXYCHAINS_SOCKS5_HOST"
|
||||
#define PROXYCHAINS_DNS_ENV_VAR "PROXYCHAINS_DNS"
|
||||
#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);
|
||||
|
||||
+81
-51
@@ -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,7 +272,7 @@ 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));
|
||||
@@ -298,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;
|
||||
@@ -392,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;
|
||||
|
||||
|
||||
@@ -413,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
|
||||
@@ -506,6 +514,19 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
unsigned int get_rand_int(unsigned int range){
|
||||
static FILE *fp;
|
||||
unsigned int randval;
|
||||
if (!fp) {
|
||||
fp = fopen("/dev/urandom", "r");
|
||||
}
|
||||
if(fread(&randval, sizeof(randval), 1, fp)) {
|
||||
return (randval % range);
|
||||
} else {
|
||||
srand((unsigned int)time(NULL));
|
||||
return (rand() % range);
|
||||
}
|
||||
}
|
||||
|
||||
static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int proxy_count, unsigned int *offset) {
|
||||
unsigned int i = 0, k = 0;
|
||||
@@ -514,10 +535,10 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
|
||||
return NULL;
|
||||
switch (how) {
|
||||
case RANDOMLY:
|
||||
srand(time(NULL));
|
||||
|
||||
do {
|
||||
k++;
|
||||
i = 0 + (unsigned int) (proxy_count * 1.0 * rand() / (RAND_MAX + 1.0));
|
||||
i = 0 + get_rand_int(proxy_count);
|
||||
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
|
||||
break;
|
||||
case FIFOLY:
|
||||
@@ -552,8 +573,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)
|
||||
@@ -616,7 +636,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)))
|
||||
@@ -640,7 +660,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");
|
||||
@@ -715,6 +735,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
|
||||
static const ip_type local_host = { {127, 0, 0, 1} };
|
||||
|
||||
char hostname[256]; // default maximum length of hostname in linux
|
||||
struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data* data) {
|
||||
char buff[256];
|
||||
uint32_t i, hash;
|
||||
@@ -736,6 +757,12 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
|
||||
data->resolved_addr = inet_addr(buff);
|
||||
if(data->resolved_addr == (in_addr_t) (-1))
|
||||
data->resolved_addr = (in_addr_t) (local_host.as_int);
|
||||
|
||||
snprintf(hostname,sizeof hostname, "%s", name);
|
||||
data->hostent_space.h_name = hostname;
|
||||
data->hostent_space.h_length = sizeof (in_addr_t);
|
||||
data->hostent_space.h_addrtype = AF_INET;
|
||||
|
||||
return &data->hostent_space;
|
||||
}
|
||||
|
||||
@@ -802,6 +829,8 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
|
||||
|
||||
data->hostent_space.h_name = data->addr_name;
|
||||
data->hostent_space.h_length = sizeof(in_addr_t);
|
||||
data->hostent_space.h_addrtype = AF_INET;
|
||||
|
||||
return &data->hostent_space;
|
||||
|
||||
err_plus_unlock:
|
||||
@@ -819,7 +848,7 @@ void proxy_freeaddrinfo(struct addrinfo *res) {
|
||||
free(res);
|
||||
}
|
||||
|
||||
void proxy_getserverbyname(const char * service, struct servent *se_buf,
|
||||
void proxy_getservbyname(const char * service, struct servent *se_buf,
|
||||
char * buf, size_t buf_len, struct servent **se_result)
|
||||
{
|
||||
|
||||
@@ -829,22 +858,22 @@ void proxy_getserverbyname(const char * service, struct servent *se_buf,
|
||||
|
||||
#ifdef __APPLE__
|
||||
struct servent *se;
|
||||
#ifdef THREAD_SAFE
|
||||
|
||||
MUTEX_LOCK(&internal_getsrvbyname_lock);
|
||||
#endif
|
||||
if(service)
|
||||
if(service) {
|
||||
se = getservbyname(service, NULL);
|
||||
if (!se)
|
||||
memcpy(se_buf, se, buf_len);
|
||||
*se_result = se_buf;
|
||||
#ifdef THREAD_SAFE
|
||||
|
||||
if ( se != NULL ) {
|
||||
memcpy(se_buf, se, buf_len);
|
||||
*se_result = se_buf;
|
||||
} else {
|
||||
*se_result = NULL;
|
||||
}
|
||||
}
|
||||
MUTEX_UNLOCK(&internal_getsrvbyname_lock);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* __APPLE__ */
|
||||
}
|
||||
|
||||
|
||||
int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||
struct gethostbyname_data ghdata;
|
||||
struct addrinfo_data *space;
|
||||
@@ -857,21 +886,24 @@ 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)
|
||||
proxy_getserverbyname(service, &se_buf, buf, sizeof(buf), &se);
|
||||
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);
|
||||
@@ -889,14 +921,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;
|
||||
}
|
||||
|
||||
+16
-16
@@ -41,11 +41,9 @@ extern internal_ip_lookup_table internal_ips;
|
||||
|
||||
#ifdef THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
pthread_mutex_t internal_ips_lock;
|
||||
|
||||
#ifdef __APPLE__
|
||||
pthread_mutex_t internal_getsrvbyname_lock;
|
||||
#endif
|
||||
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)
|
||||
@@ -104,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);
|
||||
|
||||
|
||||
@@ -136,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)
|
||||
|
||||
+63
-12
@@ -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,9 +167,23 @@ 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) {
|
||||
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];
|
||||
@@ -174,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 */
|
||||
@@ -266,7 +279,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;
|
||||
}
|
||||
@@ -279,7 +292,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")) {
|
||||
@@ -293,9 +306,43 @@ 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;
|
||||
char *host_string;
|
||||
|
||||
if(proxychains_got_chain_data)
|
||||
return;
|
||||
|
||||
load_default_settings(ct);
|
||||
|
||||
port_string = getenv(PROXYCHAINS_SOCKS5_PORT_ENV_VAR);
|
||||
|
||||
if(!port_string)
|
||||
return;
|
||||
|
||||
host_string = getenv(PROXYCHAINS_SOCKS5_HOST_ENV_VAR);
|
||||
|
||||
if(!host_string)
|
||||
host_string = "127.0.0.1";
|
||||
|
||||
memset(pd, 0, sizeof(proxy_data));
|
||||
|
||||
pd[0].ps = PLAY_STATE;
|
||||
pd[0].ip.as_int = (uint32_t) inet_addr(host_string);
|
||||
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;
|
||||
@@ -424,7 +471,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];
|
||||
|
||||
+4
-3
@@ -28,7 +28,7 @@
|
||||
static int usage(char **argv) {
|
||||
printf("\nUsage:\t%s -q -f config_file program_name [arguments]\n"
|
||||
"\t-q makes proxychains quiet - this overrides the config setting\n"
|
||||
"\t-t allows to manually specify a configfile to use\n"
|
||||
"\t-f allows to manually specify a configfile to use\n"
|
||||
"\tfor example : proxychains telnet somehost.com\n" "More help in README file\n\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ static const char *dll_name = DLL_NAME;
|
||||
|
||||
static char own_dir[256];
|
||||
static const char *dll_dirs[] = {
|
||||
".",
|
||||
//".",
|
||||
own_dir,
|
||||
LIB_DIR,
|
||||
"/lib",
|
||||
@@ -52,7 +52,8 @@ static void set_own_dir(const char *argv0) {
|
||||
while(l && argv0[l - 1] != '/')
|
||||
l--;
|
||||
if(l == 0)
|
||||
memcpy(own_dir, ".", 2);
|
||||
//memcpy(own_dir, ".", 2);
|
||||
memcpy(own_dir, "/dev/null/", 2);
|
||||
else {
|
||||
memcpy(own_dir, argv0, l - 1);
|
||||
own_dir[l] = 0;
|
||||
|
||||
+10
-2
@@ -2,8 +2,12 @@
|
||||
# This script is called by proxychains to resolve DNS names
|
||||
|
||||
# DNS server used to resolve names
|
||||
DNS_SERVER=4.2.2.2
|
||||
|
||||
if [ -z "$PROXY_DNS_SERVER" ] ; then
|
||||
DNS_SERVER=208.67.222.222 # OpenDNS
|
||||
else
|
||||
DNS_SERVER=$PROXY_DNS_SERVER
|
||||
fi
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo " usage:"
|
||||
@@ -11,6 +15,10 @@ if [ $# = 0 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
awk 'BEGIN{ARGC=0} {for(i=2;i<=NF;i++){if($i==ARGV[1] && $1!~":"){print $1;found=1}} } END{exit found?0:1}' "$1" </etc/hosts
|
||||
if [ "$?" -eq "0" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
export LD_PRELOAD=libproxychains.so
|
||||
dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||
drill $1 @$DNS_SERVER -t | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||
|
||||
Reference in New Issue
Block a user