name: Nishang PowershellTCPOneLine
id: 1a382c6c-7c2e-11eb-ac69-acde48001122
version: 1
date: '2021-03-03'
author: Michael Haag, Splunk
type: batch
datamodel:
- Endpoint
description: This query detects the Nishang Invoke-PowerShellTCPOneLine utility that
  spawns a call back to a remote command and control server. This is a powershell
  oneliner. In addition, this will capture on the command-line additional utilities
  used by Nishang. Triage the endpoint and identify any parallel processes that look
  suspicious. Review the reputation of the remote IP or domain contacted by the powershell
  process.
search: '| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time)
  as lastTime from datamodel=Endpoint.Processes where Processes.process_name=powershell.exe
  OR Processes.process_name=pwsh.exe OR Processes.process_name=PowerShell_ISE.exe
  (Processes.process=*Net.Sockets.TCPClient* AND Processes.process=*System.Text.ASCIIEncoding*)
  by Processes.dest Processes.user Processes.parent_process Processes.process_name
  Processes.process Processes.process_id Processes.parent_process_id | `drop_dm_object_name(Processes)`
  | `security_content_ctime(firstTime)`| `security_content_ctime(lastTime)`| `nishang_powershelltcponeline_filter`'
how_to_implement: To successfully implement this search you need to be ingesting information
  on process that include the name of the process responsible for the changes from
  your endpoints into the `Endpoint` datamodel in the `Processes` node.
known_false_positives: Limited false positives may be present. Filter as needed based
  on initial analysis.
references:
- https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcpOneLine.ps1
- https://www.volexity.com/blog/2021/03/02/active-exploitation-of-microsoft-exchange-zero-day-vulnerabilities/
- https://www.microsoft.com/security/blog/2021/03/02/hafnium-targeting-exchange-servers/
- https://blog.rapid7.com/2021/03/03/rapid7s-insightidr-enables-detection-and-response-to-microsoft-exchange-0-day/
tags:
  analytic_story:
  - HAFNIUM Group
  automated_detection_testing: passed
  dataset:
  - https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1059.001/atomic_red_team/windows-sysmon.log
  kill_chain_phases:
  - Exploitation
  mitre_attack_id:
  - T1059.001
  product:
  - Splunk Enterprise
  - Splunk Enterprise Security
  - Splunk Cloud
  required_fields:
  - _time
  - Processes.process_name
  - Processes.process
  - Processes.dest
  - Processes.user
  - Processes.parent_process
  - Processes.process_name
  - Processes.process_id
  - Processes.parent_process_id
  security_domain: endpoint
