mirror of
https://github.com/haad/proxychains.git
synced 2026-09-13 18:45:50 +05:00
Merge pull request #30 from benizi/add-socks5-mode
Add simple SOCKS5 mode
This commit is contained in:
commit
caa76df519
19
README
19
README
@ -100,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
|
||||
|
||||
@ -130,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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,6 +306,34 @@ 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, socklen_t len) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user