
依存関係ゼロのWindows EDRユーティリティで、不正なLSASSメモリアクセス、ハンドル複製、LOLBinによる資格情報ダンプをリアルタイムで検出・緩和します。
不正なLSASSメモリアクセス、ハンドルの複製、およびLOLBinによる資格情報ダンプの試行をリアルタイムで検出・緩和する、軽量でゼロ依存のWindows EDRユーティリティ。
Windowsエンタープライズ環境では、Local Security Authority Subsystem Service (lsass.exe) がアクティブなユーザー資格情報、Kerberosチケット保証チケット (TGT)、およびNTLMパスワードハッシュを仮想メモリ内に保存しています。
LSASSはドメイン全体の鍵を握っているため、攻撃者やレッドチームは日常的に以下を用いてこれを標的にします:
PROCESS_VM_READ (0x0010) や PROCESS_ALL_ACCESS (0x1FFFFF) でハンドルを開く。rundll32.exe C:\Windows\System32\comsvcs.dll, MiniDump <lsass_pid> <dump_path> full や procdump.exe -ma lsass.exe。CrowdStrike Falcon や SentinelOne のような商用エンドポイント検出応答 (EDR) プラットフォームは、まさにこの手法 (MITRE ATT&CK T1003.001) から保護するために、エンタープライズサブスクリプションで数千ドルを請求します。
MemGuard は、ネイティブのWindows Win32およびNTカーネル構造を使用し、サードパーティ依存ゼロで完全に無料、オープンソース、かつ透過的なPython実装を提供します。
flowchart TD
subgraph Host ["Windows 11 / 10 Endpoint"]
Adversary["Attacker / LOLBin / Mimikatz / ProcDump"] -- OpenProcess (PROCESS_VM_READ) --> LSASS["lsass.exe (PID: 1744)"]
subgraph MemGuard ["MemGuard Defensive Engine"]
HScan["NtQuerySystemInformation\n(SystemExtendedHandleInformation)"] --> CheckMask{"Access Mask\nAnalysis"}
CheckMask -- "VM_READ / ALL_ACCESS" --> Alert1["🚨 Critical Alert:\nUnauthorized Handle"]
PEBScan["Process PEB Reader\n(NtQueryInformationProcess)"] --> LOLBinCheck{"CommandLine\nRegex Engine"}
LOLBinCheck -- "comsvcs.dll / procdump" --> Alert2["🚨 Critical Alert:\nLOLBin Dump Attempt"]
DumpWatch["Triage Directory\nArtifact Scanner"] --> MDMPCheck{"MDMP Header\nValidation"}
MDMPCheck -- "Valid LSASS .dmp" --> Alert3["🚨 Alert:\nRogue Dump File"]
Alert1 & Alert2 --> Mitigation["Active Mitigation:\nNtSuspendProcess (Freeze)"]
end
endNtQuerySystemInformation を SystemExtendedHandleInformation (クラス64) でクエリし、オペレーティングシステム全体で開かれているすべてのハンドルを列挙します。プロセスハンドルを複製し、そのターゲットがアクティブな lsass.exe PIDに解決されるかどうかを検証します。
各ハンドル保持者の32ビット GrantedAccess ビットマスクを分析します:
PROCESS_VM_READ (0x0010): CRITICAL (プロセスメモリの読み取り — 資格情報ダンプの前提条件)PROCESS_VM_WRITE (0x0020): HIGH (メモリインジェクション / シェルコード)PROCESS_VM_OPERATION (0x0008): HIGH (VirtualAllocEx / ページ保護の変更)PROCESS_CREATE_THREAD (0x0002): HIGH (リモートスレッドの作成)PROCESS_ALL_ACCESS (0x1FFFFF): CRITICAL (無制限の制御)既知の正規のWindowsシステムプロセス (services.exe、csrss.exe、wininit.exe、Windows Defender MsMpEng.exe) はホワイトリストに登録され、ダンプ可能なハンドルを保持する未検証のサードパーティプロセスは即座にフラグが立てられます。
NtQueryInformationProcess(ProcessBasicInformation) と ReadProcessMemory を介して仮想メモリから直接 Process Environment Block (PEB) を読み取ることで、実行中のプロセスを検査します:
PEB -> ProcessParameters -> CommandLine (UNICODE_STRING) を走査します。comsvcs.dll, #24、MiniDumpWriteDump、procdump -ma) を検出します。NtSuspendProcess)--suspend フラグを付けて実行すると、MemGuardはネイティブの ntdll.NtSuspendProcess を使用して問題のあるプロセスのスレッドをその場で凍結し、メモリ抽出を防ぎつつ、ライブフォレンジック分析のために攻撃者プロセスをRAM内に保持します。
pipインストールは不要です! クローンしてPython 3.8+で直接実行してください:
git clone https://github.com/prox0959/MemGuard.git
cd MemGuard
python memguard.py --scan
# Monitor system every 3 seconds
python memguard.py --monitor --interval 3
# Monitor with automatic active mitigation (freeze dumper processes)
python memguard.py --monitor --interval 2 --suspend
python memguard.py --scan --json incident_report.json
python memguard.py --scan --lang tr
███╗ ███╗███████╗███╗ ███╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝ ██║ ██║██╔══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗ ██╔████╔██║██║ ███╗██║ ██║███████║██████╔╝██║ ██║
██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║██║ ██║██╔══██║██╔══██╗██║ ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██║ ██║██║ ██║██████╔╝
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝
Zero-Dependency LSASS Memory Dump Shield & EDR Hook Detector | Pure Python
► MITRE ATT&CK: T1003.001 (OS Credential Dumping: LSASS Memory)
[*] Privilege Level: Elevated (Administrator) - Full Kernel Handle Access
[*] SeDebugPrivilege Status: Enabled Successfully
[*] Target Security Process Found: lsass.exe (PID: 1744) | Path: C:\Windows\System32\lsass.exe
--- LSASS Handle Table Audit (NtQuerySystemInformation) ---
✓ No unauthorized or suspicious handles targeting LSASS detected.
--- Process Heuristics & LOLBin CommandLine Inspection ---
✓ No credential dumping processes or LOLBin signatures found.
--- Dump File Artifacts & Honeypot Tripwire ---
✓ No rogue memory dump (.dmp) files identified in triage directories.
Audit Summary: 0 handle threats, 0 process threats, 0 dump artifacts.
MemGuard/
├── memguard.py # Main CLI entry point & real-time monitoring loop
├── core/
│ ├── __init__.py
│ ├── win_api.py # Native Win32/NT kernel ctypes prototypes & PEB reader
│ ├── handle_scanner.py # NtQuerySystemInformation handle table & access mask auditor
│ ├── process_auditor.py # Heuristic LOLBin cmdline inspection & parent verification
│ └── honey_dmp.py # MiniDump (.dmp) artifact validator
├── LICENSE # MIT License
├── README.md # Technical Documentation
└── requirements.txt # Zero dependencies notice
Çınar (@prox0959) によって開発されました。
低レベルのオペレーティングシステム内部、防御セキュリティ、およびWindowsメモリフォレンジックを研究している高校生です。
MIT License の下で配布されています。