Skip to content

Commit

Permalink
allow dynamic host for simple socks env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Apr 23, 2018
1 parent fbfdd99 commit f886100
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +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_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] "

Expand Down
12 changes: 9 additions & 3 deletions src/libproxychains.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,27 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ

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_ENV_VAR);
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));
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].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;
Expand Down

0 comments on commit f886100

Please sign in to comment.