Skip to content
prox0959Public

About

MemGuard v2.0 (by @prox0959) - Zero-dependency Windows EDR utility: NT kernel handle table auditor, NTDLL syscall hook detector & credential hardening engine (T1003.001).

Topics

Resources

Stars

19 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ MemGuard v2.0 β€” Zero-Dependency LSASS Memory Shield, Syscall Hook Detector & Hardening Engine

Author: Γ‡Δ±nar (@prox0959) Β· πŸ“§ prox0959@gmail.com

Version Author Python Platform Dependencies MITRE ATT&CK License: MIT

MemGuard v2.0 (developed by Γ‡Δ±nar / @prox0959) is a zero-dependency Windows Endpoint Detection and Response (EDR) utility written in pure Python (ctypes). It audits NT kernel handle tables, verifies ntdll.dll syscall stub integrity against on-disk PE headers, hunts in-memory LOLBin modules (comsvcs.dll / dbghelp.dll), evaluates OS credential hardening (RunAsPPL, Credential Guard, WDigest), and surgically neutralizes credential dumpers via DUPLICATE_CLOSE_SOURCE handle stripping and NtSuspendProcess.

MemGuard v2.0 Live Attack & Defense Demo


πŸ”₯ What's New in MemGuard v2.0?

Following global community feedback from SOC/CISO threat intelligence reports (VigilIntel), r/blueteamsec, and offensive security researchers, MemGuard v2.0 introduces 5 Defensive Layers:

  1. πŸ›‘οΈ Layer 1 β€” LSASS Hardening & Security Posture Auditor (core/hardening_auditor.py):
    • Audits RunAsPPL (Protected Process Light), Windows Defender Credential Guard (LsaCfgFlags), and WDigest Cleartext Password Caching (UseLogonCredential).
    • Computes an actionable 0–100 LSASS Hardening Score with CISO/SOC remediation commands.
  2. 🧬 Layer 2 β€” NTDLL Syscall Stub & Userland EDR Hook Detector (core/hook_detector.py):
    • Parses the clean on-disk C:\Windows\System32\ntdll.dll PE Export Address Table (EAT) in pure Python and compares the first 16 bytes of 9 critical NT syscalls (NtOpenProcess, NtReadVirtualMemory, NtDuplicateObject, NtQuerySystemInformation, etc.) against live RAM.
    • Extracts live x64 System Service Numbers (SSNs) and flags inline 0xE9 / 0xFF 0x25 JMP detours or direct syscall patches (MITRE T1562.001).
  3. ⚑ Layer 3 β€” Surgical Remote Handle Stripping (--strip-handles) & Kernel Handle Audit (core/handle_scanner.py):
    • Enumerates all system handles via NtQuerySystemInformation(SystemExtendedHandleInformation) for PROCESS_VM_READ (0x0010) and PROCESS_DUP_HANDLE (0x0040 Handle Stealing).
    • Active Handle Revocation: Uses DuplicateHandle(..., DUPLICATE_CLOSE_SOURCE) to forcefully close unauthorized lsass.exe handles inside the attacker's process without destroying forensic memory state!
  4. πŸ•΅οΈβ€β™‚οΈ Layer 4 β€” In-Memory LOLBin DLL Hunter & PEB Reader (core/process_auditor.py):
    • Defeats command-line spoofing by enumerating loaded DLL modules (TH32CS_SNAPMODULE) inside script hosts (rundll32.exe, powershell.exe, cmd.exe, wscript.exe, etc.) to catch stealthy in-memory loading of comsvcs.dll!
  5. 🍯 Layer 5 β€” Active MiniDump Canary Tripwire (--deploy-canary) & SHA-256 IOC Enrichment (core/honey_dmp.py):
    • Deploys a realistic MDMP decoy dump file in %TEMP% and monitors access timestamps while enriching all SOC/SIEM JSON alerts with cryptographic SHA-256 hashes.

βš™οΈ v2.0 Architecture & Defensive Workflow

flowchart TD
    subgraph Endpoint ["Windows 10 / 11 (x64) Endpoint"]
        Adversary["Attacker: Mimikatz / NanoDump / Direct Syscall / LOLBin"] --> LSASS["lsass.exe (Credentials & TGTs)"]
        
        subgraph MemGuard ["MemGuard v2.0 β€” 5-Layer EDR Engine (by @prox0959)"]
            L1["1. Hardening Auditor\n(RunAsPPL / CredGuard / WDigest)"] --> Score["0-100 Resilience Score"]
            L2["2. NTDLL Syscall Inspector\n(Disk PE vs. RAM Stubs & SSN)"] --> HookAlert["🚨 Detect Inline Hooks\n& Syscall Patches"]
            L3["3. Kernel Handle Scanner\n(SystemExtendedHandleInformation)"] --> HandleAlert["🚨 Detect VM_READ (0x0010)\n& DUP_HANDLE (0x0040)"]
            L4["4. PEB & In-Memory DLL Hunter\n(TH32CS_SNAPMODULE)"] --> DLLAlert["🚨 Detect Loaded comsvcs.dll\n& Obfuscated LOLBins"]
            L5["5. Canary Dump Tripwire\n(MDMP Header & Access Watch)"] --> DumpAlert["🚨 Detect Rogue .dmp\n& Canary Access"]
            
            HandleAlert & DLLAlert --> Mitigation["Active Mitigation:\nβ€’ DUPLICATE_CLOSE_SOURCE (Strip Handle)\nβ€’ NtSuspendProcess (Forensic Freeze)"]
        end
    end
Loading

πŸš€ Installation & Usage

Zero external dependencies! Clone and run directly with Python 3.8+ on Windows:

git clone https://github.com/prox0959/MemGuard.git
cd MemGuard

1. Full 5-Layer Security Audit (with Live Syscall Table)

python memguard.py --scan --show-syscalls

2. Active EDR Protection Mode (Strip Attacker Handles + Freeze Process)

python memguard.py --monitor --interval 2 --strip-handles --suspend

3. Deploy Deceptive MiniDump Canary Tripwire

python memguard.py --scan --deploy-canary

4. Export SOC / SIEM Incident Report (JSON with SHA-256 IOCs)

python memguard.py --scan --json soc_report.json

5. Bilingual CLI Support (English / Turkish)

python memguard.py --scan --show-syscalls --lang tr

πŸ“Έ v2.0 Terminal Output

β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘  β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β• 
β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•     β•šβ•β• β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•     β•šβ•β•β•β•  β•šβ•β•β•β•β•β•β•
MemGuard v2.0 - Zero-Dependency LSASS Memory Shield & Syscall Hook Detector
β–Ί Author: Γ‡Δ±nar (@prox0959) | prox0959@gmail.com | github.com/prox0959/MemGuard
β–Ί MITRE ATT&CK: T1003.001 (LSASS Memory) Β· T1055 (Process Injection) Β· T1562.001 (Unhooking)

[*] Privilege Level: Elevated (Administrator) - Full Kernel Handle Access
[*] SeDebugPrivilege Status: Enabled Successfully
[*] Target Security Process Found: lsass.exe (PID: 1388) | Path: C:\Windows\System32\lsass.exe

--- [1/5] LSASS Security Posture & OS Hardening Audit (RunAsPPL / Credential Guard / WDigest) ---
  [*] LSASS Hardening Score: 65/100 (MODERATE_POSTURE)
      β€’ LSASS Protected Process Light (RunAsPPL): ENABLED (RunAsPPL=1)
      β€’ Windows Defender Credential Guard (VBS): NOT CONFIGURED (LsaCfgFlags=0)
      β€’ WDigest Cleartext Password Caching: DISABLED (Secure) (UseLogonCredential=0)

--- [2/5] NTDLL Syscall Stub & Userland EDR Hook Integrity (Disk vs. Memory) ---
  βœ“ All 9 critical NTDLL syscall stubs match clean on-disk PE prologues (0 inline hooks).
    Verified Syscall IDs (SSN): NtOpenProcess=0x26, NtReadVirtualMemory=0x3f, NtDuplicateObject=0x3c ...

--- [3/5] LSASS Kernel Handle Table Audit (NtQuerySystemInformation) ---
  βœ“ No unauthorized or suspicious handles targeting LSASS detected.

--- [4/5] PEB CommandLine & In-Memory LOLBin DLL Hunter (comsvcs.dll / dbghelp.dll) ---
  βœ“ No credential dumping processes, LOLBin cmdlines, or in-memory comsvcs.dll modules found.

--- [5/5] Dump File Artifacts & Active Canary Tripwire ---
  βœ“ No rogue memory dump (.dmp) files identified in triage directories.

Audit Summary: Hardening 65/100 | 0 Hook Anomalies | 0 Handle Threats | 0 Process/DLL Threats | 0 Dump Artifacts

πŸ—ΊοΈ MITRE ATT&CK Mapping

Technique ID Technique Name MemGuard v2.0 Detection & Mitigation Mechanism
T1003.001 OS Credential Dumping: LSASS Memory NtQuerySystemInformation handle table audit (PROCESS_VM_READ / 0x0010), In-Memory comsvcs.dll DLL scanner, and DUPLICATE_CLOSE_SOURCE handle stripping
T1562.001 Impair Defenses: Disable or Modify Tools (Unhooking) Disk vs. RAM ntdll.dll PE Export Table syscall stub verification & SSN decoding
T1055 Process Injection Access mask bitfield inspection (PROCESS_VM_WRITE, PROCESS_CREATE_THREAD) & NtCreateThreadEx hook check
T1036.005 Masquerading: Match Legitimate Name or Location Strict C:\Windows\System32 path & wininit.exe parent PID verification for lsass.exe and whitelisted services

πŸ› οΈ Project Structure

MemGuard/
β”œβ”€β”€ memguard.py               # Main CLI entry point & 5-layer real-time EDR loop
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ win_api.py            # Native Win32/NT ctypes bridge, PEB reader & DUPLICATE_CLOSE_SOURCE
β”‚   β”œβ”€β”€ hardening_auditor.py  # RunAsPPL, Credential Guard & WDigest registry posture scorer
β”‚   β”œβ”€β”€ hook_detector.py      # Pure Python PE EAT parser & NTDLL syscall stub integrity engine
β”‚   β”œβ”€β”€ handle_scanner.py     # SystemExtendedHandleInformation auditor & SHA-256 IOC enricher
β”‚   β”œβ”€β”€ process_auditor.py    # PEB command-line regex engine & In-Memory comsvcs.dll DLL hunter
β”‚   └── honey_dmp.py          # MiniDump (.dmp) artifact validator & active canary deployer
β”œβ”€β”€ LICENSE                   # MIT License
β”œβ”€β”€ README.md                 # Documentation
└── requirements.txt          # Zero external dependencies

πŸ‘€ Author & Contact


βš–οΈ License

Distributed under the MIT License.

About

MemGuard v2.0 (by @prox0959) - Zero-dependency Windows EDR utility: NT kernel handle table auditor, NTDLL syscall hook detector & credential hardening engine (T1003.001).

Topics

Resources

Stars

19 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages