Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
MemGuard — 零依赖 Windows EDR 工具,可实时检测并缓解未经授权的 LSASS 内存访问、句柄复制以及 LOLBin 凭据转储。 | Kitploit
工具/GitHubGitHub/prox0959/memguard
防御工具内存取证恶意软件分析数字取证入侵检测事件响应日志分析
GitHubprox0959/memguard

MemGuard

零依赖 Windows EDR 工具,可实时检测并缓解未经授权的 LSASS 内存访问、句柄复制以及 LOLBin 凭据转储。

查看仓库
1316小时27分前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

🛡️ MemGuard — 零依赖 LSASS 内存防护盾与 EDR 钩子检测器

Python Platform Dependencies MITRE ATT&CK License: MIT

一款轻量级、零依赖的 Windows EDR 实用工具,可实时检测并缓解未经授权的 LSASS 内存访问、句柄复制以及 LOLBin 凭据转储尝试。


📌 威胁概述:为什么要保护 LSASS?

在 Windows 企业环境中,本地安全机构子系统服务(lsass.exe) 会在其虚拟内存中存储活动用户凭据、Kerberos 票据授予票据(TGT)以及 NTLM 密码哈希。

由于 LSASS 掌握着整个域的密钥,攻击者和红队人员经常通过以下方式将其作为目标:

  1. 直接内存访问: 诸如 Mimikatz、Dumpert 或 NanoDump 之类的工具,使用 PROCESS_VM_READ(0x0010)或 PROCESS_ALL_ACCESS(0x1FFFFF)打开句柄。
  2. 离地攻击二进制文件(LOLBins): 滥用合法的 Windows 签名二进制文件进行转储,例如 rundll32.exe C:\Windows\System32\comsvcs.dll, MiniDump <lsass_pid> <dump_path> full 或 procdump.exe -ma lsass.exe。
  3. 句柄窃取: 从特权服务复制已打开的现有句柄,以绕过常规的 API 监控。

像 CrowdStrike Falcon 或 SentinelOne 这样的商业端点检测与响应(EDR)平台,会收取数千美元的企业订阅费用来防御这一特定技术(MITRE ATT&CK T1003.001)。

MemGuard 提供了一个完全免费、开源且透明的 Python 实现,使用原生 Windows Win32 和 NT 内核结构,且零第三方依赖。


⚙️ 架构与技术机制

root@kitploit:~
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
    end

1. NT 内核句柄枚举

使用 SystemExtendedHandleInformation(类 64)查询 NtQuerySystemInformation,以枚举整个操作系统中所有打开的句柄。它会复制进程句柄,并验证其目标是否解析为活动的 lsass.exe PID。

2. 访问掩码位域解码

分析每个句柄持有者的 32 位 GrantedAccess 位掩码:

  • PROCESS_VM_READ(0x0010):严重(读取进程内存——凭据转储的前提条件)
  • PROCESS_VM_WRITE(0x0020):高(内存注入 / shellcode)
  • PROCESS_VM_OPERATION(0x0008):高(VirtualAllocEx / 页面保护修改)
  • PROCESS_CREATE_THREAD(0x0002):高(远程线程创建)
  • PROCESS_ALL_ACCESS(0x1FFFFF):严重(不受限制的控制)

已知的合法 Windows 系统进程(services.exe、csrss.exe、wininit.exe、Windows Defender 的 MsMpEng.exe)会被列入白名单,而持有可转储句柄的未经验证的第三方进程会立即被标记。

3. 纯 Python PEB 命令行读取器

通过 NtQueryInformationProcess(ProcessBasicInformation) 和 ReadProcessMemory 直接从虚拟内存读取进程环境块(PEB) 来检查正在运行的进程:

  • 遍历 PEB -> ProcessParameters -> CommandLine (UNICODE_STRING)。
  • 检测经过混淆的 LOLBin 调用(comsvcs.dll, #24、MiniDumpWriteDump、procdump -ma)。
  • 零依赖 WMI、PowerShell 或外部模块!

4. 主动威胁冻结(NtSuspendProcess)

当使用 --suspend 标志运行时,MemGuard 会使用原生 ntdll.NtSuspendProcess 就地冻结违规进程的线程,阻止内存提取,同时将攻击者进程保留在 RAM 中以便进行实时取证分析。


🚀 安装与使用

无需 pip 安装!直接克隆并使用 Python 3.8+ 运行:

root@kitploit:~
git clone https://github.com/prox0959/MemGuard.git
cd MemGuard

1. 一次性安全分类扫描

root@kitploit:~
python memguard.py --scan

2. 持续实时 EDR 防护模式

root@kitploit:~
# 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

3. 导出取证事件报告(JSON)

root@kitploit:~
python memguard.py --scan --json incident_report.json

4. 双语 CLI 支持(英语 / 土耳其语)

root@kitploit:~
python memguard.py --scan --lang tr

📸 终端输出示例

root@kitploit:~
███╗   ███╗███████╗███╗   ███╗ ██████╗ ██╗   ██╗ █████╗ ██████╗ ██████╗ 
████╗ ████║██╔════╝████╗ ████║██╔════╝ ██║   ██║██╔══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║██║  ███╗██║   ██║███████║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██║   ██║██║   ██║██╔══██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██║  ██║██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝ 
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.

🛠️ 项目结构

root@kitploit:~
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 许可证 分发。

下载工具