Name:Cisco Secure Endpoint - Encoded Script Decode and Run id:6cceef1d-a64d-4608-ad82-6979c30e1d75 version:1 date:None author:Nasreddine Bencherchali, Splunk status:production type:TTP Description:This analytic detects a PowerShell download command writing an encoded file, a certutil decode command naming that file and a decoded script, and a later hidden PowerShell execution alert naming the decoded script. It correlates Cisco Secure Endpoint Behavioral Protection alerts by endpoint, parent process, exact paths, and order.
The file relationships suggest a staged payload. The certutil alert may trigger an end-process response in Protect mode, so a decode command alone does not prove the file was produced. Confirm the file and response status before concluding the sequence completed. Data_source:
| where isnotnull(endpoint_guid) AND isnotnull(parent_guid) AND isnotnull(event_time)
| sort 0 endpoint_guid parent_guid event_time
| streamstats last(eval(if(stage="download",download_file,null()))) as prior_download_file last(eval(if(stage="download",process_command,null()))) as prior_download_command max(eval(if(stage="download",event_time,null()))) as download_time by endpoint_guid parent_guid
| eval valid_decode=if(stage="decode" AND encoded_input=prior_download_file AND isnotnull(decoded_output) AND event_time>=download_time AND event_time-download_time<=300,1,0)
| streamstats last(eval(if(valid_decode=1,decoded_output,null()))) as prior_decoded_file last(eval(if(valid_decode=1,encoded_input,null()))) as prior_encoded_file last(eval(if(valid_decode=1,prior_download_command,null()))) as download_command last(eval(if(valid_decode=1,process_command,null()))) as decode_command max(eval(if(valid_decode=1,event_time,null()))) as decode_time max(eval(if(valid_decode=1,download_time,null()))) as first_event_time by endpoint_guid parent_guid
| where stage="execute" AND executed_file=prior_decoded_file AND isnotnull(decode_time) AND event_time>=decode_time AND event_time-decode_time<=300 AND event_time-first_event_time<=300
| table dest user endpoint_guid parent_guid encoded_file decoded_file download_command decode_command execution_command bp_response firstTime lastTime | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` | `cisco_secure_endpoint___encoded_script_decode_and_run_filter`
how_to_implement: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:An approved deployment workflow may download encoded scripts, decode them with certutil, and
execute them from Temp. Review the source URL, decoded script, account, parent process, and
deployment change record. References: -https://docs.amp.cisco.com/en/SecureEndpoint/Secure%20Endpoint%20User%20Guide.pdf -https://attack.mitre.org/techniques/T1105/ -https://attack.mitre.org/techniques/T1140/ -https://attack.mitre.org/techniques/T1059/001/ drilldown_searches: name:'View BP Activity for - $dest$' search:'`cisco_secure_endpoint` event_type="Threat Detection"
| spath path=computer.connector_guid output=endpoint_guid
| search endpoint_guid="$endpoint_guid$"
| spath path=bp_data.details.sig_id output=sig_id
| spath path=bp_data.remediated output=remediated
| 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
| spath path=bp_data.details.matched_activity.events{0}.process:start.cmd_line output=process_command
| spath path=bp_data.details.matched_activity.events{0}.script:execution.cmd_line output=script_command
| eval observed_command=coalesce(process_command,script_command)
| table _time detection severity sig_id bp_audit bp_action bp_action_status remediated observed_command _raw
| sort - _time' earliest_offset:'7d' latest_offset:'0' name:'View Cloud IOC Activity for - $dest$' search:'`cisco_secure_endpoint` event_type="Cloud IOC"
| spath path=computer.connector_guid output=endpoint_guid
| search endpoint_guid="$endpoint_guid$"
| spath path=cloud_ioc.short_description output=ioc_name
| spath path=cloud_ioc.description output=ioc_description
| spath path=command_line.arguments output=process_command
| spath path=file.file_name output=file_name
| spath path=file.file_path output=file_path
| spath path=file.identity.sha256 output=file_sha256
| eval activity_time=strftime(tonumber(coalesce(start_timestamp,timestamp)),"%Y-%m-%d %H:%M:%S")
| table _time activity_time ioc_name severity process_command file_name file_path file_sha256 ioc_description _raw
| sort - _time' earliest_offset:'7d' latest_offset:'0' name:'View risk events for the last 7 days for - "$user$"' search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$user$", "$dest$") | 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:['Compromised Windows Host', 'Windows Post-Exploitation', 'Cisco Secure Endpoint - Correlated Threat Activity']