A fully functional home lab simulating a real-world attacker vs. defender scenario built on VMware with Ubuntu Server and Kali Linux. An automated detection engine monitors the system in real time β when an attack is detected, it triggers a multi-phase response: evidence collection, IP containment, and auto-generated incident reports β all without human intervention.
- Overview
- Lab Architecture
- How It Works
- Scenarios Covered
- Lab Results β Real Attack Captured
- Alert Format (JSON)
- Project Structure
- Setup
- Evidence Structure
- Tools & Technologies
- NIST IR Framework Alignment
- Playbooks
This project demonstrates a complete Incident Response Planning and Execution pipeline built with Bash, Python, and JSON. An Ubuntu Server defended by a custom detection engine is attacked by a Kali Linux machine performing SSH brute force and network reconnaissance. The detection engine identifies the attack in real time, automatically contains the threat via iptables and UFW, collects forensic evidence, and generates a structured incident report β all within 30 seconds of the attack threshold being reached.
βββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββ
β VM1 β Defender β β VM2 β Attacker β
β Ubuntu Server 22.04 βββββββ Kali Linux β
β 192.168.126.10 β β 192.168.126.129 β
β β β β
β β auditd (kernel audit logging) β β β nmap (reconnaissance) β
β β Fail2ban (adaptive IP banning) β β β hydra (SSH brute force) β
β β UFW / iptables (host firewall) β β β netcat (reverse shell sim) β
β β detect_incident.sh (engine) β β β
β β respond.sh (auto-response) β β β
β β Wazuh Agent (SIEM integration) β β β
βββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββ
VMware VMnet1 β Host-Only Network (192.168.126.0/24)
Attack (Kali) Detection (Ubuntu) Response (automated)
ββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββ
hydra SSH BF βββΊ detect_incident.sh βββΊ Phase 1: Evidence
nmap scan βββΊ polls every 30s β’ network state
reverse shell βββΊ threshold reached β’ process list
alert written to β’ auth.log copy
alerts.json (JSON) β’ audit events
βββΊ Phase 2: Containment
β’ iptables DROP
β’ UFW deny
β’ hosts.deny
βββΊ Phase 3: Report
β’ Markdown report
β’ SHA256 hashes
| # | Scenario | MITRE ATT&CK | Detection Method | Automated Response |
|---|---|---|---|---|
| 1 | SSH Brute Force | T1110.001 | Failed auth threshold β₯5 | Block IP via iptables + UFW + hosts.deny |
| 2 | Port Scan | T1046 | SYN flood detection | Rate-limit + block source IP |
| 3 | Reverse Shell | T1059.004 | Process name pattern match | Kill process + quarantine binary |
| 4 | Privilege Escalation | T1548.001 | New SUID binary detection | Terminate sessions + lock file |
| 5 | File Tampering | T1565.001 | SHA256 hash change | chattr +i + alert |
The detection engine identified the SSH brute force from Kali (192.168.126.129) and triggered the automated response pipeline within one polling cycle (30 seconds).
All traffic from the attacker IP was dropped at the kernel level via iptables, with additional blocks applied through UFW and /etc/hosts.deny.
The response engine captured a full forensic snapshot at the moment of detection β network state, process list, auth logs, audit events β all SHA256-hashed for chain of custody.
A structured Markdown incident report was generated automatically, including containment actions taken, evidence paths, and next-step recommendations.
Every detection event is written to /opt/ir-lab/logs/alerts.json as structured JSON, ready for ingestion into a SIEM or TheHive:
{
"id": "ALERT-1783568272-14498",
"timestamp": "2026-07-09T03:37:52Z",
"severity": "HIGH",
"type": "SSH_BRUTEFORCE",
"message": "Brute force: 8 intentos desde 192.168.126.129",
"src_ip": "192.168.126.129",
"hostname": "ubuntu"
}incident-response-lab/
βββ README.md
βββ scripts/
β βββ setup_environment.sh # Installs all tools on VM1 (one command)
β βββ deploy_ir_scripts.sh # Deploys engine as systemd service
β βββ ir_dashboard.sh # Live terminal dashboard
β βββ detection/
β β βββ detect_incident.sh # Detection engine (6 modules, 30s polling)
β βββ response/
β β βββ respond.sh # Evidence + containment + report
β βββ simulation/
β βββ attack_simulation.sh # 3-phase attack from VM2
βββ playbooks/
β βββ playbook-ssh-bruteforce.md # Runbook T1110.001
β βββ playbook-port-scan.md # Runbook T1046
βββ configs/
βββ wazuh_custom_rules.xml # 8 custom Wazuh detection rules
| Component | Spec |
|---|---|
| Host OS | Windows 10/11 |
| Hypervisor | VMware Workstation 17+ |
| VM1 | Ubuntu Server 22.04 LTS β 2 vCPU, 2 GB RAM, 20 GB disk |
| VM2 | Kali Linux β 2 vCPU, 2 GB RAM, 20 GB disk |
| Network | VMnet1 Host-Only (192.168.126.0/24) for lab isolation |
# Clone the repo
git clone https://github.com/alexrepsec/incident-response-lab.git
cd incident-response-lab
# Install all tools (auditd, fail2ban, ufw, wazuh-agent, net-tools, tcpdump, jq)
sudo bash scripts/setup_environment.sh
# Deploy detection engine as systemd service
sudo bash scripts/deploy_ir_scripts.sh
# Verify service is running
sudo systemctl status ir-detection
# Monitor live
journalctl -u ir-detection -f# Kali has all tools pre-installed
# Verify connectivity to VM1
ping -c 3 192.168.126.10
# Launch SSH brute force attack
hydra -l root -P /usr/share/wordlists/rockyou.txt 192.168.126.10 ssh -t 4 -VAfter an incident is detected, artifacts are organized automatically:
/opt/ir-lab/
βββ evidence/<ALERT_ID>/
β βββ network/
β β βββ listening_ports.txt # Open ports at incident time
β β βββ established_connections.txt # Active connections
β β βββ iptables_rules.txt # Firewall state
β β βββ routing_table.txt
β βββ processes/
β β βββ process_list.txt # Full ps auxef output
β β βββ top_snapshot.txt
β βββ system/
β β βββ auth.log # Authentication log copy
β β βββ audit_today.txt # auditd events
β β βββ last_logins.txt
β β βββ current_users.txt
β βββ EVIDENCE_HASHES.txt # SHA256 of all artifacts
βββ reports/
β βββ incident-report-<ID>.md # Auto-generated report
βββ logs/
β βββ alerts.json # Structured JSON alert feed
β βββ detection.log # Human-readable detection log
β βββ blocked_ips.txt # Audit trail of all IP blocks
β βββ response.log # Response action log
βββ quarantine/ # Captured malicious binaries
| Tool | Purpose |
|---|---|
auditd |
Kernel-level syscall monitoring and audit logging |
Fail2ban |
Adaptive IP banning based on log pattern matching |
UFW / iptables |
Host-based firewall and real-time IP blocking |
Wazuh Agent |
SIEM integration with custom detection rules |
Bash |
Detection engine, response automation, evidence collection |
JSON |
Structured alert format for SIEM ingestion |
Python |
Log parsing and audit event processing via auditd |
tcpdump |
Packet capture during evidence collection |
hydra |
SSH brute force simulation (attacker VM) |
nmap |
Network reconnaissance simulation (attacker VM) |
tmux |
Multi-terminal session management on Ubuntu Server |
sha256sum |
Evidence integrity and chain of custody |
| Phase | Implementation |
|---|---|
| Preparation | auditd rules, Fail2ban config, UFW baseline, detection engine as systemd service |
| Detection & Analysis | detect_incident.sh β threshold-based detection, JSON alerts, 30s polling cycle |
| Containment | respond.sh β iptables DROP, UFW deny, hosts.deny, process termination |
| Eradication | Playbooks with manual eradication steps and verification commands |
| Recovery | Recovery checklists in each playbook |
| Post-Incident | Auto-generated Markdown reports with timeline, evidence, and recommendations |
| File | Scenario | MITRE |
|---|---|---|
playbooks/playbook-ssh-bruteforce.md |
SSH Brute Force β detection, containment, recovery | T1110.001 |
playbooks/playbook-port-scan.md |
Network Reconnaissance β detection, containment | T1046 |
β οΈ Disclaimer: This project was conducted in an isolated VMware lab environment for educational purposes only. All attack simulations were performed on systems owned and controlled by the author. Do not use these scripts or techniques against systems you do not own or have explicit permission to test.
alexrepsec Cybersecurity enthusiast | Home Lab Builder
This project was built as part of a cybersecurity portfolio to demonstrate practical incident response, SOC automation, and blue team skills.



