mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-01-02 15:12:13 +00:00
introduce HOOKFUNC macro to mark all libc hook functions
this is currently a NO-OP, but it's already useful in that it clearly marks our hook functions that override libc. this in preparation of adding support for MacOS 12.0.1 "Monterey", which apparently requires a new dynlinker hooking method.
This commit is contained in:
parent
063ac681da
commit
d415d8a5ed
@ -537,7 +537,10 @@ inv_host:
|
|||||||
|
|
||||||
/******* HOOK FUNCTIONS *******/
|
/******* HOOK FUNCTIONS *******/
|
||||||
|
|
||||||
int close(int fd) {
|
#define EXPAND( args...) args
|
||||||
|
#define HOOKFUNC(R, N, args...) R N ( EXPAND(args) )
|
||||||
|
|
||||||
|
HOOKFUNC(int, close, int fd) {
|
||||||
if(!init_l) {
|
if(!init_l) {
|
||||||
if(close_fds_cnt>=(sizeof close_fds/sizeof close_fds[0])) goto err;
|
if(close_fds_cnt>=(sizeof close_fds/sizeof close_fds[0])) goto err;
|
||||||
close_fds[close_fds_cnt++] = fd;
|
close_fds[close_fds_cnt++] = fd;
|
||||||
@ -558,7 +561,8 @@ int close(int fd) {
|
|||||||
static int is_v4inv6(const struct in6_addr *a) {
|
static int is_v4inv6(const struct in6_addr *a) {
|
||||||
return !memcmp(a->s6_addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
|
return !memcmp(a->s6_addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
|
||||||
}
|
}
|
||||||
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
|
||||||
|
HOOKFUNC(int, connect, int sock, const struct sockaddr *addr, unsigned int len) {
|
||||||
INIT();
|
INIT();
|
||||||
PFUNC();
|
PFUNC();
|
||||||
|
|
||||||
@ -649,13 +653,13 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IS_SOLARIS
|
#ifdef IS_SOLARIS
|
||||||
int __xnet_connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
HOOKFUNC(int, __xnet_connect, int sock, const struct sockaddr *addr, unsigned int len)
|
||||||
return connect(sock, addr, len);
|
return connect(sock, addr, len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct gethostbyname_data ghbndata;
|
static struct gethostbyname_data ghbndata;
|
||||||
struct hostent *gethostbyname(const char *name) {
|
HOOKFUNC(struct hostent*, gethostbyname, const char *name) {
|
||||||
INIT();
|
INIT();
|
||||||
PDEBUG("gethostbyname: %s\n", name);
|
PDEBUG("gethostbyname: %s\n", name);
|
||||||
|
|
||||||
@ -669,7 +673,7 @@ struct hostent *gethostbyname(const char *name) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
HOOKFUNC(int, getaddrinfo, const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||||
INIT();
|
INIT();
|
||||||
PDEBUG("getaddrinfo: %s %s\n", node ? node : "null", service ? service : "null");
|
PDEBUG("getaddrinfo: %s %s\n", node ? node : "null", service ? service : "null");
|
||||||
|
|
||||||
@ -679,7 +683,7 @@ int getaddrinfo(const char *node, const char *service, const struct addrinfo *hi
|
|||||||
return true_getaddrinfo(node, service, hints, res);
|
return true_getaddrinfo(node, service, hints, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeaddrinfo(struct addrinfo *res) {
|
HOOKFUNC(void, freeaddrinfo, struct addrinfo *res) {
|
||||||
INIT();
|
INIT();
|
||||||
PDEBUG("freeaddrinfo %p \n", (void *) res);
|
PDEBUG("freeaddrinfo %p \n", (void *) res);
|
||||||
|
|
||||||
@ -689,7 +693,7 @@ void freeaddrinfo(struct addrinfo *res) {
|
|||||||
proxy_freeaddrinfo(res);
|
proxy_freeaddrinfo(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
HOOKFUNC(int, getnameinfo, const struct sockaddr *sa, socklen_t salen,
|
||||||
char *host, socklen_t hostlen, char *serv,
|
char *host, socklen_t hostlen, char *serv,
|
||||||
socklen_t servlen, int flags)
|
socklen_t servlen, int flags)
|
||||||
{
|
{
|
||||||
@ -733,7 +737,7 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
HOOKFUNC(struct hostent*, gethostbyaddr, const void *addr, socklen_t len, int type) {
|
||||||
INIT();
|
INIT();
|
||||||
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
||||||
|
|
||||||
@ -769,7 +773,7 @@ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
|||||||
# define MSG_FASTOPEN 0x20000000
|
# define MSG_FASTOPEN 0x20000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
HOOKFUNC(ssize_t, sendto, int sockfd, const void *buf, size_t len, int flags,
|
||||||
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
||||||
INIT();
|
INIT();
|
||||||
PFUNC();
|
PFUNC();
|
||||||
|
Loading…
Reference in New Issue
Block a user