| ID | Technique | Tactic |
|---|---|---|
| T1059.001 | PowerShell | Execution |
| T1095 | Non-Application Layer Protocol | Command and Control |
Detection: Cisco Secure Endpoint - Nishang Script Alert After Download
Description
This analytic detects a PowerShell download command followed by a Nishang-like reverse-shell script alert in the same process, using Cisco Secure Endpoint Behavioral Protection telemetry. The ordered sequence adds the source URL to a high-signal script alert. It does not establish that a remote shell connected; investigate the downloaded content, process, and response action.
Search
1`cisco_secure_endpoint`
2event_type="Threat Detection"
3
4
5| `cisco_secure_endpoint_extract_bp_fields`
6
7
8| where sig_id IN ("20200719101800","20250306001111")
9
10
11| spath path=bp_data.details.matched_activity.events{0}.process:start.guid output=start_guid
12
13
14| spath path=bp_data.details.matched_activity.events{0}.script:execution.guid output=script_guid
15
16
17| spath path=bp_data.details.matched_activity.events{0}.process:start.cmd_line output=start_command
18
19
20| spath path=bp_data.details.matched_activity.events{0}.script:execution.cmd_line output=script_command
21
22
23| spath path=bp_data.details.matched_activity.events{0}.script:execution.user.name output=script_user
24
25
26| eval stage=if(sig_id="20200719101800","download","shell"),
27 process_guid=coalesce(start_guid,script_guid),
28 process_command=coalesce(start_command,script_command),
29 user=coalesce(user,script_user),
30 event_time=tonumber(timestamp)+tonumber(timestamp_nanoseconds)/1000000000
31
32
33| rex field=process_command "(?i)(?<payload_url>https?://[A-Za-z0-9._~:/?#@!$&()*+,;=%-]+)"
34
35
36| eval payload_url=lower(payload_url)
37
38
39| where isnotnull(endpoint_guid)
40 AND isnotnull(process_guid)
41 AND isnotnull(event_time)
42
43
44| sort 0 endpoint_guid process_guid event_time
45
46| streamstats last(eval(if(stage="download",event_time,null()))) as download_time
47 last(eval(if(stage="download",payload_url,null()))) as prior_payload_url
48 last(eval(if(stage="download",process_command,null()))) as download_command
49 by endpoint_guid process_guid
50
51| where stage="shell" AND isnotnull(download_time)
52 AND isnotnull(prior_payload_url)
53 AND event_time>=download_time AND event_time-download_time<=120
54
55| eval payload_url=prior_payload_url, shell_command=process_command,
56 firstTime=download_time, lastTime=event_time,
57 user=coalesce(user,"unknown")
58
59| dedup endpoint_guid process_guid download_time
60
61
62| table dest user endpoint_guid process_guid payload_url
63 download_command shell_command firstTime lastTime
64
65| `security_content_ctime(firstTime)`
66
67| `security_content_ctime(lastTime)`
68
69| `cisco_secure_endpoint___nishang_script_alert_after_download_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Cisco Secure Endpoint Behavioral Protection Threat Detection | Other | 'cisco:se' |
'not_applicable' |
Macros Used
| Name | Value |
|---|---|
| cisco_secure_endpoint | sourcetype="cisco:se" |
| 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___nishang_script_alert_after_download_filter | search * |
cisco_secure_endpoint___nishang_script_alert_after_download_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 |
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
An approved test harness could download a PowerShell script that resembles a reverse shell. Verify the script contents, URL, network session, operator, and change record. The process and script alerts do not prove a completed callback.
Associated Analytic Story
Finding
| Title | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| PowerShell download followed by a Nishang-like script alert in process $process_guid$ on $dest$ | dest | system | 50 |
Threat Objects
| Field | Type |
|---|---|
| shell_command | command |
| payload_url | url |
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