Incident Response with journald
A server has been compromised. You investigate the incident systematically: filter journald logs, identify suspicious logins and processes, reconstruct a timeline, isolate compromised services, and write an incident report. University level — SOC analyst workflow in practice. 5 tasks, about 90 minutes.
Investigate a server incident
Incident response: investigating a server breach
A server has been compromised — an attacker gained access. As an analyst you must systematically find out: who got in, how, what they did, and how to stop them. This structured process is called incident response and is the daily work of a SOC analyst (Security Operations Center).
Key terms
journald/journalctl: the central logging system of modern Linux servers.journalctlsearches these logs.- Persistence: mechanisms an attacker uses to embed themselves permanently (e.g. a hidden cronjob that runs regularly).
- Timeline: the chronological reconstruction of the attack — the backbone of any incident report.
- Containment: isolating the threat so no further damage occurs.
Your goal
You filter suspicious logins, find the malicious cronjob, build a timeline, isolate the compromised service, and write an incident report — university level.
Exercises
1. Find failed logins
Step 1: who attacked? Failed SSH logins reveal the IP addresses of a brute-force attack. You filter them from the journal and save the attacker IPs.
Create the working folder and extract the source IPs of the failed logins:
mkdir -p /home/student/incident journalctl -u ssh | grep -i "failed password" | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort -u > /home/student/incident/suspicious-ips.txtgrep -oEpulls out only the IP addresses,sort -umakes them unique.Check:
/home/student/incident/suspicious-ips.txtis not empty.2. Identify suspicious cronjob
Step 2: find persistence. Attackers use cronjobs to embed themselves permanently — an entry that regularly starts, say, a reverse shell survives every reboot. You find it by checking all crontab locations.
Search the cron directories and copy the suspicious line into a file:
sudo grep -rE "bash|curl|wget|nc|/tmp/" /etc/crontab /etc/cron.d/ /var/spool/cron/ 2>/dev/nullPut the malicious line you found into the file (
nano /home/student/incident/malicious-cron.txt).Check:
/home/student/incident/malicious-cron.txtis not empty.3. Reconstruct attack timeline
Step 3: reconstruct the timeline. A chronological timeline shows the entry point, the attacker's actions and the impact in the right order — without it nobody can follow the incident. Use the timestamps from the journal.
Write timestamp + event per line (at least 3 lines) into
timeline.txt, e.g.:2026-05-28 02:14 First successful SSH login from attacker IP 2026-05-28 02:17 Malicious cronjob created in /etc/cron.d/ 2026-05-28 02:19 Unknown service 'rogue-agent' startedHelpful for research:
journalctl --since "today" | less.Check:
/home/student/incident/timeline.txtcontains at least 3 lines.4. Isolate compromised service
Step 4: containment. As long as the compromised service runs, the attacker can stay active. You must stop it (immediate damage halted) and disable it (won't restart after reboot — the persistence is gone).
Stop and disable the malicious
rogue-agentservice:sudo systemctl stop rogue-agent sudo systemctl disable rogue-agentCheck:
systemctl is-active rogue-agentreportsinactiveandsystemctl is-enabled rogue-agentreportsdisabled.5. Write incident report
Step 5: incident report. A good report starts with a summary (decision-makers often read only that) and ends with recommendations (so the same attack doesn't work again). This closes the loop: lessons learned.
Write a structured report (
nano /home/student/incident/report.md) containing at least these sections:# Incident report ## Summary Briefly: what happened, when, what impact. ## Timeline (reference timeline.txt) ## Affected systems ... ## Recommendations - Reset passwords - Enforce public-key auth, disable password login - Set up monitoring/fail2banCheck:
/home/student/incident/report.mdcontains a heading "Summary" (or "Zusammenfassung") and "Recommendations" (or "Empfehlungen").
Now practice it yourself
Reading is good – doing is better. Start this course on a real Linux VM, right in your browser. A free account is all it takes.
Start for freeLab content under CC BY 4.0 – free to use with attribution (© TechLogia).
