Detection rules › Splunk

Clear Linux System Logs

Group by
_time, host
Source
github.com/anvilogic-forge/armory

This use case would detect the alteration or removal of log files

MITRE ATT&CK coverage

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>.+")

The parser skipped this rex command.

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.

FieldKindExcluded valuesSearch
processregex_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.

FieldKindValuesSearch
processregex_match
  • "(?i)(vi|vim|nano|echo.*\>|visudo|rm|shred|wipe)\s"
  • "(?i)dd\s.*if[^a-z0-9]"
  • "(?i)tee"
  • "(?i)truncate\s"
field:"CommandLine" kind:regex_match
sourcetypeeq
  • bash_history
field:"sourcetype" kind:eq value:"bash_history"
typeeq
  • execve
  • proctitle
field:"type" kind:eq

Search terms

These SPL tokens match against raw event text.

StageTerm
1vi
1vim
1nano
1echo
1">"
1visudo
1rm
1dd
1if
1cat
1"/dev/null"
1truncate
10
1tee
1shred
1wipe
1"auth.log"
1faillog
1secure
1syslog
1messages
1utmp
1wtmp
1"kern.log"
1"audit.log"
1"cron.log"
1"error.log"
1"access.log"
1"boot.log"
1"mysqld.log"
1httpd
1"yum.log"
1covermyass