Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Incident Response Planning and Execution Lab

Bash Python JSON Ubuntu Kali Wazuh VMware MITRE

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.


πŸ“‹ Table of Contents


Overview

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.


Lab Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        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)

How It Works

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

Scenarios Covered

# 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

Lab Results β€” Real Attack Captured

Attack Detection

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).

Detection and automated response triggered


IP Containment β€” iptables DROP Rules

All traffic from the attacker IP was dropped at the kernel level via iptables, with additional blocks applied through UFW and /etc/hosts.deny.

iptables DROP rules applied to attacker IP


Evidence Collected

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.

Evidence directory structure


Incident Report β€” Auto-Generated

A structured Markdown incident report was generated automatically, including containment actions taken, evidence paths, and next-step recommendations.

Auto-generated incident report


Alert Format (JSON)

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"
}

Project Structure

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

Setup

Prerequisites

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

VM1 β€” Defender Setup

# 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

VM2 β€” Attacker Setup

# 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 -V

Evidence Structure

After 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

Tools & Technologies

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

NIST IR Framework Alignment

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

Playbooks

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.


πŸ‘€ Author

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.

About

A fully functional home lab simulating a real-world attacker vs. defender scenario built on VMware with Ubuntu Server and Kali Linux.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages