SiteQ8/PowerShield

GitHub: SiteQ8/PowerShield

企业级 Windows Server 安全加固框架,基于 CIS/NIST/STIG 标准自动化执行 120+ 项合规检查并支持一键修复。

Stars: 0 | Forks: 0

PowerShield
[![Version](https://img.shields.io/badge/version-2.0-0078d4?style=flat-square)]() [![License](https://img.shields.io/badge/license-MIT-0078d4?style=flat-square)](LICENSE) [![Windows Server](https://img.shields.io/badge/Server-2019%20|%202022-0078d4?style=flat-square)]() [![CIS](https://img.shields.io/badge/CIS-aligned-0078d4?style=flat-square)]() [![NIST](https://img.shields.io/badge/NIST_800--53-aligned-0078d4?style=flat-square)]() [![DISA STIG](https://img.shields.io/badge/DISA_STIG-aligned-0078d4?style=flat-square)]() [![PowerShell](https://img.shields.io/badge/PowerShell-5.1+-0078d4?style=flat-square&logo=powershell&logoColor=white)]() **Windows Server 企业级安全基线执行工具。** [文档](#deployment) · [模块](#hardening-modules) · [标准](#compliance-alignment) · [报告](#reporting) · [贡献](#contributing)
## 概述 PowerShield 是一个开源的 PowerShell 加固框架,适用于 Windows Server 2019 和 2022。它在 **12 个模块**中执行 **120 多项安全检查**,符合 CIS Benchmark、NIST SP 800-53、DISA STIG 和 Microsoft Security Baselines。 该工具以三种模式运行:**audit**(只读评估)、**fix**(自动修复并在更改前备份)和 **dry-run**(更改预览)。所有发现均导出为 HTML、CSV 和 JSON 报告,包含合规性评分和执行摘要。 ### 设计原则 - **零依赖** — 纯 PowerShell 5.1+。无外部模块、代理或框架。 - **默认非破坏性** — Audit 模式不进行任何系统更改。每次修复都会备份。 - **标准映射** — 每项检查都引用特定的 CIS、NIST 或 STIG 控制标识符。 - **企业级报告** — HTML 用于管理,CSV 用于 GRC 平台,JSON 用于自动化流水线。 - **模块化执行** — 运行完整评估或针对单个模块。 ## 部署 ### 前置条件 - Windows Server 2019 或 2022 - PowerShell 5.1 或更高版本 - 管理员权限 - 无外部模块依赖 ### 安装 ``` git clone https://github.com/SiteQ8/PowerShield.git cd PowerShield ``` ### 执行 ``` # 仅审计 — 只读评估,无系统修改 .\PowerShield.ps1 -Audit # 审计与自动修复 .\PowerShield.ps1 -Fix # 应用前预览所有更改 .\PowerShield.ps1 -DryRun # Target specific modules .\PowerShield.ps1 -Module Firewall,Services,TLSCrypto # 应用 CIS Level 2 profile .\PowerShield.ps1 -Fix -Profile level2 ``` ### 参数 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `-Audit` | Switch | 只读评估。无系统更改。默认模式。 | | `-Fix` | Switch | 评估并应用修复。在更改前备份配置。 | | `-DryRun` | Switch | 预览所有更改而不应用它们。 | | `-Profile` | String | 合规性配置文件:`level1`、`level2`、`stig`。默认:`level1`。 | | `-Module` | String[] | 按名称运行特定模块(逗号分隔)。 | | `-Report` | Switch | 生成 HTML 报告(默认自动生成)。 | | `-Version` | Switch | 显示版本号。 | | `-Help` | Switch | 显示使用信息。 | ## 加固模块 | 模块 | CIS 参考 | NIST 系列 | 检查项 | 描述 | |--------|---------------|-------------|--------|-------------| | **Account Policies** | 1.1–1.2 | IA | 9 | 密码策略(历史记录、期限、长度、复杂性、可逆加密)和账户锁定(阈值、持续时间、重置计数器) | | **Local Policies** | 2.2–2.3 | AC, IA | 12 | Administrator/Guest 账户、空密码限制、SMB 签名、SAM 枚举、NTLMv2 强制执行、UAC、非活动超时 | | **Advanced Audit Policy** | 17 | AU | 15 | 15 个子类别:凭据验证、账户管理、进程创建、登录/注销、特权使用、策略更改、系统完整性 | | **Windows Firewall** | 9 | SC | 12 | 域/专用/公用配置文件 — 启用状态、默认入站操作、出站操作、日志记录 | | **Defender and Exploit Guard** | 18.9.47 | SI | 10 | 实时保护、行为监控、PUA、IOAV、MAPS、签名更新、ASLR、Credential Guard | | **Network Security** | 18.4 | SC, AC | 8 | 禁用 SMBv1、SMB 加密、WinRM、LLMNR、NetBIOS、IPv6、带 NLA 的 RDP | | **Windows Services** | 5 | CM | 20 | 20 个不必要的服务:IIS、FTP、SNMP、UPnP、SSDP、Xbox、WSL、移动热点、媒体共享 | | **Registry Hardening** | 18 | CM | 14 | LSA 保护、WDigest、SEHOP、PowerShell 日志记录、AlwaysInstallElevated、Remote Credential Guard | | **Event Log Configuration** | 18.9.26 | AU | 6 | 应用程序/安全/系统/设置日志大小调整、Sysmon 检测、PowerShell 模块日志记录 | | **TLS and Cryptography** | — | SC-13 | 12+ | 弃用 SSL 2.0/3.0 和 TLS 1.0/1.1,强制 TLS 1.2/1.3,消除弱密码 | | **Windows Update** | 18.9.108 | SI | 3 | 自动更新策略、补丁时效、待重启检测 | | **Additional Hardening** | — | CM | 7 | 登录横幅、AutoPlay、BitLocker、Print Spooler、管理共享、Spectre/Meltdown、本地管理员计数 | ## 合规性对标 | 标准 | 覆盖范围 | 应用 | |----------|----------|-------------| | **CIS Benchmark for Windows Server 2019/2022** | Level 1 + Level 2 | 账户策略、本地策略、审核配置、防火墙、服务、注册表、事件日志、更新策略 | | **NIST SP 800-53 Revision 5** | AC, AU, CM, IA, SC, SI | 访问控制、审核和问责、配置管理、标识和身份验证、系统保护、信息完整性 | | **DISA STIG** | CAT I, II, III | LSA 保护、WDigest、Credential Guard、SEHOP、TLS 配置、密码套件、BitLocker、管理共享 | | **Microsoft Security Baselines** | Server 2019 / 2022 | Microsoft 推荐的注册表设置、组策略配置、Windows Defender 策略 | ## 报告 PowerShield 每次执行都会生成三种报告格式: | 格式 | 位置 | 用途 | |--------|----------|---------| | **HTML** | `C:\PowerShield\Logs\` | 带有颜色标记的结果、合规性评分和执行摘要的可视化报告。适用于管理和审核审查。 | | **CSV** | `C:\PowerShield\Logs\` | 结构化表格导出,用于 GRC 平台、SIEM 集成和基于电子表格的跟踪。 | | **JSON** | `C:\PowerShield\Logs\` | 包含完整系统元数据、摘要统计和各项检查结果的机器可读输出,用于 API 集成和 CI/CD 流水线。 | 配置备份存储在 `C:\PowerShield\Backups\` 中,带有时间戳,可以回滚任何修复过的设置。 ## 输出格式 ``` [PASS] CIS 1.1.5 — Password complexity: Enabled [FAIL] CIS 18.4.x — SMBv1: Enabled (critical — disable immediately) [WARN] NIST — Sysmon: Not detected (recommended for advanced logging) EXECUTIVE SUMMARY ───────────────────────────────────────────── System: DC01 (Windows Server 2022 Datacenter) Domain: CORP.LOCAL Compliance: 74.8% Critical Gaps: 3 ═══════════════════════════════════════════════════ PowerShield Hardening Summary ═══════════════════════════════════════════════════ PASS: 89 FAIL: 18 WARN: 12 TOTAL: 119 Score: 74.8% — Needs improvement Log: C:\PowerShield\Logs\PowerShield-20260309-143022.log Report: C:\PowerShield\Logs\PowerShield-Report-20260309-143022.html Backup: C:\PowerShield\Backups\20260309-143022 ═══════════════════════════════════════════════════ ``` ## 架构 ``` PowerShield.ps1 ├── Parameter validation and initialization ├── Banner display and environment detection ├── Module execution (sequential or targeted) │ ├── Module 01: Account Policies (secedit export) │ ├── Module 02: Local Policies (registry queries) │ ├── Module 03: Advanced Audit Policy (auditpol queries) │ ├── Module 04: Windows Firewall (Get-NetFirewallProfile) │ ├── Module 05: Defender / Exploit Guard (Get-MpPreference) │ ├── Module 06: Network Security (Get-SmbServerConfiguration) │ ├── Module 07: Windows Services (Get-Service) │ ├── Module 08: Registry Hardening (Get-ItemProperty) │ ├── Module 09: Event Log Configuration (Get-WinEvent) │ ├── Module 10: TLS / Cryptography (SCHANNEL registry) │ ├── Module 11: Windows Update (Get-HotFix) │ └── Module 12: Additional Hardening (mixed) ├── Report generation (HTML, CSV, JSON) ├── Executive summary with critical findings └── Compliance scoring and summary output ``` ## 免责声明 PowerShield 在使用 `-Fix` 参数执行时会修改 Windows 注册表和系统设置。组织应: 1. 在生产环境中首先使用 `-Audit` 模式进行初始评估 2. 在应用更改之前使用 `-DryRun` 验证修复影响 3. 在非生产环境中测试所有修复 4. 在执行前后验证 `C:\PowerShield\Backups\` 中的备份 5. 维护文档化的变更管理程序 本工具根据 MIT License 按“原样”提供。作者不对加固操作引起的系统中断承担任何责任。 ## 贡献 接受以下方面的贡献: - 额外的 CIS、NIST 或 STIG 控制实现 - Pester 测试框架集成 - 对 Windows Server 2025 的支持 - PowerShell Gallery 打包 - 模块级文档 请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 了解编码标准和提交指南。 ## 许可证 MIT License — 详见 [LICENSE](LICENSE)。
PowerShield — Enterprise Windows Server Hardening Framework
@SiteQ8 — Ali AlEnezi
CIS Benchmark · NIST SP 800-53 · DISA STIG · Microsoft Security Baselines
标签:AI合规, ATTACK-Python-Client, CIS Benchmark, DISA STIG, GPT, HTML报告, IPv6, JSON报告, Libemu, NIST 800-53, PE 加载器, PowerShell, Server 2019, Server 2022, Windows服务器, 企业安全, 基线扫描, 安全合规, 安全基线, 安全报告, 安全策略, 开源安全工具, 指令遵循, 提示词设计, 教学环境, 流量嗅探, 漏洞管理, 系统加固, 网络代理, 网络资产管理, 自动化运维, 逆向工程平台, 零依赖