ashvinctrl/cloud-security-scripts
GitHub: ashvinctrl/cloud-security-scripts
一套覆盖 AWS 云安全、DevOps 工具链及系统加固的独立自动化审计脚本集合,帮助团队在运维和 CI/CD 流程中快速发现配置风险与安全隐患。
Stars: 0 | Forks: 0
# 云安全脚本
[](https://python.org)
[](https://aws.amazon.com)
[](LICENSE)
覆盖云、DevOps 和网络安全领域的生产级安全与 DevOps 自动化脚本 —— 每个脚本都是独立的,只需极少的设置即可运行。
## 结构
```
cloud/ AWS security audit scripts (IAM, S3, EC2, CloudTrail)
devops/ Kubernetes, Docker, CI/CD, and IaC tooling
security/ Linux hardening, web security, and secret detection
```
## 云 (`cloud/`)
| 脚本 | 检查内容 |
|---|---|
| [aws_s3_audit.py](cloud/aws_s3_audit.py) | S3 存储桶 —— 公开访问、静态加密、版本控制、访问日志、ACL 配置错误 |
| [aws_iam_audit.py](cloud/aws_iam_audit.py) | IAM 用户和角色 —— 未启用 MFA 的控制台访问、未使用的访问密钥、过于宽松的策略、root 账户活动 |
| [cloudtrail_threat_detector.py](cloud/cloudtrail_threat_detector.py) | CloudTrail 事件 —— 提权、可疑的 API 调用、异常的访问模式、未经授权的活动 |
| [ec2_sg_auditor.py](cloud/ec2_sg_auditor.py) | EC2 安全组 —— 过于宽松的入站规则 (0.0.0.0/0)、敏感端口暴露、孤立的组 |
## DevOps (`devops/`)
| 脚本 | 检查内容 |
|---|---|
| [k8s_resource_audit.py](devops/k8s_resource_audit.py) | Kubernetes 工作负载 —— 缺失 CPU/内存限制、缺失 liveness/readiness 探针、崩溃循环的 pod、空的服务 |
| [terraform_drift_detector.py](devops/terraform_drift_detector.py) | Terraform plan 输出 —— 按严重程度 (CRITICAL / HIGH / MEDIUM / LOW) 对基础设施漂移进行分类,JSON 输出可用于 CI/CD 门禁 |
| [dockerfile_security_scanner.py](devops/dockerfile_security_scanner.py) | Dockerfile —— 以 root 身份运行、未锁定的基础镜像、硬编码的密钥、`curl \| bash` 模式、未锁定的软件包、缺失 HEALTHCHECK |
| [github_actions_audit.py](devops/github_actions_audit.py) | GitHub Actions 工作流 —— 危险的触发器、未锁定的 actions、脚本注入向量、硬编码的密钥、过于宽松的 token 权限范围 |
## 安全 (`security/`)
| 脚本 | 检查内容 |
|---|---|
| [linux_hardening_audit.sh](security/linux_hardening_audit.sh) | Linux 系统 —— SSH 配置、防火墙状态、SUID 二进制文件、全局可写文件、空密码、sudo 日志、开放端口 |
| [owasp_headers_check.py](security/owasp_headers_check.py) | HTTP 安全头 —— HSTS、CSP、X-Content-Type-Options、X-Frame-Options、Referrer-Policy、Permissions-Policy、服务器版本泄露 |
| [ssl_cert_auditor.py](security/ssl_cert_auditor.py) | SSL/TLS —— 证书过期、弱密码套件、已弃用的协议版本 (SSLv3, TLS 1.0/1.1) |
| [secrets_scanner.py](security/secrets_scanner.py) | 文件系统 —— 24 种硬编码密钥模式 (AWS, GCP, Azure, GitHub, Stripe, SendGrid, JWT, 数据库连接字符串, 私钥);JSON 输出;`--fail-on-findings` 标志可用于 CI |
## 使用说明
### 云 —— AWS 审计
```
pip install boto3
aws configure # or set AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
python cloud/aws_s3_audit.py
python cloud/aws_iam_audit.py
python cloud/ec2_sg_auditor.py
python cloud/cloudtrail_threat_detector.py
```
### DevOps —— Kubernetes 审计
```
pip install kubernetes
python devops/k8s_resource_audit.py
```
### DevOps —— Terraform 漂移检测
```
terraform plan -out=tfplan
terraform show -json tfplan | python devops/terraform_drift_detector.py
```
### DevOps —— Dockerfile 扫描
```
python devops/dockerfile_security_scanner.py path/to/Dockerfile
```
### DevOps —— GitHub Actions 审计
```
pip install pyyaml
python devops/github_actions_audit.py .github/workflows/
```
### 安全 —— Linux 加固
```
sudo bash security/linux_hardening_audit.sh
sudo bash security/linux_hardening_audit.sh --json # machine-readable output
```
### 安全 —— OWASP 头检查
```
pip install requests
python security/owasp_headers_check.py https://example.com
```
### 安全 —— SSL/TLS 审计
```
python security/ssl_cert_auditor.py example.com
```
### 安全 —— 密钥扫描器
```
python security/secrets_scanner.py /path/to/scan
python security/secrets_scanner.py /path/to/scan --fail-on-findings # exit 1 if secrets found (CI use)
python security/secrets_scanner.py /path/to/scan --json # JSON output
```
## 许可证
MIT
标签:Python, 子域名突变, 审计工具, 应用安全, 恶意代码分类, 数字取证, 无后门, 杀软绕过, 自动化脚本, 请求拦截, 逆向工具