| ID | Technique | Tactic |
|---|---|---|
| T1105 | Ingress Tool Transfer | Command and Control |
| T1197 | BITS Jobs | Execution |
Detection: PowerShell Start-BitsTransfer
Description
The following analytic detects PowerShell command lines initiating a BITS transfer with and additional behavioral indicator such as literal IP URL host, file-sharing or hosted-content domain, executable or script in a staging destination, or a chained execution command.
Search
1
2| tstats `security_content_summariesonly`
3 count min(_time) as firstTime
4 max(_time) as lastTime
5
6FROM datamodel=Endpoint.Processes WHERE
7
8`process_powershell`
9Processes.process="*Start-BitsTransfer*"
10
11BY Processes.action Processes.dest Processes.original_file_name
12 Processes.parent_process Processes.parent_process_exec Processes.parent_process_guid
13 Processes.parent_process_id Processes.parent_process_name Processes.parent_process_path
14 Processes.process Processes.process_exec Processes.process_guid
15 Processes.process_hash Processes.process_id Processes.process_integrity_level
16 Processes.process_name Processes.process_path Processes.user
17 Processes.user_id Processes.vendor_product
18
19
20| `drop_dm_object_name(Processes)`
21
22
23| where match(process, "(?i)(?:^
24|[\\s;
25|&({\"\\x27])(?:BitsTransfer\\\\)?Start-BitsTransfer\\s+(?:-[A-Za-z]+\\s+
26|[\"\\x27]?https?://)")
27 AND NOT match(process, "(?i)-TransferType\\s+[\"\\x27]?Upload(?:Reply)?(?:[\"\\x27\\s;]
28|$)")
29
30
31| rex max_match=0 field=process "(?i)https?://(?:[^/\\s@]+@)?(?<bits_remote_host>\\[[0-9a-f:]+\\]
32|[^/:\\s\"\\x27]+)"
33
34| rex max_match=0 field=process "(?i)https?://[^\\s\"']+[\"']?\\s+(?<bits_positional_path>\"[^\"]+\"
35|'[^']+'
36|\\S+)"
37
38| rex field=process "(?i)-Destination\\s+(?:\"(?<bits_destination_double>[^\"]+)\"
39|'(?<bits_destination_single>[^']+)'
40|(?<bits_destination_bare>[^\\s;
41|]+))"
42
43
44| eval bits_direct_ip=if(mvfind(bits_remote_host, "(?i)^(?:25[0-5]
45|2[0-4][0-9]
46|1?[0-9]?[0-9])(?:\\.(?:25[0-5]
47|2[0-4][0-9]
48|1?[0-9]?[0-9])){3}$
49|^\\[[0-9a-f]*:[0-9a-f:]+\\]$")>=0, 1, 0),
50 bits_file_hosting=if(mvfind(bits_remote_host, "(?i)(^
51|\\.)(?:github\\.com
52|githubusercontent\\.com
53|discordapp\\.com
54|discordapp\\.net
55|dropboxusercontent\\.com
56|gofile\\.io
57|mega\\.nz
58|mediafire\\.com
59|pastebin\\.com
60|paste\\.ee
61|transfer\\.sh
62|temp\\.sh
63|anonfiles\\.com
64|storage\\.googleapis\\.com
65|trycloudflare\\.com
66|workers\\.dev
67|pages\\.dev
68|onrender\\.com
69|supabase\\.co
70|ddns\\.net
71|ngrok-free\\.app)$")>=0, 1, 0),
72 bits_local_path=coalesce(bits_destination_double, bits_destination_single, bits_destination_bare, bits_positional_path)
73
74
75| where isnotnull(bits_remote_host)
76 AND
77 (
78 bits_direct_ip=1
79 OR
80 bits_file_hosting=1
81 OR
82 mvcount(
83 mvfilter(
84 match(bits_local_path, "(?i)(?:\\\\(?:AppData\\\\(?:Local
85|Roaming)
86|Users\\\\Public
87|ProgramData
88|PerfLogs
89|Temp
90|Windows\\\\(?:Temp
91|Tasks
92|debug)
93|\\$Recycle\\.Bin
94|inetpub\\\\wwwroot)\\\\
95|\\\\Start Menu\\\\Programs\\\\Startup\\\\
96|%(?:temp
97|tmp
98|appdata
99|localappdata
100|programdata
101|public)%\\\\
102|\\$env:(?:temp
103|tmp
104|appdata
105|localappdata
106|programdata
107|public)\\\\)")
108 AND
109 match(bits_local_path, "(?i)\\.(?:exe
110|dll
111|com
112|pif
113|scr
114|cpl
115|msi
116|msp
117|ps1
118|psm1
119|bat
120|cmd
121|vbs
122|vbe
123|js
124|jse
125|wsf
126|wsh
127|sct
128|hta
129|chm
130|xll
131|aspx?
132|ashx
133|asmx
134|jsp
135|jspx
136|war)[\"\\x27]?$")
137 )
138 )>0
139 OR
140 match(process, "(?i)[;
141|]\\s*(?:Start-Process
142|Invoke-Item
143|Invoke-Expression
144|iex
145|&)(?:\\s
146|\\()")
147 )
148
149
150| `security_content_ctime(firstTime)`
151
152| `security_content_ctime(lastTime)`
153
154| `powershell_start_bitstransfer_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Windows Event Log Security 4688 | 'XmlWinEventLog' |
'XmlWinEventLog:Security' |
|
| CrowdStrike ProcessRollup2 | Other | 'crowdstrike:events:sensor' |
'crowdstrike' |
| Sysmon EventID 1 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
Macros Used
| Name | Value |
|---|---|
| security_content_summariesonly | summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config`` |
| powershell_start_bitstransfer_filter | search * |
powershell_start_bitstransfer_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Finding (Notable) | Yes |
| Rule Title | %name% |
| Rule Description | %description% |
| Notable Event Fields | user, dest |
| Creates Intermediate Finding (Risk Event) | Yes |
Implementation
The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are
designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this
search, you must ingest logs that contain the process GUID, process name, and parent process. Additionally, you must
ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons
that are specific to the EDR product. The logs must also be mapped to the Processes node of the Endpoint data
model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
Known False Positives
Administration, CI jobs and authorized testing can use literal IPs, public hosting, temporary destinations or chained execution. Review the script and its ancestry before tuning the filter macro. Invocation and URL checks reduce literal code-search matches but cannot distinguish all quoted examples from executed PowerShell code.
Associated Analytic Story
Finding
| Title | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| An instance of [$parent_process_name$] spawning [$process_name$] was identified on endpoint [$dest$] by user [$user$] attempting a suspicious Start-BitsTransfer operation with command line [$process$]. | user | user | 50 |
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| An instance of [$parent_process_name$] spawning [$process_name$] was identified on endpoint [$dest$] by user [$user$] attempting a suspicious Start-BitsTransfer operation with command line [$process$]. | dest | system | 50 |
References
-
https://isc.sans.edu/diary/Investigating+Microsoft+BITS+Activity/23281
-
https://learn.microsoft.com/en-us/powershell/module/bitstransfer/start-bitstransfer
Atomic Tests
Learn more about Atomic Red Team tests here.
| Atomic Test ID | Atomic Test Name | Supported Platform |
|---|---|---|
| f63b8bc4-07e5-4112-acba-56f646f3f0bc | Bitsadmin Download (PowerShell) | Windows |
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
| Integration | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub |
Version: 13