Detection rules › Splunk

Access Common Package Config file (PowerShell)

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

Adversaries may establish persistence and/or elevate privileges using system mechanisms that trigger execution based on specific events. An Adversary with access could identify or modify configuration of packages in order to execute code and evade defenses.

MITRE ATT&CK coverage

TacticTechniques
PersistenceT1546 Event Triggered Execution
Privilege EscalationT1546 Event Triggered Execution

References

Event coverage

Rule body yaml

id: '5986.6348'
title: Access Common Package Config file
description: 'Adversaries may establish persistence and/or elevate privileges using
  system mechanisms that trigger execution based on specific events. An Adversary
  with access could identify or modify configuration of packages in order to execute
  code and evade defenses. '
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` TERM(EventCode=4104) (TERM(vi)
  OR TERM(vim) OR TERM(nano) OR TERM(visudo) OR TERM(edit) OR (TERM(copy) TERM(con))
  OR TERM(cat) OR TERM(more) OR TERM(gc) OR TERM(get-Content) OR TERM(type) OR ">>"
  OR ">") ("requirements.txt" OR "pip.conf" OR "package.json" OR "gemspec" OR "gemrc")
  | regex process="(?i)(vi|vim|nano|visudo|edit|copy\s+con|cat|more|gc|get-content|type|\>\>|\>)\s+.+(requirements\.txt|pip\.conf|package.json|\.gemspec|gemrc)"
  | table _time, host, user, process, process_*, signature_id | bin span=1s | stats
  values(*) as * by _time, host '
techniques:
- persistence:event triggered execution
- privilege-escalation:event triggered execution
technique_id: 
- T1546
data_category:
- Process command-line parameters
- PowerShell logs
references:
- https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_powershell` TERM(EventCode=4104) (TERM(vi) OR TERM(vim) OR TERM(nano) OR TERM(visudo) OR TERM(edit) OR (TERM(copy) TERM(con)) OR TERM(cat) OR TERM(more) OR TERM(gc) OR TERM(get-Content) OR TERM(type) OR ">>" OR ">") ("requirements.txt" OR "pip.conf" OR "package.json" OR "gemspec" OR "gemrc")

Stage 2: regex

| regex process="(?i)(vi|vim|nano|visudo|edit|copy\s+con|cat|more|gc|get-content|type|\>\>|\>)\s+.+(requirements\.txt|pip\.conf|package.json|\.gemspec|gemrc)"

Stage 3: table

| table _time, host, user, process, process_*, signature_id

Stage 4: bucket

| bin span=1s

Stage 5: stats

| stats values(*) as * by _time, host

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
EventCodeeq
  • 4104 corpus 268 (splunk 268)
processregex_match
  • "(?i)(vi|vim|nano|visudo|edit|copy\s+con|cat|more|gc|get-content|type|\>\>|\>)\s+.+(requirements.txt|pip.conf|package.json|.gemspec|gemrc)" corpus 4 (splunk 4)

Search terms

Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.

StageTerm
1TERM
1TERM
1vi
1TERM
1vim
1TERM
1nano
1TERM
1visudo
1TERM
1edit
1TERM
1copy
1TERM
1con
1TERM
1cat
1TERM
1more
1TERM
1gc
1"get-Content"
1TERM
1type
1">>"
1">"
1"requirements.txt"
1"pip.conf"
1"package.json"
1"gemspec"
1"gemrc"