
의존성이 전혀 없는 Windows EDR 유틸리티로, 무단 LSASS 메모리 접근, 핸들 복제, LOLBin 자격 증명 덤프를 실시간으로 탐지하고 완화합니다.
무단 LSASS 메모리 접근, 핸들 복제, 그리고 LOLBin 자격 증명 덤프 시도를 실시간으로 탐지하고 완화하는 경량의 제로 의존성 Windows EDR 유틸리티입니다.
Windows 엔터프라이즈 환경에서 로컬 보안 기관 하위 시스템 서비스(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처럼 덤프에 악용되는 정상 서명된 Windows 바이너리입니다.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
endSystemExtendedHandleInformation(클래스 64)과 함께 NtQuerySystemInformation을 쿼리하여 운영 체제 전체에 걸쳐 열려 있는 모든 핸들을 열거합니다. 프로세스 핸들을 복제하고 대상이 활성 lsass.exe PID로 확인되는지 검증합니다.
각 핸들 보유자의 32비트 GrantedAccess 비트마스크를 분석합니다:
PROCESS_VM_READ(0x0010): 치명적 (프로세스 메모리 읽기 — 자격 증명 덤프의 전제 조건)PROCESS_VM_WRITE(0x0020): 높음 (메모리 주입 / 셸코드)PROCESS_VM_OPERATION(0x0008): 높음 (VirtualAllocEx / 페이지 보호 수정)PROCESS_CREATE_THREAD(0x0002): 높음 (원격 스레드 생성)PROCESS_ALL_ACCESS(0x1FFFFF): 치명적 (무제한 제어)알려진 정상 Windows 시스템 프로세스(services.exe, csrss.exe, wininit.exe, Windows Defender MsMpEng.exe)는 화이트리스트에 포함되며, 덤프 가능한 핸들을 보유한 검증되지 않은 서드파티 프로세스는 즉시 플래그됩니다.
NtQueryInformationProcess(ProcessBasicInformation)와 ReadProcessMemory를 통해 가상 메모리에서 직접 프로세스 환경 블록(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에 따라 배포됩니다.