Exploit databaseDownload repository ZIP
GH-77b084c651f84d76fe59d880f4600f96
genaforvena/mishe-tauftauf2shell
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files13
genaforvena/mishe-tauftauf2shellRevision 9edba631cfcf
- ↑..Parent directory
- evidence/
- check.sh
- clang-fixed-asan
- clang-fixed-plain
- clang-vuln-asan
- clang-vuln-plain
- driver-fixed.c
- driver-vuln.c
- gcc-fixed-asan
- gcc-fixed-plain
- gcc-vuln-asan
- gcc-vuln-plain
- run.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/frontier/ndpi2shell/harness/driver-fixed.c
C · 6,799 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.fixed"
int ndpi_json_string_escape(const char *src, int src_len, char *dst, int dst_max_len) {
int i = 0;
int j = 0;
// We need at least 3 bytes for an empty JSON string: "" and '\0'
if (dst_max_len < 3) {
if (dst_max_len > 0) dst[0] = '\0';
return -1; // Buffer too small
}
// Reserve 2 bytes at the end for the closing quote and null terminator
int safe_max_len = dst_max_len - 2;
// Opening quote
dst[j++] = '"';
for (i = 0; i < src_len; i++) {
u_char c = (u_char)src[i];
if (c <= 0x7E) {
// Handle characters requiring 2-byte escape sequences
if (c == '\\' || c == '"' || c == '/') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = c;
} else if (c == '\b') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'b';
} else if (c == '\t') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 't';
} else if (c == '\n') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'n';
} else if (c == '\f') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'f';
} else if (c == '\r') {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'r';
} else if (c < 0x20) {
// Hex escape non-printable ASCII control characters (\u00XX)
if (j + 6 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'u';
dst[j++] = '0';
dst[j++] = '0';
// Quick hex conversion
char hex[] = "0123456789abcdef";
dst[j++] = hex[(c >> 4) & 0x0F];
dst[j++] = hex[c & 0x0F];
} else {
// Printable ASCII
if (j + 1 > safe_max_len) goto overflow;
dst[j++] = c;
}
} else if (c == 0x7F) {
// Escape DEL character
if (j + 6 > safe_max_len) goto overflow;
dst[j++] = '\\';
dst[j++] = 'u';
dst[j++] = '0';
dst[j++] = '0';
dst[j++] = '7';
dst[j++] = 'f';
} else {
// Multi-byte UTF-8 Validation & Copying
// Note: Length check must happen BEFORE accessing lookahead buffer indices
if ((c >= 0xC2 && c <= 0xDF) && (src_len - i >= 2)) {
u_char c1 = (u_char)src[i+1];
if (c1 >= 0x80 && c1 <= 0xBF) {
if (j + 2 > safe_max_len) goto overflow;
dst[j++] = c;
dst[j++] = (char)c1;
i += 1;
continue;
}
}
else if ((c >= 0xE0 && c <= 0xEF) && (src_len - i >= 3)) {
u_char c1 = (u_char)src[i+1];
u_char c2 = (u_char)src[i+2];
if ((c1 >= 0x80 && c1 <= 0xBF) && (c2 >= 0x80 && c2 <= 0xBF)) {
// Exclude overlongs and surrogates for strict JSON validity
if (!((c == 0xE0 && c1 < 0xA0) || (c == 0xED && c1 > 0x9F))) {
if (j + 3 > safe_max_len) goto overflow;
dst[j++] = c;
dst[j++] = (char)c1;
dst[j++] = (char)c2;
i += 2;
continue;
}
}
}
else if ((c >= 0xF0 && c <= 0xF4) && (src_len - i >= 4)) {
u_char c1 = (u_char)src[i+1];
u_char c2 = (u_char)src[i+2];
u_char c3 = (u_char)src[i+3];
if ((c1 >= 0x80 && c1 <= 0xBF) && (c2 >= 0x80 && c2 <= 0xBF) && (c3 >= 0x80 && c3 <= 0xBF)) {
// Exclude overlongs and out-of-range codepoints (> U+10FFFF)
if (!((c == 0xF0 && c1 < 0x90) || (c == 0xF4 && c1 > 0x8F))) {
if (j + 4 > safe_max_len) goto overflow;
dst[j++] = c;
dst[j++] = (char)c1;
dst[j++] = (char)c2;
dst[j++] = (char)c3;
i += 3;
continue;
}
}
}
// If it falls through here, it's an invalid UTF-8 byte.
// Replace it with the standard Unicode Replacement Character (U+FFFD) encoded in UTF-8
if (j + 3 > safe_max_len) goto overflow;
dst[j++] = (char)0xEF;
dst[j++] = (char)0xBF;
dst[j++] = (char)0xBD;
}
}
// Closing quote and direct sequence termination
dst[j++] = '"';
dst[j] = '\0';
return j;
overflow:
// Graceful failure or fallback termination on overflow
if (j < dst_max_len) dst[j] = '\0';
return -1;
}
/* #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;
}