Detection rules › Splunk
Clear Linux System Logs
This use case would detect the alteration or removal of log files
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth | |
| Defense Impairment |
References
Telemetry coverage
Rule body
id: '1141.1221'
title: Clear Linux System Logs
description: 'This use case would detect the alteration or removal of log files. Atomics
T1070.003 Test #3 Atomics T1070.003 Test #5'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_unix` (type=proctitle OR type=execve
OR sourcetype=bash_history) AND ((TERM(vi) OR TERM(vim) OR TERM(nano) OR (TERM(echo)
AND TERM(>)) OR TERM(visudo) OR TERM(rm) OR (TERM(dd) AND TERM(if)) OR (TERM(cat)
AND "/dev/null") OR (TERM(truncate) AND TERM(0)) OR (TERM(tee) AND NOT TERM(-a))
OR TERM(shred) OR TERM(wipe)) AND ("auth.log" OR TERM(faillog) OR TERM(secure) OR
TERM(syslog) OR TERM(messages) OR TERM(utmp) OR TERM(wtmp) OR "kern.log" OR "audit.log"
OR "cron.log" OR "error.log" OR "access.log" OR "boot.log" OR "mysqld.log" OR TERM(httpd)
OR "yum.log")) OR TERM(covermyass) | rex field=_raw "(?i)proctitle=(\")?(?<proc>.+")|
eval process=mvappend(process, proc) | regex process!="(?i)(\/)?(etc|home|opt|bin|sbin|dev|ext|lib|media|mnt|proc|root|sys|tmp|usr|boot)\/\w+"
| table _time, host, user, process, process_* | bin span=1s | stats values(*) as
* by _time, host | where match(process, "(?i)(vi|vim|nano|echo.*\>|visudo|rm|shred|wipe)\s")
OR match(process, "(?i)dd\s.*if[^a-z0-9]") OR match(process, "(?i)truncate\s") OR
(match(process, "(?i)tee") and not match(process, "(?i)tee\s.*-a")) '
techniques:
- defense-evasion:indicator removal:file deletion
- defense-evasion:indicator removal:clear linux or mac system logs
- defense-evasion:indicator removal:clear command history
technique_id:
- T1070.003
- T1070.002
- T1070.004
data_category:
- Process command-line parameters
- Linux audit logs
references:
- https://null-byte.wonderhowto.com/how-to/clear-logs-history-linux-systems-cover-your-tracks-remain-undetected-0244768/
- https://hackingpassion.com/clear-your-tracks-on-linux/
- https://null-byte.wonderhowto.com/forum/easily-cover-your-tracks-from-kali-linux-after-hacking-system-0205468/
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_unix` (type=proctitle OR type=execve OR sourcetype=bash_history) AND ((TERM(vi) OR TERM(vim) OR TERM(nano) OR (TERM(echo) AND TERM(>)) OR TERM(visudo) OR TERM(rm) OR (TERM(dd) AND TERM(if)) OR (TERM(cat) AND "/dev/null") OR (TERM(truncate) AND TERM(0)) OR (TERM(tee) AND NOT TERM(-a)) OR TERM(shred) OR TERM(wipe)) AND ("auth.log" OR TERM(faillog) OR TERM(secure) OR TERM(syslog) OR TERM(messages) OR TERM(utmp) OR TERM(wtmp) OR "kern.log" OR "audit.log" OR "cron.log" OR "error.log" OR "access.log" OR "boot.log" OR "mysqld.log" OR TERM(httpd) OR "yum.log")) OR TERM(covermyass)
Stage 2: rex
| rex field=_raw "(?i)proctitle=(\")?(?<proc>.+")
Stage 3: eval
| eval process=mvappend(process, proc)
Stage 4: regex
| regex process!="(?i)(\/)?(etc|home|opt|bin|sbin|dev|ext|lib|media|mnt|proc|root|sys|tmp|usr|boot)\/\w+"
Stage 5: table
| table _time, host, user, process, process_*
Stage 6: bucket
| bin span=1s
Stage 7: stats
| stats values(*) as * by _time, host
Stage 8: where
| where match(process, "(?i)(vi|vim|nano|echo.*\>|visudo|rm|shred|wipe)\s") OR match(process, "(?i)dd\s.*if[^a-z0-9]") OR match(process, "(?i)truncate\s") OR (match(process, "(?i)tee") and not match(process, "(?i)tee\s.*-a"))
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process | regex_match | "(?i)(\/)?(etc|home|opt|bin|sbin|dev|ext|lib|media|mnt|proc|root|sys|tmp|usr|boot)\/\w+" | excludes:process |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process | regex_match |
| field:"CommandLine" kind:regex_match |
sourcetype | eq |
| field:"sourcetype" kind:eq value:"bash_history" |
type | eq |
| field:"type" kind:eq |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | vi |
| 1 | vim |
| 1 | nano |
| 1 | echo |
| 1 | ">" |
| 1 | visudo |
| 1 | rm |
| 1 | dd |
| 1 | if |
| 1 | cat |
| 1 | "/dev/null" |
| 1 | truncate |
| 1 | 0 |
| 1 | tee |
| 1 | shred |
| 1 | wipe |
| 1 | "auth.log" |
| 1 | faillog |
| 1 | secure |
| 1 | syslog |
| 1 | messages |
| 1 | utmp |
| 1 | wtmp |
| 1 | "kern.log" |
| 1 | "audit.log" |
| 1 | "cron.log" |
| 1 | "error.log" |
| 1 | "access.log" |
| 1 | "boot.log" |
| 1 | "mysqld.log" |
| 1 | httpd |
| 1 | "yum.log" |
| 1 | covermyass |