Advanced Linux Detection and Forensics Cheatsheet by Defensive Security
Advanced Linux Detection and Forensics Cheatsheet by Defensive Security
/proc:
/proc/PID/fdinfo → Contains one entry for each file that the process has open
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
/proc/PID/environ → Display environment variables per process
/proc/PID/comm → Exposes the process's comm value - that is, the command name
associated with the process
/proc/PID/cwd → Gets a symbolic link to the current working directory of the process
/proc/PID/stack → Symbolic trace of the function calls in this process's kernel stack
/proc/PID/fd/* | grep bpf-map → Get file descriptors per process with bpf-map type
/proc/PID/fd/* | grep bpf-prog → Get file descriptors per process with bpf-prog type
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
/sys:
/sys/kernel/debug/tracing/trace →
/sys/module/$module/taint →
Black Hat USA 2024 Training → Practical Linux Attack Paths and
Hunting for Red and Blue Team by Leszek Miś / AUGUST 3-6 2024
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
"Practical Linux Attack Paths and Hunting for Red and Blue Team" training has been created
with a focus on realistic hands-on experience in analyzing user space and kernel space Linux
rootkits, including recent Linux APT campaigns, C2 frameworks for Linux with a focus on
Sliver/Metasploit overview/behavior vs hunting/DFIR tooling in Linux ecosystem. This training
helps create and understand low-level Linux attack paths, improve your Linux detection
coverage, see in action many Open Source DFIR/defensive projects, and understand the need
for Linux telemetry, especially including Linux/Docker/Kubernetes clusters where Runtime
Security solutions are a must these days.
Register here:
https://www.blackhat.com/us-24/training/schedule/#practical-linux-attack-paths-and-hunting-
for-red-and-blue-team-36776
Logs:
/var/log/syslog → Contains messages that are recorded by the host about the system
activity
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
/var/log/cron → Cron logs
journalctl --file X.journal -o verbose > journal.txt → Dump journald logs with verbose
output
CLI/tools:
lsmod → Display the status of modules in the Linux Kernel by reading /proc/modules
lsof → "list open files” tool is a robust interface for the information inside the /proc
virtual filesystem
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
dd if=mem bs=1 skip=ADDRESS count=1000 of=/tmp/dumped_proc_file → Extract
memory content (1000 bytes) at specified ADDRESS
ltrace → intercepts and records the dynamic library calls which are called by the
executed process and the signals which are received by that process
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
dmesg | grep taint →
mount → Read /proc/mounts, watch for bind mounted PID dirs to random dir
ausearch → Query the audit daemon logs for events based on different search
criteria
chkconfig --list → Display a list of all services and their current configuration
loginctl user-status UID --full → May be used to introspect and control the state of
the systemd login manager per user
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
dnf list installed → Display installed packages
rpm -V -a → Verify all packages to compare information about the installed files in the
package with information about the files taken from the package
metadata stored in the rpm database
debsums → Verify installed Debian package files against MD5 checksum lists from
/var/lib/dpkg/info/*.md5sums
tc qdisc →
log2timeline.py → extract events from individual files and creates a Plaso storage file
LKRG → Performs runtime integrity checking of the Linux kernel and detection of
security vulnerability exploits against the kernel
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Files/directories/attributes:
.bash_history →
.mysql_history →
.ftp_history →
.git/logs →
/etc/passwd →
/etc/group →
/etc/fstab →
/etc/ssh/sshd_config →
/etc/sudoers →
.ssh/authorized_keys →
.ssh/known_hosts →
.viminfo →
.gitconfig →
/boot/initrd.img →
/etc/ld.so.preload →
/dev/shm/ →
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
/dev/ →
/etc/pam.d →
hidden-pids.sh → Reveal rootkits that hide processes from getdents() calls to /proc
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
ld-so-preload.sh → Find preload entries
thieves.sh → Reveal programs whose process space may have been taken over by
another program
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
unexpected-ebpf-hooks.sh → Detect suspicious bpf hooks
low-fd-socket.sh → Find programs where fd0 (stdin), fd1 (stdout), or fd2 (stderr) are
connected to a socket
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
unexpected-active-systemd-units.sh → Unexpected systemd units, may be evidence
of persistence
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
unusual-executable-name-linux.sh → Detect processes with executable names that
are potentially suspicious
Hack In The Box Bangkok 2024 Training → Practical Linux Attack Paths
and Hunting for Red and Blue Team by Leszek Miś / 26-28 August 2024
"Practical Linux Attack Paths and Hunting for Red and Blue Team" training has been created
with a focus on realistic hands-on experience in analyzing user space and kernel space Linux
rootkits, including recent Linux APT campaigns, C2 frameworks for Linux with a focus on
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Sliver/Metasploit overview/behavior vs hunting/DFIR tooling in Linux ecosystem. This training
helps create and understand low-level Linux attack paths, improve your Linux detection
coverage, see in action many Open Source DFIR/defensive projects, and understand the need
for Linux telemetry, especially including Linux/Docker/Kubernetes clusters where Runtime
Security solutions are a must these days.
Register here:
https://conference.hitb.org/hitbsecconf2024bkk/product/practical-linux-attack-paths-bkk2024
Cgroups Release Agent File Modification → Detects changes to the cgroup release_agent
Core Dumps Config File Modification → Monitors core dump configuration alterations.
Default Dynamic Loader Modification → Tracks changes to the default binary loader.
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Hidden Executable File Creation → Detects creation of hidden executable files
Kubernetes API Server Connection → Detects connections to the Kubernetes API server
File Operations Hooking on Proc Filesystem → Detects hooks on file operations in /proc
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
System Request Key Configuration Modification → Monitors system request key
configuration changes
Interactive root
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Shell configuration file has been modified
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Outbound connection to IP/Port flagged by https://cryptoioc.ch
Execve →
Execve script →
Exit →
Exit group →
Clone →
Prctl →
Init module →
Mprotect exec →
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Mmap exec →
Connect →
Dns query →
Send data →
Read →
Read config →
Write →
Write config →
File rename →
File unlink →
sudo Monitoring
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Privileges Escalation via Setuid system calls
Fileless Execution
Outbound Connections
Linux.Detection.MemFD
Linux.Detection.Yara.Process
Generic.Detection.Yara.Glob
Generic.Detection.Yara.Zip
Linux.Proc.Modules
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Linux.Sys.Maps
Linux.Sys.Pslist
Linux.Sys.SUID
Generic.Detection.WebShells
Linux.Memory.AVML
Linux.Detection.IncorrectPermissions
Linux.Network.NM.Connections
Linux.Debian.GPGKeys
Linux.Debian.AptSources
Linux.Debian.Packages
Linux.RHEL.Packages
Generic.Forensic.LocalHashes.Query
Generic.Forensic.LocalHashes.Init
Generic.Forensic.LocalHashes.Glob
Linux.PrivilegeEscalationDetection
Exchange.Linux.Kunai
Linux.LogAnalysis.ChopChopGo
Generic.Collection.UAC
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Linux.Detection.vRealizeLogInsightExploitation
Linux.Collection.Autoruns
Linux.Collection.BrowserExtensions
Linux.Collection.BrowserHistory
Linux.Collection.DBConfig
Linux.Collection.History
Linux.Collection.NetworkConfig
Linux.Collection.SysConfig
Linux.Collection.SysLogs
Linux.Collection.UserConfig
Linux.System.BashLogout
Linux.Sys.BashShell
Linux.Sys.LastUserLogin
Linux.Sys.Crontab
Linux.Forensics.RecentlyUsed
Linux.Sys.APTHistory
Linux.Sys.JournalCtl
Linux.Forensics.Journal
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Linux.Sys.SystemdTimer
Linux.Remediation.Quarantine
Linux.Detection.ConfluenceLogs
Linux.Detection.CVE20214034
Linux.Sys.LogHunter
Linux.Sys.Services
Linux.Sys.Users
Linux.Users.InteractiveUsers
Linux.Users.RootUsers
Linux.Sysinternals.SysmonEvent
Linux.Sysinternals.Sysmon
Generic.Detection.log4jRCE
Linux.Collection.CatScale
Linux.Applications.WgetHSTS
Linux.Network.Netstat
Linux.Network.NetstatEnriched
Linux.Network.PacketCapture
Linux.OSQuery.Generic
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
Generic.System.Pstree
Linux.Memory.Acquisition
Linux.Triage.ProcessMemory
Linux.Volatility.Create.Profile
Exchange.Linux.Detection.BPF
Exchange.Linux.System.PAM
Linux.Applications.Docker.Info
Linux.Applications.Docker.Version
Linux.Detection.AnomalousFiles
Linux.Mounts
Linux.Proc.Arp
Linux.Search.FileFinder
Linux.Ssh.AuthorizedKeys
Linux.Ssh.KnownHosts
Linux.Ssh.PrivateKeys
Linux.Syslog.SSHLogin
Linux.Detection.SSHKeyFileCmd
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
44CON London 2024 Training → Practical Linux Attack Paths and
Hunting for Red and Blue Team by Leszek Miś / 16–18 Sept 2024
"Practical Linux Attack Paths and Hunting for Red and Blue Team" training has been created
with a focus on realistic hands-on experience in analyzing user space and kernel space Linux
rootkits, including recent Linux APT campaigns, C2 frameworks for Linux with a focus on
Sliver/Metasploit overview/behavior vs hunting/DFIR tooling in Linux ecosystem. This training
helps create and understand low-level Linux attack paths, improve your Linux detection
coverage, and see in action many Open Source DFIR/defensive projects, and understand the
need for Linux telemetry, especially including Linux/Docker/Kubernetes clusters where
Runtime Security solutions are a must these days.
Register here:
https://44con.com/product/practical-linux-attack-paths-and-hunting-for-red-and-blue-team/
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
DFIR/Triage Tools:
varc → Volatile Artifact Collector collects a snapshot of volatile data from a system
lynis → Security auditing tool for Linux, macOS, and UNIX-based systems
Unhide → Forensic tool to find hidden processes and TCP/UDP ports by rootkits
sandfly-file-decloak → Decloak Linux stealth rootkits hiding data with this simple
memory mapped IO investigation tool
sandfly-process-decloak → Utility to quickly scan for Linux Process IDs (PIDs) that
are hidden by common and not-so-common loadable
kernel module stealth rootkits and decloak them so they
are visible
Sandfly Security → The greatest agentless Linux intrusion detection and incident
response platform. Find Linux threats without endpoint agents
instantly → https://sandflysecurity.com/
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale
LINKS:
● https://github.com/falcosecurity/falco
● https://github.com/aquasecurity/tracee
● https://github.com/cilium/tetragon
● https://github.com/Sysinternals/SysmonForLinux/
● https://why.kunai.rocks/
● https://github.com/chainguard-dev/osquery-defense-kit
● https://github.com/tstromberg/sunlight
● https://github.com/Velocidex/velociraptor
● https://github.com/lkrg-org/lkrg
● https://github.com/sandflysecurity/sandfly-file-decloak
● https://github.com/sandflysecurity/sandfly-processdecloak
● https://github.com/tclahr/uac
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale