A practical guide to detecting SSH brute force, SUID abuse, persistence, and exfiltration using Splunk, auditd, and custom SPL queries
In this post, I’ll be going through the importance of a SIEM. A SIEM allows us to analyze systems, understand their behavior, and recognize dangerous patterns. In this blog, I’ll keep it simple. We’ll go over:
A SIEM centralizes logs from systems and services across your infrastructure. It gives you visibility into:
It becomes your eyes into your systems’ behavior and potential threats.
For this lab:
To enable detailed system monitoring, I created a custom audit ruleset located at:
/etc/audit/rules.d/audit.rules
Click below to expand audit.rules
-D
-b 8192
-f 1
--backlog_wait_time 60000
## === EXECUTION ===
-a always,exit -F arch=b64 -S execve -k exec_log
-a always,exit -F arch=b32 -S execve -k exec_log
-w /bin/bash -p x -k bash_exec
-w /bin/sh -p x -k sh_exec
-w /usr/bin/nc -p x -k netcat_use
-w /usr/bin/ncat -p x -k netcat_use
-w /usr/bin/ssh -p x -k ssh_use
## === PRIV ESCALATION ===
-a always,exit -F arch=b64 -S setuid,setgid -k priv_esc
-a always,exit -F arch=b32 -S setuid,setgid -k priv_esc
## === PERSISTENCE ===
-w /etc/cron.allow -p wa -k cron_mod
-w /etc/cron.d/ -p wa -k cron_mod
-w /etc/cron.daily/ -p wa -k cron_mod
-w /etc/crontab -p wa -k cron_mod
-w /etc/systemd/system/ -p wa -k systemd_backdoor
-w /etc/rc.local -p wa -k rc_persistence
## === LOG TAMPERING ===
-w /var/log/ -p wa -k log_tamper
-w /root/.bash_history -p wa -k history_clear
-w /home/abdullah/.bash_history -p wa -k history_clear
## === EXFILTRATION ===
-w /usr/bin/scp -p x -k exfil
-w /usr/bin/wget -p x -k exfil
-w /usr/bin/curl -p x -k exfil
-w /usr/bin/ftp -p x -k exfil
-w /usr/bin/sftp -p x -k exfil
## === NETWORK ACTIVITY ===
-a always,exit -F arch=b64 -S connect -k netconn
-a always,exit -F arch=b32 -S connect -k netconn
-a always,exit -F arch=b64 -S socket -k socket_create
-a always,exit -F arch=b32 -S socket -k socket_create
## === PROCESS ACTIVITY ===
-a always,exit -F arch=b64 -S fork,vfork,clone -k proc_spawn
-a always,exit -F arch=b32 -S fork,vfork,clone -k proc_spawn
## === SSH BRUTEFORCE LOGGING ===
-w /var/log/secure -p r -k ssh_brute
This ruleset enables logging for:
execve
, /bin/bash
, /bin/sh
)setuid
, chmod +s
)cron.d
, rc.local
, systemd
)/etc/shadow
, .bash_history
)/tmp
, /var/tmp
, /dev/shm
)connect
, socket
)scp
, curl
, wget
, ftp
)These audit rules allow Splunk to receive enriched log events from auditd
via rsyslog
, providing full visibility into attacker behavior without requiring agents or kernel modules.
Below is the custom dashboard I created in Splunk. It covers detections such as SSH brute force, sudo usage, SUID escalation, persistence via cron, suspicious temp files, and data exfiltration.

We log all sudo
command executions to monitor privileged access usage.
SPL:
index="linux_logs" sourcetype="syslog" host="rocky-web01" "sudo"
| rex field=_raw "sudo\\[\\d+\\]: (?<executing_user>[^ ]+) : TTY=[^;]+ ; PWD=(?<pwd>[^;]+) ; USER=(?<user>[^;]+) ; COMMAND=(?<command>.+)"
| where isnotnull(command)
| table _time executing_user user pwd command
| sort -_time
We monitor failed SSH logins, highlighting brute-force attempts.
SPL:
index="linux_logs" sourcetype="syslog" "authentication failure"
| stats count as "SSH Failures"
and
index="linux_logs" sourcetype="syslog" "sshd" "Failed password"
| rex "Failed password for (invalid user )?(?<username>\w+) from (?<attacker_ip>\d+\.\d+\.\d+\.\d+)"
| stats count by attacker_ip
| sort -count
This helps confirm who successfully logged in via SSH and from where.
SPL:
index="linux_logs" sourcetype="syslog" "sshd" ("USER_START" OR "USER_AUTH")
| rex "acct=\"(?<user>[^\"]+)"
| rex "addr=(?<ip>\d+\.\d+\.\d+\.\d+)"
| rex "exe=\"(?<exe>[^\"]+)"
| search res=success exe="/usr/sbin/sshd"
| dedup _time, user, ip
| table _time, host, user, ip
| sort -_time
Executed SUID binaries and suspicious chmod +s
events are flagged.
SPL:
index="linux_logs" sourcetype="syslog" ("type=EXECVE" OR "type=SYSCALL") ( "chmod" OR "u+s" )
| rex field=_raw "msg=audit\\((?<audit_id>[^)]+)\\):"
| eventstats values(_raw) as all_logs by audit_id
| eval joined = mvjoin(all_logs, " ")
| rex field=joined "(?<uid_field>(A|E|F|S)?UID)=\"?(?<user>[^\\s\"]+)\"?"
| rex field=joined "a2=\\\"(?<target_file>[^\"]+)"
| stats latest(_time) as _time values(user) as user values(target_file) as target_file values(host) as host by audit_id
| table _time host user target_file
We watch for file modifications or executions under cron directories.
SPL:
index="linux_logs" sourcetype="syslog" host="rocky-web01"
"COMMAND=" "/etc/cron.d"
| rex "COMMAND=(?<command>.+)"
| rex "sudo\\[\d+\\]: (?<user>\w+)"
| where isnotnull(command) AND isnotnull(user)
| table _time, host, user, command
| sort -_time
Common post-exploitation tools or malware may run from /tmp
, /var/tmp
, or /dev/shm
.
SPL:
index="linux_logs" sourcetype="syslog" ("/tmp/" OR "/dev/shm/" OR "/var/tmp/")
| rex "a1=\"(?<executed>[^\"]+)"
| where like(executed, "/tmp/%") OR like(executed, "/dev/shm/%") OR like(executed, "/var/tmp/%")
| table _time, host, executed
| dedup _time, host, executed
| sort -_time
Detects data being posted or copied out of the system.
SPL:
index="linux_logs" sourcetype="syslog" ("curl" OR "scp")
| rex "COMMAND=(?<command>.+)"
| search command="*POST*" OR command="*scp*" OR command="*/etc/shadow*"
| table _time, host, user, command
| sort -_time
This detection lab maps to multiple MITRE ATT&CK techniques, including:
Technique | Description | Covered by |
---|---|---|
T1078 | Valid Accounts | Successful SSH login tracking |
T1110.001 | Brute Force: Password Guessing | SSH brute force detection |
T1059 | Command and Scripting Interpreter | execve , bash/sh audit rules |
T1547.001 | Boot or Logon Autostart via cron | Cron job modification detection |
T1546.004 | Event Triggered Execution: systemd | Watching /etc/systemd/system |
T1055 | Process Injection (via SUID abuse) | Detection of SUID privilege escalation attempts |
T1041 | Exfiltration over C2 channel | Curl, scp-based exfiltration detection |
This lab demonstrates how a SIEM can provide immediate visibility into system behavior and attacker activity. With even minimal log sources and audit rules, we can:
With more data and tuning, this can evolve into a highly effective detection and response platform. This project reflects real-world detection use cases and demonstrates hands-on skills in log analysis, Splunk SPL and Linux internals.