kongali1720/Security-Automation-Scripts
GitHub: kongali1720/Security-Automation-Scripts
一套跨平台的蓝队安全自动化脚本集合,为 SOC 分析师和系统管理员提供日志分析、威胁检测、主机加固和合规审计等防御性安全运营能力。
Stars: 1 | Forks: 0
# 🛡️ 安全自动化脚本
**企业级自动化框架,专为蓝队运营、SOC 分析和主动系统加固而设计。**
[](https://github.com/kongali1720/Security-Automation-Scripts)
[](https://github.com/kongali1720/Security-Automation-Scripts)
[](https://github.com/kongali1720/Security-Automation-Scripts/issues)
[](LICENSE)
## 📖 目录
- [概述](#-overview)
- [核心功能](#-key-capabilities)
- [核心架构](#-core-architecture)
- [模块参考](#-module-reference)
- [部署](#-deployment)
- [使用示例](#-usage-examples)
- [工程路线图](#-engineering-roadmap)
- [贡献](#-contributing)
- [仓库结构](#-repository-structure)
- [许可证](#-license)
- [作者](#-author)
## 📖 概述
**Security Automation Scripts** 是一个跨平台(**Python, Bash, 和 PowerShell**)的自动化脚本集合,旨在辅助安全运营中心 (SOC)、蓝队、事件响应、威胁狩猎以及基础设施加固活动。
该框架简化了以下流程:
- 事件分诊
- 威胁情报
- 主机加固
- 数字取证
- 合规审计
- 安全监控
## 🎯 核心功能
- 🔍 **事件响应与分诊**
- IOC 提取
- 日志解析
- YARA 恶意软件检测
- 文件完整性监控
- 🌐 **攻击面监控**
- DNS 查询
- WHOIS 查询
- 外部情报
- 🛡️ **主机加固**
- Linux 安全审计
- Windows 安全审计
- SSH 加固
- 防火墙验证
## 🏗️ 核心架构
```
graph TD
Root[Security Automation Scripts]
Root --> PY[🐍 Python Engine]
Root --> SH[🐧 Linux Hardening]
Root --> PS[🪟 Windows Audit]
PY --> PY1[IOC Extractor]
PY --> PY2[Log Analyzer]
PY --> PY3[YARA Scanner]
PY --> PY4[FIM Engine]
SH --> SH1[System Audit]
SH --> SH2[SSH Hardening]
SH --> SH3[Firewall Controller]
PS --> PS1[Event Log Parser]
PS --> PS2[Windows Audit]
PS --> PS3[Defender Status]
```
# 🗂️ 模块参考
## 🐍 Python 引擎 (`/python`)
| 工具 | 功能范围 | 目标产物 |
|----------|------------------|------------------|
| `log_analyzer.py` | SIEM 风格的日志解析与关联 | 身份验证日志, Apache, Nginx |
| `log_parser.py` | 通用日志解析引擎 | 系统与应用程序日志 |
| `file_integrity_monitor.py` | 基线哈希与文件完整性监控 | 关键系统文件 |
| `ioc_extractor.py` | 提取妥协指标 (IOC) | IP, 域名, URL, 电子邮件, 哈希 |
| `hash_checker.py` | 使用加密哈希验证文件完整性 | 文件与恶意软件样本 |
| `dns_lookup.py` | DNS 枚举与查询 | 域名 |
| `whois_lookup.py` | WHOIS 信息检索 | 域名 |
| `url_checker.py` | URL 验证与检查 | URL |
| `network_monitor.py` | 监控活动网络连接 | 网络会话 |
| `yara_scanner.py` | 使用 YARA 规则进行恶意软件检测 | PE 文件, 脚本, 文档 |
| `report_generator.py` | 生成 HTML 和 JSON 安全报告 | 扫描结果 |
## 🐧 Linux 加固 (`/bash`)
| 工具 | 功能范围 | 合规性 / 目标 |
|----------|------------------|---------------------|
| `system_audit.sh` | Linux 安全审计 | CIS Benchmark |
| `ssh_hardening.sh` | SSH 配置加固 | `/etc/ssh/sshd_config` |
| `firewall_status.sh` | 防火墙状态检查 | UFW / iptables / firewalld |
| `backup_logs.sh` | 备份安全日志 | `/var/log` |
| `user_audit.sh` | 用户枚举与 Shadow 审计 | `/etc/passwd`, `/etc/shadow` |
## 🪟 Windows 安全 (`/powershell`)
| 工具 | 功能范围 | 事件 ID / 目标 |
|----------|------------------|--------------------|
| `windows_audit.ps1` | Windows 安全审计 | Defender, Build, Hotfixes |
| `eventlog_parser.ps1` | Windows 事件日志分析 | 4624, 4625, 4688, 7045 |
| `firewall_check.ps1` | Windows 防火墙检查 | 防火墙配置文件 |
| `defender_status.ps1` | Microsoft Defender 状态 | AV 引擎与特征库 |
# 🚀 部署
## 📋 前置条件
- Python **3.10+**
- PowerShell **7+**
- Bash Shell
- 管理员 / Root 权限
## 1️⃣ 克隆仓库
```
git clone https://github.com/kongali1720/Security-Automation-Scripts.git
cd Security-Automation-Scripts
pip install -r requirements.txt
```
## 2️⃣ IOC 提取
```
python python/ioc_extractor.py \
--input samples/suspect_payload.txt
```
## 3️⃣ Linux 安全审计
```
chmod +x bash/system_audit.sh
sudo ./bash/system_audit.sh
```
## 4️⃣ Windows 安全审计
```
Set-ExecutionPolicy Bypass -Scope Process
.\powershell\windows_audit.ps1 -Detailed
```
# 📊 使用示例
## 🔐 文件完整性监控
```
# 每 30 秒监控 /etc
python python/file_integrity_monitor.py \
-d /etc \
--monitor \
-i 30
# 运行一次性完整性检查
python python/file_integrity_monitor.py \
-d /etc \
--check
```
## 🦠 恶意软件扫描 (YARA)
```
python python/yara_scanner.py \
-r malware_rules/ \
-t /tmp \
--recursive \
-o report.json
```
## 📄 日志分析
```
python python/log_analyzer.py \
-f /var/log/auth.log \
--json \
-o auth_report.json
```
## 🪟 Windows 安全审计
```
# 执行完整的 Windows 安全审计
.\powershell\windows_audit.ps1
# 将审计结果导出为 HTML
.\powershell\windows_audit.ps1 -ExportHTML
```
## 📊 工程路线图
```
Security Automation Scripts
├── ✅ Core Automation Engine
│ ├── Log Analyzer
│ ├── IOC Extractor
│ ├── YARA Scanner
│ └── File Integrity Monitor
│
├── 🚧 External Threat Intelligence
│ ├── VirusTotal
│ ├── AbuseIPDB
│ └── Shodan API
│
├── 📅 SIEM Integration
│ ├── Splunk
│ ├── Elastic Stack
│ └── Graylog
│
└── 📅 Dashboard Generator
```
# 🗺️ 项目路线图
| 状态 | 组件 | 描述 |
|:------:|-----------|-------------|
| ✅ | 日志分析引擎 | SIEM 风格的日志解析与关联 |
| ✅ | IOC 提取 | 提取 IP、域名、URL、电子邮件和文件哈希 |
| ✅ | 文件完整性监控 | 基线哈希与文件变更检测 |
| ✅ | 安全映射 | 安全事件分类与报告 |
| 🚧 | VirusTotal 集成 | 自动进行文件与哈希信誉查询 |
| 🚧 | AbuseIPDB 集成 | IP 信誉与威胁情报查询 |
| 🚧 | Shodan 集成 | 面向互联网的资产丰富化 |
| ⬜ | SIEM 转发器 | 将日志转发至 Wazuh、Splunk、ELK 或 Microsoft Sentinel |
| ⬜ | GitHub Actions CI/CD | 自动化测试、linting 和发布 |
| ⬜ | Web 仪表板 | 用于报告的交互式 Web 界面 |
| ⬜ | HTML 和 PDF 报告 | 适合管理层的报告引擎 |
| ⬜ | 电子邮件通知 | 自动化安全警报发送 |
| ⬜ | Docker 支持 | 容器化部署 |
| ⬜ | REST API | 用于自动化和第三方集成的 API |
## 📂 仓库结构
```
Security-Automation-Scripts/
├── python/
│ ├── log_analyzer.py
│ ├── log_parser.py
│ ├── ioc_extractor.py
│ ├── yara_scanner.py
│ ├── file_integrity_monitor.py
│ └── report_generator.py
│
├── bash/
│ ├── system_audit.sh
│ ├── ssh_hardening.sh
│ └── user_audit.sh
│
├── powershell/
│ ├── eventlog_parser.ps1
│ └── windows_audit.ps1
│
├── requirements.txt
├── LICENSE
└── README.md
```
# 👨💻 作者
## Kong Ali
**网络安全爱好者 • 安全自动化工程师 • 蓝队**
[](https://github.com/kongali1720)
## 🎯 专注领域
| 领域 | 描述 |
|---------|-------------|
| 🔵 **蓝队工程** | 防御性安全、监控和检测工程 |
| 🔴 **事件响应** | 调查、遏制、根除和恢复 |
| 🛡️ **安全自动化** | 用于安全运营的 Python、Bash 和 PowerShell 自动化 |
| 🔍 **威胁狩猎** | IOC 分析、威胁检测和行为分析 |
| 📊 **安全运营中心 (SOC)** | 日志分析、SIEM、检测和监控 |
### 🛡️ 安全 • 自动化 • 检测 • 防御
**用 ❤️ 为开源网络安全社区而打造**