vetementsvmnts/Powershell-Automation

GitHub: vetementsvmnts/Powershell-Automation

一个面向Windows平台的PowerShell网络安全自动化框架,覆盖蓝队检测、红队测试、系统加固、事件响应和合规审计等核心场景。

Stars: 0 | Forks: 0

``` ██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗██╗ ██╗███████╗██╗ ██╗ ██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝██║ ██║ ██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗███████║█████╗ ██║ ██║ ██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║██╔══██║██╔══╝ ██║ ██║ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║██║ ██║███████╗███████╗███████╗ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ``` ### ⚡ 网络安全自动化 — 从加固到狩猎 [![PowerShell](https://img.shields.io/badge/PowerShell-5.1%2B%20%7C%207.x-0078D4?style=for-the-badge&logo=powershell&logoColor=white)](https://docs.microsoft.com/en-us/powershell/) [![Platform](https://img.shields.io/badge/Platform-Windows%2010%2F11%20%7C%20Server-0078D4?style=for-the-badge&logo=windows&logoColor=white)](https://www.microsoft.com/en-us/windows) [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](./LICENSE) [![Maintenance](https://img.shields.io/badge/Maintained-Yes-brightgreen?style=for-the-badge)](https://github.com/YourUsername/Powershell-Automation/commits) [![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-blueviolet?style=for-the-badge)](./CONTRIBUTING.md) [![Blue Team](https://img.shields.io/badge/Blue%20Team-Detection%20%26%20Hardening-1565C0?style=flat-square)](.) [![Red Team](https://img.shields.io/badge/Red%20Team-Authorized%20Testing%20Only-C62828?style=flat-square)](.) [![MITRE ATT&CK](https://img.shields.io/badge/MITRE-ATT%26CK%20Mapped-FF6F00?style=flat-square)](https://attack.mitre.org/) [![CIS Benchmarks](https://img.shields.io/badge/CIS-Benchmark%20Aligned-2E7D32?style=flat-square)](https://www.cisecurity.org/)
## 📋 目录 - [✨ 概述](#-overview) - [🚀 功能一览](#-features-at-a-glance) - [⚙️ 前置条件](#️-prerequisites) - [📦 安装说明](#-installation) - [🗂️ 模块结构](#️-module-structure) - [🟢 新手快速入门](#-beginner-quick-start) - [🔧 高级用法](#-advanced-usage) - [🔵 Blue Team 模块](#-blue-team-modules) - [🔴 Red Team 模块](#-red-team-modules) - [🛡️ 合规与加固](#️-compliance--hardening) - [🚨 事件响应](#-incident-response) - [📊 日志分析](#-log-analysis) - [🤝 贡献指南](#-contributing) - [⚠️ 免责声明](#️-disclaimer) - [📄 许可证](#-license) ## ✨ 概述 **Powershell-Automation** 是一个完全使用 PowerShell 构建的模块化、可扩展的网络安全自动化框架。无论您是经验丰富的渗透测试人员、Blue Team 分析师,还是初次接触安全领域的 IT 管理员——这个工具集都能为您提供必要的脚本、文档和工作流,助您快速而精准地开展操作。 每个模块在构建时都兼顾了两类受众: | 👤 非技术用户 | 🧑‍💻 安全专业人员 | |---|---| | 通俗易懂的步骤指南 | 完整的参数控制与管道支持 | | 默认安全的只读模式 | SIEM 集成与 API 钩子 | | 自动生成的 HTML 报告 | 自定义规则集与高级过滤器 | | 无需任何 PowerShell 基础 | 可扩展的模块化架构 | ## 🚀 功能一览 | 模块 | 功能 | 标准 | |---|---|---| | 🔒 **安全加固** | CIS Benchmark 与 STIG 自动化审计 | CIS L1/L2, STIG | | 🚨 **事件响应** | 遏制、根除与恢复工作流 | NIST SP 800-61 | | 📊 **日志分析** | Windows Event Logs, Sysmon, PowerShell 转换解析 | MITRE ATT&CK | | ✅ **合规检查** | 附带可导出报告的基线审计 | NIST, PCI-DSS, ISO 27001 | | 🔴 **Red Team** | 枚举、横向移动模拟、密码审计 | MITRE ATT&CK TTPs | | 🔵 **Blue Team** | 威胁狩猎、异常检测、IOC 搜索 | MITRE D3FEND | | 📝 **报告生成** | 自动生成 HTML/CSV/JSON 安全审计报告 | — | | 🧩 **模块化设计** | 仅导入您需要的模块 | — | ## ⚙️ 前置条件 在开始之前,请确保满足以下条件: ``` ✔ PowerShell 5.1+ OR PowerShell Core 7.x (recommended) ✔ Windows 10 / 11 OR Windows Server 2016 / 2019 / 2022 ✔ Administrator / Elevated Privileges (required for most modules) ``` **可选依赖项:** - [Pester](https://pester.dev/) — 用于运行模块单元测试 - [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) — 用于脚本代码检查 检查您的 PowerShell 版本: ``` $PSVersionTable.PSVersion ``` ## 📦 安装说明 ### 选项 1 — 通过 Git 克隆 *(推荐)* ``` git clone https://github.com/YourUsername/Powershell-Automation.git cd Powershell-Automation ``` ### 选项 2 — 下载 ZIP 1. 在此页面点击 **`Code`** → **`Download ZIP`** 2. 解压到您选择的文件夹 3. 以管理员身份打开 PowerShell 并导航至该文件夹 ### 设置执行策略 ``` Set-ExecutionPolicy RemoteSigned -Scope CurrentUser ``` ### 导入工具包 ``` Import-Module .\CyberSecToolkit.psm1 # 验证已加载的模块 Get-Module CyberSecToolkit ``` ## 🗂️ 模块结构 ``` Powershell-Automation/ │ ├── 📁 BlueTeam/ # Detection, hunting & monitoring │ ├── Invoke-ThreatHunt.ps1 │ ├── Get-SuspiciousProcesses.ps1 │ ├── Watch-NetworkConnections.ps1 │ └── Get-FailedLogons.ps1 │ ├── 📁 RedTeam/ # Authorized offensive testing │ ├── Invoke-Enumeration.ps1 │ ├── Test-LateralMovement.ps1 │ ├── Get-LocalPrivileges.ps1 │ └── Invoke-PasswordAudit.ps1 │ ├── 📁 Hardening/ # System & policy hardening │ ├── Invoke-CISBenchmark.ps1 │ ├── Set-SecureBaseline.ps1 │ ├── Disable-LegacyProtocols.ps1 │ └── Enable-AuditPolicies.ps1 │ ├── 📁 IncidentResponse/ # IR workflows & forensics │ ├── Start-IRWorkflow.ps1 │ ├── Invoke-Containment.ps1 │ ├── Collect-ForensicData.ps1 │ └── Export-IRReport.ps1 │ ├── 📁 LogAnalysis/ # Log parsing & IOC detection │ ├── Parse-EventLogs.ps1 │ ├── Analyze-SysmonLogs.ps1 │ ├── Get-PowerShellHistory.ps1 │ └── Find-IOCs.ps1 │ ├── 📁 Compliance/ # Regulatory baseline checks │ ├── Test-NISTBaseline.ps1 │ ├── Test-PCIDSSControls.ps1 │ └── Export-ComplianceReport.ps1 │ ├── 📁 Docs/ # Guides & references │ ├── BeginnerGuide.md │ ├── AdvancedScripting.md │ └── ModuleReference.md │ ├── 📁 Reports/ # Auto-generated output reports ├── CyberSecToolkit.psm1 # Main module manifest └── README.md ``` ## 🟢 新手快速入门 **步骤 1** — 以管理员身份打开 PowerShell ``` Start Menu → Search "PowerShell" → Right-click → Run as Administrator ``` **步骤 2** — 导航至工具包文件夹 ``` cd C:\Path\To\Powershell-Automation ``` **步骤 3** — 导入工具包 ``` Import-Module .\CyberSecToolkit.psm1 ``` **步骤 4** — 运行您的第一次检查 *(安全的只读模式)* ``` # 检查过去 24 小时内失败的登录尝试 .\BlueTeam\Get-FailedLogons.ps1 -Hours 24 ``` **步骤 5** — 查看您的报告 结果将显示在终端中,**并且**会作为 HTML 文件保存在 `.\Reports\` 目录下,您可以在任何浏览器中打开它。 ## 🔧 高级用法 所有模块均支持管道输入、自定义参数、详细日志记录以及 SIEM/API 集成。 ``` # 完整的 CIS Level 1 Benchmark 审计 — 导出为 HTML .\Hardening\Invoke-CISBenchmark.ps1 -Level 1 -ExportHTML -OutputPath "C:\Reports\CIS_Audit.html" # 映射到 MITRE ATT&CK T1059 (Command & Scripting Interpreter) 的威胁狩猎 .\BlueTeam\Invoke-ThreatHunt.ps1 -IOC "mimikatz" -Scope EventLog,ProcessList,Network -MITREMap # 包含取证收集的完整勒索软件 IR 工作流 .\IncidentResponse\Start-IRWorkflow.ps1 -IncidentType Ransomware -AffectedHost WORKSTATION-01 -CollectForensics # Pipeline:获取可疑进程并将结果传递给 IOC 查找器 .\BlueTeam\Get-SuspiciousProcesses.ps1 | .\LogAnalysis\Find-IOCs.ps1 -SearchScope All ``` ## 🔵 Blue Team 模块 ### `Get-FailedLogons.ps1` 查询 Windows 安全事件日志 **(Event ID 4625)** 中失败的认证尝试。适用于检测暴力破解和密码喷洒攻击。 ``` .\BlueTeam\Get-FailedLogons.ps1 -Hours 48 -ExportCSV -Threshold 5 ``` ### `Get-SuspiciousProcesses.ps1` 识别具有异常父子关系、未签名二进制文件或名称与已知恶意模式匹配的进程。 ``` .\BlueTeam\Get-SuspiciousProcesses.ps1 -CheckSignatures -CompareBaseline ``` ### `Watch-NetworkConnections.ps1` 监控实时网络连接,并使用本地或远程威胁情报源标记发往已知恶意 IP 的流量。 ``` .\BlueTeam\Watch-NetworkConnections.ps1 -ThreatFeed .\Data\malicious_ips.txt -Interval 30 ``` ### `Invoke-ThreatHunt.ps1` 跨事件日志、进程、注册表键和网络特征的结构化威胁狩猎——映射到 MITRE ATT&CK 剧本。 ``` .\BlueTeam\Invoke-ThreatHunt.ps1 -Playbook MITRE_T1059 -Verbose ``` ## 🔴 Red Team 模块 ### `Invoke-Enumeration.ps1` 本地和域枚举——用户、组、共享、服务和计划任务。 ``` .\RedTeam\Invoke-Enumeration.ps1 -Target localhost -Scope Full ``` ### `Test-LateralMovement.ps1` 通过 WMI、PsExec 和 WinRM 模拟横向移动路径,以识别权限过高的账户和暴露的攻击路径。 ``` .\RedTeam\Test-LateralMovement.ps1 -TargetHost 192.168.1.50 -Method WinRM ``` ### `Get-LocalPrivileges.ps1` 识别本地权限提升向量,包括薄弱的服务权限、未加引号的路径以及 token 滥用机会。 ``` .\RedTeam\Get-LocalPrivileges.ps1 -CheckAll ``` ### `Invoke-PasswordAudit.ps1` 测试密码策略,并根据可配置的字典检查活动账户,以识别弱凭证。 ``` .\RedTeam\Invoke-PasswordAudit.ps1 -WordList .\Data\common_passwords.txt -Domain CORP ``` ## 🛡️ 合规与加固 ### 运行 CIS Benchmark 审计 ``` # Level 1 — 基本(适用于大多数环境) .\Hardening\Invoke-CISBenchmark.ps1 -Level 1 # Level 2 — 严格(适用于高安全性环境) .\Hardening\Invoke-CISBenchmark.ps1 -Level 2 -ExportHTML ``` ### 应用安全基线 ``` # 始终先使用 -WhatIf 进行预览 .\Hardening\Set-SecureBaseline.ps1 -WhatIf # 审查后应用 .\Hardening\Set-SecureBaseline.ps1 -Confirm ``` ### 禁用旧版协议 ``` # 禁用 SMBv1、TLS 1.0/1.1、RC4 和弱密码套件 .\Hardening\Disable-LegacyProtocols.ps1 -All ``` ### 启用推荐的审计策略 ``` .\Hardening\Enable-AuditPolicies.ps1 -Preset Recommended ``` ## 🚨 事件响应 ### 启动完整的事件响应工作流 ``` .\IncidentResponse\Start-IRWorkflow.ps1 -IncidentType Malware -AffectedHost WORKSTATION-01 ``` 该工作流将自动执行: ``` [1] Notify analyst via console prompt [2] Isolate affected host ← requires confirmation [3] Collect volatile data (processes, connections, memory artifacts) [4] Pull Windows Event Logs (Security, System, Application) [5] Package all evidence → timestamped ZIP [6] Generate IR report → HTML + JSON ``` ### 仅收集取证数据 ``` .\IncidentResponse\Collect-ForensicData.ps1 -Host WORKSTATION-01 -OutputPath C:\IR\Evidence\ ``` ### 隔离主机(遏制) ``` .\IncidentResponse\Invoke-Containment.ps1 -Host WORKSTATION-01 -Method NetworkIsolation ``` ## 📊 日志分析 ### 解析 Windows Event Logs ``` # 7 天内的登录事件 + 失败记录 .\LogAnalysis\Parse-EventLogs.ps1 -EventID 4624,4625,4648 -Days 7 -ExportCSV ``` ### 分析 Sysmon 日志 ``` # 筛选可疑的网络连接和进程创建 .\LogAnalysis\Analyze-SysmonLogs.ps1 -Filter NetworkConnect,ProcessCreate -Suspicious ``` ### 获取 PowerShell 命令历史记录 ``` # 提取所有用户的 PSReadLine 历史记录和脚本运行日志 .\LogAnalysis\Get-PowerShellHistory.ps1 -AllUsers -IncludeTranscripts ``` ### 查找失陷指标 ``` # 跨所有日志源搜索已知的 IOC .\LogAnalysis\Find-IOCs.ps1 -IOCFile .\Data\iocs.csv -SearchScope All -ExportReport ``` ## 🤝 贡献指南 欢迎您的贡献——新的检测脚本、改进的文档、错误修复以及加固规则都能增强这个社区工具集。 ``` 1. Fork the repository 2. git checkout -b feature/your-module-name 3. git commit -m "Add: description of what you added" 4. git push origin feature/your-module-name 5. Open a Pull Request ``` **贡献的脚本标准:** - 所有脚本必须包含基于注释的帮助(兼容 `Get-Help`) - 遵循 PowerShell [Approved Verbs](https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands) - 每个脚本至少包含一个使用示例 - Red Team 脚本在运行时必须包含授权警告 ## ⚠️ 免责声明 ## 📄 许可证 本项目基于 **MIT License** 授权——详情请参见 [LICENSE](./LICENSE) 文件。
**为防御者而生。由攻击者打磨。受双方信赖。** [![GitHub Stars](https://img.shields.io/github/stars/YourUsername/Powershell-Automation?style=social)](https://github.com/YourUsername/Powershell-Automation/stargazers) [![GitHub Forks](https://img.shields.io/github/forks/YourUsername/Powershell-Automation?style=social)](https://github.com/YourUsername/Powershell-Automation/network/members) [![GitHub Issues](https://img.shields.io/github/issues/YourUsername/Powershell-Automation?style=social)](https://github.com/YourUsername/Powershell-Automation/issues) 如果对您有帮助,请 ⭐ **星标此仓库**  |  🐛 [报告 Bug](../../issues/new)  |  💡 [请求功能](../../issues/new)  |  💬 [讨论](../../discussions)
标签:AI合规, Awesome, BurpSuite集成, Cloudflare, Conpot, DNS 解析, GitHub Advanced Security, IPv6, IT运维, MITRE ATT&CK, OpenCanary, PowerShell, Socks5代理, Windows安全, 安全加固, 安全态势, 安全脚本, 数据包嗅探, 数据展示, 无线安全, 流量嗅探, 系统管理, 红队, 网络安全, 网络安全工具包, 网络安全运营, 运维自动化, 隐私保护