Detection: Cisco Secure Endpoint - Hidden Script After Delivery Or Zone Change

Description

This analytic detects hidden PowerShell execution of a Temp script after a BITS transfer command, a PowerShell download command writing the same file, or a Zone.Identifier change. It correlates Cisco Secure Endpoint Behavioral Protection alerts by endpoint, parent process, file path, and time. A staged script followed by concealed execution can indicate payload delivery and evasion. BITS and download alerts record commands; they do not by themselves prove transfer completion, and a zone-marker change does not prove a security control was bypassed. Check prevention actions and inspect the script and source URL.

  1`cisco_secure_endpoint`
  2event_type="Threat Detection"
  3
  4
  5| `cisco_secure_endpoint_extract_bp_fields`
  6
  7
  8| where sig_id IN ("20170804213338","20190603173116","20200719101800","20201202215412")
  9
 10
 11| spath path=bp_data.details.matched_activity.events{0}.process:start.parent_guid output=parent_guid
 12
 13| spath path=bp_data.details.matched_activity.events{0}.process:start.cmd_line output=process_command
 14
 15| spath path=bp_data.details.matched_activity.events{0}.process:start.args{} output=process_args
 16
 17
 18| eval stage=case(sig_id="20170804213338","transfer",
 19       sig_id="20190603173116","zone",
 20           sig_id="20200719101800","download",
 21           sig_id="20201202215412","execute")
 22
 23
 24| eval bits_transfer_index=mvfind(process_args,"(?i)^/transfer$")
 25
 26| rex field=process_command "(?i)WriteAllText\(\s*['\"](?<download_file>[A-Za-z]:[^'\"]+\.ps1)"
 27
 28| rex field=process_command "(?i)DownloadString\(\s*['\"](?<powershell_url>https?://[^'\"]+)"
 29
 30| eval transfer_file=if(stage="transfer" AND isnotnull(bits_transfer_index),lower(mvindex(process_args,-1)),null()),
 31       transfer_url=if(stage="transfer" AND isnotnull(bits_transfer_index),mvindex(process_args,-2),null())
 32
 33
 34| rex field=process_command "(?i)ReadAllText\('(?<executed_file>[A-Za-z]:[^']+\.ps1)'"
 35
 36
 37| rex field=process_command "(?i)>\s*(?<zone_file>[A-Za-z]:.+?\.ps1):Zone\.Identifier"
 38
 39
 40| eval file_ref=lower(coalesce(transfer_file,download_file,zone_file,executed_file))
 41
 42
 43| eval event_time=tonumber(timestamp)+tonumber(timestamp_nanoseconds)/1000000000
 44
 45
 46| where isnotnull(endpoint_guid)
 47        AND isnotnull(parent_guid)
 48        AND isnotnull(file_ref)
 49        AND isnotnull(event_time)
 50
 51
 52| eval stage=if(stage="transfer" AND isnull(transfer_file),null(),stage)
 53
 54| where isnotnull(stage)
 55
 56| sort 0 endpoint_guid parent_guid file_ref event_time
 57
 58
 59| streamstats max(eval(if(stage="transfer" OR stage="download",event_time,null()))) as transfer_time
 60              last(eval(if(stage="transfer" OR stage="download",process_command,null()))) as transfer_command
 61                  last(eval(case(stage="transfer","BITS transfer command",stage="download","PowerShell download command"))) as delivery_method
 62              last(eval(if(stage="transfer" OR stage="download",coalesce(transfer_url,powershell_url),null()))) as download_url
 63          max(eval(if(stage="zone",event_time,null()))) as zone_time
 64          last(eval(if(stage="zone",process_command,null()))) as zone_command
 65  by endpoint_guid parent_guid file_ref
 66
 67
 68| where stage="execute"
 69
 70
 71| eval transfer_time=if(isnotnull(transfer_time) AND event_time-transfer_time<=300,transfer_time,null()),
 72       zone_time=if(isnotnull(zone_time) AND event_time-zone_time<=300,zone_time,null())
 73
 74
 75| where isnotnull(transfer_time) OR isnotnull(zone_time)
 76
 77
 78| eval download_url=if(isnotnull(transfer_time),download_url,null()),
 79       transfer_command=if(isnotnull(transfer_time),transfer_command,null()),
 80       zone_command=if(isnotnull(zone_time),zone_command,null()),
 81       activity=case(isnotnull(transfer_time) AND isnotnull(zone_time),delivery_method." and zone change",
 82                     isnotnull(transfer_time),delivery_method,
 83                     isnotnull(zone_time),"zone marker change"),
 84       script_file=file_ref,
 85       execution_command=process_command,
 86       firstTime=if(isnull(transfer_time),zone_time,if(isnull(zone_time),transfer_time,min(transfer_time,zone_time))),
 87       lastTime=event_time
 88
 89
 90| sort 0 endpoint_guid parent_guid script_file firstTime -lastTime
 91
 92
 93| dedup endpoint_guid parent_guid script_file firstTime
 94
 95
 96| eval user=coalesce(user,"unknown")
 97
 98
 99| table dest user endpoint_guid parent_guid script_file activity
100        download_url transfer_command zone_command execution_command bp_response firstTime lastTime
101
102| `security_content_ctime(firstTime)`
103
104| `security_content_ctime(lastTime)`
105
106| `cisco_secure_endpoint___hidden_script_after_delivery_or_zone_change_filter`

Data Source

Name Platform Sourcetype Source
Cisco Secure Endpoint Behavioral Protection Threat Detection Other 'cisco:se' 'not_applicable'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
search bp_engine=apde
spath path=bp_data.details.sig_id output=sig_id
spath path=computer.connector_guid output=endpoint_guid
spath path=computer.hostname output=dest
spath path=bp_data.details.matched_activity.events{0}.process:start.user.name output=user
spath path=bp_data.details.matched_activity.events{0}.registry:set.user.name output=registry_user
spath path=bp_data.details.matched_activity.events{0}.file:create.user.name output=file_user
eval user=coalesce(user,registry_user,file_user)
spath path=bp_data.audit output=bp_audit
spath path=bp_data.details.actions{}.action output=bp_action
spath path=bp_data.details.actions{}.status output=bp_action_status
eval bp_response=case(bp_audit="true","audit mode",isnotnull(bp_action_status),mvjoin(bp_action,", "),true(),"no action reported")`
cisco_secure_endpoint___hidden_script_after_delivery_or_zone_change_filter search *
cisco_secure_endpoint___hidden_script_after_delivery_or_zone_change_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) No
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

Implementation

This search requires Cisco Secure Endpoint Behavioral Protection Threat Detection alerts, which include event_type="Threat Detection". This search uses an input macro named cisco_secure_endpoint. We strongly recommend that you specify your environment-specific configurations (index, source, sourcetype, etc.) for Cisco Secure Endpoint Behavioral Protection Threat Detection alerts. Replace the macro definition with configurations for your Splunk environment. The cisco_secure_endpoint_extract_bp_fields macro extracts the common signature, endpoint, actor, and prevention-response fields used by this search. The search also uses a post-filter macro designed to filter out known false positives. The logs are to be ingested using the Cisco Security Cloud App for Splunk (https://splunkbase.splunk.com/app/7404). In Protect mode, a Behavioral Protection response can kill or quarantine an earlier stage, so this search requires each later alert to have actually appeared. Review bp_data.audit and bp_data.details.actions in the source events before concluding that a task registered, a process completed, or a transfer succeeded. The included audit-mode fixtures verify alert correlation, not survival of an enforced prevention action.

Known False Positives

A legitimate deployment workflow may transfer a script with BITS, change its zone marker, or run it hidden. Review the source URL when present, script content, account, parent process, and deployment change record.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
Script delivery or zone identifier change followed by hidden execution under parent process $parent_guid$ on $dest$ dest system 50

Threat Objects

Field Type
execution_command command
script_file file_path

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset not_applicable cisco:se
Integration ✅ Passing Dataset not_applicable cisco:se

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: 1