Advanced Linux Detection and Forensics CheatSheet
Advanced Linux Detection and Forensics CheatSheet
/proc:
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
/proc/PID/fdinfo → Contains one entry for each file that the process has open
/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/net/nf_conntrack → records the source IP, destination IP, and other information
of a TCP connection in the ESTABLISHED state
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
/proc/mounts → Lists of all the filesystems currently mounted on the system
/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
/sys:
/sys/kernel/debug/tracing/enabled_functions → contains a list of kernel functions
that are currently enabled for tracing
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Logs:
/var/log/messages → Contains global system messages, including the messages that
are logged during system startup
/var/log/syslog → Contains messages that are recorded by the host about the system
activity
journalctl --file X.journal -o verbose > journal.txt → Dump journald logs with verbose
output
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
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?coupon=7G92Q2I-YO
readelf →Display information about ELF files
ltrace → intercepts and records the dynamic library calls which are called by the
executed process and the signals which are received by that process
ip link show | grep xdp →Find if any of network interfaces have XDP enabled
ip link show | grep qdisc →Find if any of network interfaces have Traffic Control
enabled
dmesg | grep taint → Check kernel message buffer for tainted kernel modules
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
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?coupon=7G92Q2I-YO
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
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?coupon=7G92Q2I-YO
Files/directories/attributes:
.bash_history → Get the command history for the Bash shell
.ftp_history → Get the command history for the FTP (File Transfer Protocol) client
.git/logs → Get log files that track changes to the repository’s references and branches
/etc/fstab → Contains descriptive information about the filesystems the system can
mount
.ssh/authorized_keys → Get a list of public SSH keys that are authorized to access the
user’s account
.ssh/known_hosts → Stores information about the public keys of remote SSH servers
.gitconfig → Get settings and preferences for Git repositories and user accounts
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
/etc/ld.so.preload → Contains a whitespace-separated list of ELF shared objects to be
loaded before the program
/lib64/ld-2.X.so → Dynamic linker which finds and loads the shared objects (shared
libraries) needed by a program
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
hidden-files.sh → Reveal hidden files
hidden-pids.sh → Reveal rootkits that hide processes from getdents() calls to /proc
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
thieves.sh → Reveal programs whose process space may have been taken over by
another program
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?coupon=7G92Q2I-YO
unexpected-dns-traffic.sh → Catch DNS traffic going to machines other than the
host-configured DNS server
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
unexpected-libcurl-user-linux.sh → Find programs processes which link against
libcurl
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
yara-unexpected-upx-process.sh → Find currently running processes backed by UPX
executable
Default Dynamic Loader Modification → Tracks changes to the default binary loader.
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Docker Socket Abuse → Flags potential Docker socket misuse
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
RCD Modification → Monitors changes to the remote control daemon
Disallowed SSH Connection → Detect any new ssh connection to a host other than
those in an allowed group of hosts
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Network connection outside authorized port and binary → Detects traffic that is not
to authorized server
process and port
Possible miner running → Detects crypto miners using the Stratum protocol
File created below /dev by untrusted program →Detects creating any files below
/dev other than known programs
that manage devices. Some rootkits
hide files in /dev.
File created below /etc by untrusted program → Detects creating any files below
/etc
File below /etc opened for writing → Detects attempt to write to any file below /etc
File below / or /root opened for writing → Detects an attempt to write to any file
directly below / or /root
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Shell configuration file has been modified → Detects attempt to modify shell
configuration files
Cron jobs were scheduled to run → Detects modifications and executions of cron
jobs
Known system binary sent/received network traffic → Identifies any network activity
performed by system binaries that are not expected to send or receive any network
traffic
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Unexpected UDP Traffic Seen → Detects UDP traffic not on port 53 (DNS) or other
commonly used ports
Network tool launched on host → Detects network tools launched on the host
Shell history had been deleted or renamed → Detects bash history deletion
Symlinks created over sensitive files → Detects symlink created over sensitive files
Hardlinks created over sensitive files → Detects hardlink created over sensitive files
Java process class file download → Detects Java process downloading a class file
which could indicate a successful exploit
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Mount was executed inside a privileged container → Detects file system mount
happened inside a privileged
container
Linux Kernel Module injection using insmod detected → Detects if kernel module
was injected
Execve script → Generated under the same conditions as execve event. The only
difference is that it provides additional information about the
interpreter when the file being executed is a script
Exit group → Generated when a thread-group (process and all its threads) exits
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Clone → A task is being cloned/forked. This means that a new task will be created on
the system.
Init module → Generated when a kernel module is loaded into the kernel.
Bpf prog load → Generated every time a BPF program is loaded into the kernel.
Bpf Socket Filter Attached → A socket filter attachement has been made
Mmap exec → Generated whenever the mmap syscall is used to map an executable
file in memory, with memory execution protection.
Dns query → Generated when the a DNS response is received on the host and gives
insight both on the query, the response and the DNS resolver.
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
File unlink → Generated when a file gets unlinked
Privileges Escalation via SUID Binary Execution → Monitors execution of SUID “Set
User ID” binaries.
Privileges Escalation via Setuid system calls → Monitors execution of the setuid()
system calls family.
Privileges Change via Capset system call → Monitors execution of the capset()
system call.
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Fileless Execution → Monitors the execution of binaries that exist exclusively as a
computer memory-based artifact.
eBPF System Activity → Audits BPF program that loads and BPFFS interactions
Argus → a cutting-edge runtime security tool designed for both monitoring and enforcing
application behavior:
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
core_pattern_access → triggered when there is an attempt to modify the system's
core dump pattern, typically found at
/proc/sys/kernel/core_pattern
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
package_repo_config_modification → Triggered when there are modifications to
critical package management configuration
files across various Linux distributions. This
includes files like /etc/apt/sources.list,
/etc/yum.conf, and others
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Velociraptor IR → a tool for collecting host-based state information using The
Velociraptor Query Language (VQL) queries:
Generic.Detection.Yara.Glob → Returns a list of target files then runs Yara over the
target list
Linux.Sys.Maps → Parses the /proc/PID/maps to emit all mapped files into the
process
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Linux.Network.NM.Connections → Lists the NetworkManager state, all configured
connections and their settings
Generic.Forensic.LocalHashes.Query
Generic.Forensic.LocalHashes.Init
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Linux.Collection.BrowserExtensions → Collects Browser Extensions based on
TriageWebBrowserExtensions
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Linux.Forensics.RecentlyUsed → Parses the ‘recently-used.xbel’ XML file for all
standard Linux users
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Linux.Sysinternals.SysmonEvent → Parses syslog for Sysmon events on Linux
using a unix domain socket
Generic.System.Pstree → Displays the call chain for every process on the system by
traversing the process’s parent ID
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Exchange.Linux.Detection.BPF → Parses /proc/*/fd files and looks for processes
with anon_inode:bpf-map
Linux.Ssh.PrivateKeys → Searches for private keys in the usual locations and also
records if they are encrypted or not
Linux.Syslog.SSHLogin → Parses the auth logs to determine all SSH login attempts
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
to detect potential persistence
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
SANDFLY SECURITY → Sandfly is an agentless, instantly deployable, and safe
Linux security monitoring platform. Sandfly automates security investigation and forensic
evidence collection on Linux. To learn more visit: https://sandflysecurity.com/. Top 30 Sandfly
modules out of thousands:
process_deleted → Looks for processes that are running, but the executable has been
deleted from the disk
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
process_running_from_tmp_dir → Looks for processes that are running out of the
system temp directories
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
process_entropy_high → Looks for processes with high entropy indicating it may be
packed or encrypted which is common with malware and
malicious activity.
file_hidden_bin → Looks for any kind of hidden file under system binary directories
which is unusual behavior
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
user_default_user_ssh_authorized_keys_present → Looks for default Linux system
users that have a SSH
authorized_keys file presents that
could allow login
kernel_module_file_missing → Kernel modules that are loaded but don't have .ko files
in /lib/modules/
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
process_shell_running_empty_file_descriptors_command_mode → Looks for
processes
running with
empty file
descriptors
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
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
https://edu.defensive-security.com/linux-attack-live-forensics-at-scale?coupon=7G92Q2I-YO
Sandfly Security → The greatest agentless Linux intrusion detection and incident
response platform. Find Linux threats without endpoint agents
instantly → https://sandflysecurity.com/
LINKS:
● https://github.com/falcosecurity/falco
● https://github.com/aquasecurity/tracee
● https://github.com/cilium/tetragon
● https://listendev.github.io/argus/dev/overview/
● 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?coupon=7G92Q2I-YO