1
0
mirror of https://github.com/rofl0r/proxychains-ng synced 2025-01-04 19:22:52 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
gijsh
457e682491
Merge 3ab15aa05c into fffd2532ad 2024-06-13 01:51:23 +00:00
rofl0r
fffd2532ad fix wrong prototype of freeaddrinfo_t
closes #557
2024-03-14 20:11:58 +00:00
Gijs Hollestelle
3ab15aa05c Preserve dnat mapping when used with localnet.
This allows using proxychains as a means of just changing the
destination IP and port of network traffic similar to iptables DNAT
without the need for root permissions.

Example usage:

localnet 127.0.0.0/8
dnat 1.1.1.1:1234 127.0.0.1:8123

This will redirect traffic to 1.1.1.1 on port 1234 to 127.0.0.1:8123.
2022-09-14 13:35:36 +02:00
2 changed files with 5 additions and 1 deletions

View File

@ -103,7 +103,7 @@ typedef int (*close_t)(int);
typedef int (*close_range_t)(unsigned, unsigned, int);
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
typedef struct hostent* (*gethostbyname_t)(const char *);
typedef int (*freeaddrinfo_t)(struct addrinfo *);
typedef void (*freeaddrinfo_t)(struct addrinfo *);
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,

View File

@ -745,6 +745,10 @@ HOOKFUNC(int, connect, int sock, const struct sockaddr *addr, unsigned int len)
if((p_addr_in->s_addr ^ localnet_addr[i].in_addr.s_addr) & localnet_addr[i].in_mask.s_addr)
continue;
}
if (!v6 && dnat) {
memcpy(&((struct sockaddr_in *) addr)->sin_addr, p_addr_in, sizeof(*p_addr_in));
((struct sockaddr_in *) addr)->sin_port = htons(port);
}
PDEBUG("accessing localnet using true_connect\n");
return true_connect(sock, addr, len);
}