Detection rules › Splunk
Windows Copy Files (PowerShell)
Adversaries may search local system sources, such as file systems or local databases, or network shares to find files of interest and sensitive data prior to Exfiltration. Interactive command shells may be in use, and common functionality within cmd may be used to gather information. These events are only detected when a new process is created, or if powershell logging is enabled and used
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059 Command and Scripting Interpreter |
| Collection | T1005 Data from Local System, T1039 Data from Network Shared Drive |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4103 | Payload Context: ContextInfo User Data: UserData. |
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '5685.5945'
title: Windows Copy Files
description: 'Adversaries may search local system sources, such as file systems or
local databases, or network shares to find files of interest and sensitive data
prior to Exfiltration. Interactive command shells may be in use, and common functionality
within cmd may be used to gather information. These events are only detected when
a new process is created, or if powershell logging is enabled and used. Threat Actor
Association: APT29, Evilnum, REvil, TA428, Vice Society Software Association: Black
Basta, SamSam Atomics T1505.003 Test #1'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4103) OR
TERM(EventCode=4104)) (TERM(Copy-Item) OR TERM(copy) OR TERM(xcopy) OR TERM(cp)
OR TERM(cpi) OR TERM(robocopy)) | regex process="(?i)(Copy\-Item|(^|\s)copy|xcopy(\.exe\"?)?|[^\-]cp|[^\-]cpi|robocopy(\.exe\"?)?)\s+.{1,}?"
| rex field=process (?<copy>"(Copy-Item|copy|xcopy|cp|cpi|robocopy)\s+.{25}")| rex
field=Message "(?i)script\s+?name\s+?\=\s+?(?<script>.{1,}?\.ps1)" | eval script=mvappend(Path,
script) | table _time, host, user signature_id, process, process_*, script, copy
| bin span=1s | stats values(*) as * by _time, host '
techniques:
- collection:data from local system
- execution:command and scripting interpreter
- collection:data from network shared drive
technique_id:
- T1005
- T1059
- T1039
data_category:
- PowerShell logs
- Process command-line parameters
references:
- https://book.hacktricks.xyz/exfiltration
- https://www.computerhope.com/xcopyhlp.htm
Stages and Predicates
Stage 1: search
search EventCode=4103 EventCode=4104 source="*" source IN ("WinEventLog:Microsoft-Windows-PowerShell/Operational", "WinEventLog:Windows", "XmlWinEventLog:Microsoft-Windows-PowerShell/Operational")
Stage 2: regex
regex match(process, "(?i)(Copy\-Item|(^|\s)copy|xcopy(\.exe\"?)?|[^\-]cp|[^\-]cpi|robocopy(\.exe\"?)?)\s+.{1,}?")
Stage 3: rex
rex field=process ... -> copy
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.
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.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | TERM |
| 1 | "Copy-Item" |
| 1 | TERM |
| 1 | copy |
| 1 | TERM |
| 1 | xcopy |
| 1 | TERM |
| 1 | cp |
| 1 | TERM |
| 1 | cpi |
| 1 | TERM |
| 1 | robocopy |