mustapha-haouili/infrastructure-security-scripts
GitHub: mustapha-haouili/infrastructure-security-scripts
一套面向企业 Windows、Linux 和 DevSecOps 环境的防御性基础设施安全审计与加固脚本工具包,内置 AI 辅助的本地证据分析与报告能力。
Stars: 0 | Forks: 0
# 基础设施安全脚本





一个实用的防御性基础设施安全工具包,适用于企业 Windows、Linux、Active Directory、DevSecOps、监控、加固、证据收集和本地安全报告。
此仓库专为防御性安全操作、基础设施管理、可重复的基线检查,以及在企业环境中进行审计优先的基础设施安全评估而设计。
它包含 SecureInfra_AI 层,用于对基础设施证据进行确定性、本地化、支持 AI 的分析。该层可以标准化安全发现,生成 JSON 和 Markdown 报告,比较历史运行记录,分析客户端数据包,审查集群证据,并在本地仪表板中显示报告。
当前版本:`1.2.0-beta.1`。有关当前 beta 版本的基线,请参阅 [CHANGELOG.md](CHANGELOG.md) 和
[v1.2.0-beta.1 发布说明](docs/releases/v1.2.0-beta.1.md)。
## 关注领域
- 基础设施加固
- PowerShell 自动化
- Linux 管理
- 安全审计
- DevSecOps 操作
- 监控与自动化
- 企业运营脚本
## 技术栈
- Windows Server
- Linux
- PowerShell
- Python
- Bash
- Docker
- Kubernetes
## 仓库结构
```
infrastructure-security-scripts/
|-- .github/workflows/ # CI checks for scripts
|-- SecureInfra_AI/ # AI-ready deterministic analysis and reporting layer
|-- docs/ # Methodology, usage notes, service model, and script index
|-- examples/ # Example configuration, sample reports, and sample outputs
|-- schemas/ # JSON schemas for findings, reports, and remediation plans
|-- scripts/
| |-- windows/ # Windows audit and hardening scripts
| |-- linux/ # Linux audit, hardening, and inventory scripts
| |-- devsecops/ # Docker, Kubernetes, and secret scanning scripts
| |-- monitoring/ # Service and disk monitoring scripts
| `-- reporting/ # Markdown report generation helpers
`-- tests/ # Lightweight static checks and unit tests
```
## 安全模型
大多数脚本使用以下模式之一:
- 默认为审计模式
- 默认为预演模式
- 在进行更改前需要明确的 `--apply` 或 `-Apply`
- 报告文件写入 `reports/` 目录下
- 当脚本更改配置时,备份文件写入 `backups/` 目录下
在生产环境中运行之前,请逐一审查每个脚本。首先在实验室或预发布环境中测试更改。
## 快速开始
```
git clone https://github.com/mustapha-haouili/infrastructure-security-scripts.git
cd infrastructure-security-scripts
bash tests/run_static_checks.sh
```
### Linux 审计
```
sudo bash scripts/linux/linux-security-audit.sh -o reports
```
### Linux 加固预演
```
sudo bash scripts/linux/linux-hardening-baseline.sh
```
仅在审查后应用选定的基线更改:
```
sudo bash scripts/linux/linux-hardening-baseline.sh --apply
```
### Windows 审计
以管理员身份运行 PowerShell:
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\scripts\windows\Start-WindowsSecurity.ps1
```
从菜单中选择 `Windows Host`,然后选择 `Windows security audit`。
### 客户端证据收集
对于客户端收集,运行安全启动器。它会运行支持的
审计/预演检查,写入一个结构化的结果文件夹,并创建一个
客户端可以发回以供分析的 zip 文件。
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\scripts\windows\Start-SecureInfraClientCollection.ps1
```
仅运行选定的范围:
```
.\scripts\windows\Start-SecureInfraClientCollection.ps1 -Scope AD,Host,Server
```
当前的收集器支持 AD/GPO、Windows 主机、服务器、工作站以及
本地网络暴露证据。
分析完整的客户端收集文件夹或 zip:
```
python .\SecureInfra_AI\scripts\reporting\secureinfra_analyzer.py --input .\reports\secureinfra-client-collection-CLIENT-20260619-120000.zip --type client-bundle --output .\reports\secureinfra-ai-client
```
分析来自多台服务器或工作站的多个客户端数据包:
```
python .\SecureInfra_AI\scripts\reporting\secureinfra_analyzer.py --input .\reports\client-bundles --type multi-bundle --output .\reports\secureinfra-ai-fleet
```
将所有返回的收集文件夹或 `.zip` 文件放在同一个父文件夹下,
例如 `reports\client-bundles`。集群分析器会创建一份标准化
报告,包含机器清单、单机覆盖范围以及唯一的发现 ID。
可选的共享 Windows 参数:
```
Copy-Item .\examples\windows-security.config.example.json .\windows-security.config.local.json
.\scripts\windows\Start-WindowsSecurity.ps1 -Group AD -RunAll -UseDefaults -ConfigPath .\windows-security.config.local.json
```
### Windows 基线预演
```
.\scripts\windows\Start-WindowsSecurity.ps1 -ToolId HOST-HARDENING
```
仅在审查后应用基线更改:
```
.\scripts\windows\Start-WindowsSecurity.ps1 -ToolId HOST-HARDENING
```
当提示输入参数时,仅在批准的变更
窗口期间启用 `-Apply`。
### 推送代码前的密钥扫描
```
python3 scripts/devsecops/secret-scan.py . --format text
```
### Docker 镜像审计
```
bash scripts/devsecops/docker-image-audit.sh nginx:latest
```
### Kubernetes RBAC 审计
```
bash scripts/devsecops/kubernetes-rbac-audit.sh --output-dir reports
```
### 服务健康检查
```
python3 scripts/monitoring/service-health-check.py --config examples/services.example.json
```
### Markdown 报告生成
```
python3 scripts/reporting/generate-markdown-report.py examples/sample-output/windows/windows-host-audit.example.json --output reports/example-assessment.md
```
### SecureInfra AI 分析器
```
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input SecureInfra_AI/examples/sample-input/active-directory/sample-ad-inactive-users.json --type ad-inactive-users --output SecureInfra_AI/reports
```
完整客户端数据包:
```
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/secureinfra-client-collection-CLIENT-20260619-120000.zip --type client-bundle --output reports/secureinfra-ai-client
```
客户端数据包集群:
```
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/client-bundles --type multi-bundle --output reports/secureinfra-ai-fleet
```
Beta 独立 Windows 报告分析器:
```
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/windows-security-audit.json --type windows-host-audit --output reports/secureinfra-ai-host
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/windows-server-security.json --type windows-server-audit --output reports/secureinfra-ai-server
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/windows-workstation-security.json --type windows-workstation-audit --output reports/secureinfra-ai-workstation
python3 SecureInfra_AI/scripts/reporting/secureinfra_analyzer.py --input reports/windows-network-exposure.json --type windows-network-exposure --output reports/secureinfra-ai-network
```
这些分析器类型仅用于报告,用于将相应的 Windows 审计脚本生成的现有 JSON 证据进行标准化。
### SecureInfra 仪表板
在浏览器中打开 `SecureInfra_AI/dashboard/index.html` 以在本地审查 JSON 报告,
包括严重性指标、过滤、证据详情和相关发现
链接。使用 `--previous-normalized-report` 生成的标准化报告还会
显示新增、持续存在和已解决的发现。标准化的 `multi-bundle` 报告
增加了机器过滤和集群收集覆盖功能。
## 脚本索引
有关脚本及其用途的完整列表,请参阅 [docs/script-index.md](docs/script-index.md)。
有关每个脚本的参数、输出文件、安全模式和可直接复制的示例,请参阅 [docs/script-reference.md](docs/script-reference.md)。
有关支持 AI 的确定性报告层,请参阅 [SecureInfra_AI/README.md](SecureInfra_AI/README.md)。
有关审计优先的评估工作流,请参阅 [docs/methodology.md](docs/methodology.md)。
有关基础设施健康检查模型,请参阅 [docs/service-model/secureinfra-check-overview.md](docs/service-model/secureinfra-check-overview.md)。
有关计划中的工具包改进,请参阅 [ROADMAP.md](ROADMAP.md)。
有关 Windows AD、GPO、服务器和工作站的扩展计划,请参阅 [docs/windows-roadmap.md](docs/windows-roadmap.md)。
每个脚本还内置了帮助信息:
```
bash scripts/linux/linux-security-audit.sh --help
python3 scripts/devsecops/secret-scan.py --help
```
PowerShell 脚本在每个文件的顶部包含基于注释的帮助。如果你的
PowerShell 会话没有通过 `Get-Help` 加载脚本帮助,请直接查看
头部信息:
```
Get-Content .\scripts\windows\Start-WindowsSecurity.ps1 -First 120
```
## 推荐的 GitHub 描述
用于 Windows、Linux、DevSecOps、加固、审计、监控和自动化的企业基础设施安全脚本。
## 建议的仓库主题
```
infrastructure-security windows-server linux powershell bash python devsecops hardening security-audit docker kubernetes automation cybersecurity
```
## 作者
Mustapha Haouili
基础设施安全架构师
## 负责任的使用
这些脚本旨在用于您拥有或被授权管理的系统。未经书面许可,请勿将其用于第三方环境。
标签:AI合规, DevSecOps, GitHub Advanced Security, IPv6, Libemu, PowerShell, Python, 上游代理, 基础架构安全, 子域名突变, 安全加固, 应用安全, 无后门, 请求拦截, 逆向工具