1
0
mirror of https://github.com/rofl0r/proxychains-ng.git synced 2024-12-30 19:28:49 +00:00

connect(): handle ipv4-mapped ipv6 addresses

if an ipv4-mapped ipv6 address is detected, the ip is converted
into v4 format because it may actually be one of our remote dns ips.
it was reported that a program called "maven", when getting handed our
fake ips in the remote dns subnet, converts the ip to v6 prior to calling
connect():
[proxychains] Strict chain ... 127.0.0.1:1080 ... ::ffff:224.0.0.1:443
<--socket error or timeout!

fixes 
This commit is contained in:
rofl0r 2015-09-15 21:16:20 +01:00
parent 097c7f9125
commit 32df7ff152

View File

@ -307,7 +307,10 @@ int close(int fd) {
errno = EBADF;
return -1;
}
static int is_v4inv6(const struct in6_addr *a) {
return a->s6_addr32[0] == 0 && a->s6_addr32[1] == 0 &&
a->s6_addr16[4] == 0 && a->s6_addr16[5] == 0xffff;
}
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
INIT();
PFUNC();
@ -334,6 +337,12 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
p_addr_in6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
port = !v6 ? ntohs(((struct sockaddr_in *) addr)->sin_port)
: ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
struct in_addr v4inv6;
if(v6 && is_v4inv6(p_addr_in6)) {
memcpy(&v4inv6.s_addr, &p_addr_in6->s6_addr32[3], 4);
v6 = dest_ip.is_v6 = 0;
p_addr_in = &v4inv6;
}
// PDEBUG("localnet: %s; ", inet_ntop(AF_INET,&in_addr_localnet, str, sizeof(str)));
// PDEBUG("netmask: %s; " , inet_ntop(AF_INET, &in_addr_netmask, str, sizeof(str)));