allow non-numeric proxy ips under certain circumstances

conditions that need to be met are:
1) chaintype strict
2) proxy_dns on
3) not the first proxy in the list

if these conditions are met, the dns name can be passed to be
receiving proxy and be resolved there.

addressing https://github.com/rofl0r/proxychains-ng/issues/246#issuecomment-468222637
This commit is contained in:
rofl0r 2019-02-28 14:07:08 +00:00
parent 9f17774b99
commit b8cdfe842c

View File

@ -256,6 +256,10 @@ inv_string:
return 0; return 0;
} }
static const char* bool_str(int bool_val) {
if(bool_val) return "true";
return "false";
}
/* get configuration from config file */ /* get configuration from config file */
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) { static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
@ -311,9 +315,21 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
pd[count].port = htons((unsigned short) port_n); pd[count].port = htons((unsigned short) port_n);
ip_type* host_ip = &pd[count].ip; ip_type* host_ip = &pd[count].ip;
if(1 != inet_pton(host_ip->is_v6 ? AF_INET6 : AF_INET, host, host_ip->addr.v6)) { if(1 != inet_pton(host_ip->is_v6 ? AF_INET6 : AF_INET, host, host_ip->addr.v6)) {
if(*ct == STRICT_TYPE && proxychains_resolver && count > 0) {
/* we can allow dns hostnames for all but the first proxy in the list if chaintype is strict, as remote lookup can be done */
ip_type4 internal_ip = at_get_ip_for_host(host, strlen(host));
pd[count].ip.is_v6 = 0;
host_ip->addr.v4 = internal_ip;
if(internal_ip.as_int == ip_type_invalid.addr.v4.as_int)
goto inv_host;
} else {
inv_host:
fprintf(stderr, "proxy %s has invalid value or is not numeric\n", host); fprintf(stderr, "proxy %s has invalid value or is not numeric\n", host);
fprintf(stderr, "non-numeric ips are only allowed under the following circumstances:\n");
fprintf(stderr, "chaintype == strict (%s), proxy is not first in list (%s), proxy_dns active (%s)\n\n", bool_str(*ct == STRICT_TYPE), bool_str(count > 0), bool_str(proxychains_resolver));
exit(1); exit(1);
} }
}
if(!strcmp(type, "http")) { if(!strcmp(type, "http")) {
pd[count].pt = HTTP_TYPE; pd[count].pt = HTTP_TYPE;