Lesson 10 of 19 · 24m
Linux Host Forensics: What Actually Survives a Compromise
journald persistence, auditd coverage, wtmp/utmp, package-manager integrity checks, and the systemd/cron/ssh persistence survey — everything except bash_history, which is decorative.
~/.bash_history is the first thing an analyst opens on a compromised Linux box and the last thing the evidence should rest on. No HISTTIMEFORMAT means no timestamps. HISTCONTROL=ignorespace — a bash default on many distros — means any command prefixed with a space is never written at all. unset HISTFILE followed by kill -9 $$ drops the whole session buffer before bash can flush it. And a non-interactive payload shell — bash -c, a reverse shell over socat, a cron-fired one-liner — never writes history in the first place. The history file isn't a log; it's a scratchpad the attacker controls.
journald and syslog: check persistence before you read
journalctl is the modern log spine, but its durability is a config question, not a default. /var/log/journal only exists when Storage=persistent in /etc/systemd/journald.conf; with Storage=auto on many distros the journal lives in volatile /run/log/journal and evaporates on reboot — the reboot the attacker may have just caused. Check the directory exists before you quote journal gaps as findings. Where syslog exists, auth.log (Debian/Ubuntu) and secure (RHEL-family) carry the sshd session lines; wtmp/utmp/btmp feed last, lastlog, and lastb for the raw login record. And note the spoofing caveat: anyone can logger a forged auth-looking line into syslog — the syslog socket takes anonymous input — so corroborate auth.log entries against journald's own records where both exist.
auditd: the tool that only helps if you had it
auditd records execve syscalls, file watches, and security-relevant syscalls into /var/log/audit/audit.log — but only for rules defined in /etc/audit/rules.d before the incident. auditctl -l shows what was being watched. If auditd wasn't deployed, it retroactively knows nothing; the honest output of this incident is a ruleset — execve logging, watches on /etc/passwd, /etc/sudoers, sshd configs, cron dirs — ending in -e 2 so the config can't be edited without a reboot. That line goes in the postmortem, not this investigation.
The persistence survey
Linux persistence is mostly additions, so enumerate what changed:
- systemd: units and symlinks in
/etc/systemd/system,/usr/lib/systemd/system,~/.config/systemd/user— including masked units and.timerunits (systemctl list-timers --all) which fire without a cron-looking artifact. - cron/at:
/etc/crontab,/etc/cron.*,/var/spool/cron/*,@rebootlines, and pendingatjobs. - ssh: appended keys in every
authorized_keys(diff comments and key material against provisioning records),Includedirectives added tosshd_config,AuthorizedKeysCommand,PermitRootLogindeltas. - ld preload / PAM:
/etc/ld.so.preloadcontents,LD_PRELOADexports inside service unit files, edits to files under/etc/pam.d. - identity/escalation primitives: new UID-0 accounts (
awk -F: '$3==0' /etc/passwd), fresh SUID/SGID binaries (find / -xdev \( -perm -4000 -o -perm -2000 \) -type f), rc.local, shell rc files. - kernel:
lsmodagainst a known-good module list; userland rootkits hide viaLD_PRELOAD, kernel ones hide from/proc/modulesitself.
Proving binaries honest: package manifests
rpm -Va (RPM systems) and debsums -s / dpkg -V (Debian) verify every package-owned file's hash against the vendor manifest — the direct test for a modified sshd or sudo binary. Their blind spot is symmetric: files the attacker added aren't in any manifest, so a clean -V run doesn't clear the box — it clears the vendor-owned files. If AIDE or Tripwire was deployed, its baseline is the answer to both halves.
The trust hierarchy
Rank Linux evidence by how far it sits from attacker control: off-box syslog forwarder > persistent journald > auditd > wtmp/auth.log > shell history. The local logs are contested by definition; a host forwarding syslog to a collector the attacker never touched is the copy that matters. And if you captured RAM before shutdown, Volatility's linux.bash — built on a dwarf2json symbol file for the exact kernel — recovers the session's shell history straight out of memory, which is the answer to a wiped ~/.bash_history.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
Attacks of UPS Devices are on the Rise warns CISA
Hackers have now begun to attack internet-connected universal power supply devices. They are targeting their control interfaces via multiple remote code execution vulnerabilities. In some of the cases, they changed the default usernames and passwords, according to an important advisory from the…
Immich Had Fourteen Advisories and One Bug It Fixed Three Times
Immich's 2026 security record runs to fourteen advisories, and they cluster hard: the sharing features, the OAuth plumbing, and one login redirect parameter that took three separate fixes across eighty-three days. Plus the 3.0 migration traps still waiting for anyone who hasn't jumped yet.
Jellyfin's Threat Model Is Your Brother-in-Law
Four Jellyfin CVEs landed in 2026 and not one of them needs an admin account. One needs only the ability to name a file. Meanwhile Jellyfin 12 shipped in September, the version numbers stopped starting with 10, and every "am I patched" check you wrote is now wrong.