Name:PowerShell Start-BitsTransfer id:39e2605a-90d8-11eb-899e-acde48001122 version:13 date:None author:Michael Haag, Nasreddine Bencherchali, Splunk status:production type:TTP 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. Data_source:
-Sysmon EventID 1
-Windows Event Log Security 4688
-CrowdStrike ProcessRollup2
search:| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime
| where match(process, "(?i)(?:^|[\\s;|&({\"\\x27])(?:BitsTransfer\\\\)?Start-BitsTransfer\\s+(?:-[A-Za-z]+\\s+|[\"\\x27]?https?://)") AND NOT match(process, "(?i)-TransferType\\s+[\"\\x27]?Upload(?:Reply)?(?:[\"\\x27\\s;]|$)")
| rex max_match=0 field=process "(?i)https?://(?:[^/\\s@]+@)?(?<bits_remote_host>\\[[0-9a-f:]+\\]|[^/:\\s\"\\x27]+)" | rex max_match=0 field=process "(?i)https?://[^\\s\"']+[\"']?\\s+(?<bits_positional_path>\"[^\"]+\"|'[^']+'|\\S+)" | rex field=process "(?i)-Destination\\s+(?:\"(?<bits_destination_double>[^\"]+)\"|'(?<bits_destination_single>[^']+)'|(?<bits_destination_bare>[^\\s;|]+))"
| where isnotnull(bits_remote_host) AND ( bits_direct_ip=1 OR bits_file_hosting=1 OR mvcount( mvfilter( match(bits_local_path, "(?i)(?:\\\\(?:AppData\\\\(?:Local|Roaming)|Users\\\\Public|ProgramData|PerfLogs|Temp|Windows\\\\(?:Temp|Tasks|debug)|\\$Recycle\\.Bin|inetpub\\\\wwwroot)\\\\|\\\\Start Menu\\\\Programs\\\\Startup\\\\|%(?:temp|tmp|appdata|localappdata|programdata|public)%\\\\|\\$env:(?:temp|tmp|appdata|localappdata|programdata|public)\\\\)") AND match(bits_local_path, "(?i)\\.(?:exe|dll|com|pif|scr|cpl|msi|msp|ps1|psm1|bat|cmd|vbs|vbe|js|jse|wsf|wsh|sct|hta|chm|xll|aspx?|ashx|asmx|jsp|jspx|war)[\"\\x27]?$") ) )>0 OR match(process, "(?i)[;|]\\s*(?:Start-Process|Invoke-Item|Invoke-Expression|iex|&)(?:\\s|\\()") )
how_to_implement: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. References: -https://isc.sans.edu/diary/Investigating+Microsoft+BITS+Activity/23281 -https://docs.microsoft.com/en-us/windows/win32/bits/using-windows-powershell-to-create-bits-transfer-jobs -https://github.com/redcanaryco/atomic-red-team/blob/388942adbd9641f4dfdcf079d7efe9a75ec0ac43/atomics/T1197/T1197.yaml#L27 -https://learn.microsoft.com/en-us/powershell/module/bitstransfer/start-bitstransfer drilldown_searches: name:'View the detection results for - "$dest$" and "$user$"' search:'%original_detection_search% | search dest = "$dest$" user = "$user$"' earliest_offset:'$info_min_time$' latest_offset:'$info_max_time$' name:'View risk events for the last 7 days for - "$dest$" and "$user$"' search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$", "$user$") | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`' earliest_offset:'7d' latest_offset:'0' analytic_story:['BITS Jobs', 'Gozi Malware']