← Back to SOC feed Coverage →

Nishang Reverse TCP Shell in Base64 (Normalized Process Events)

kql MEDIUM Azure-Sentinel
T1011
imProcessCreate
backdoorhuntingmicrosoftofficialpowershell
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-04-22T09:00:00Z · Confidence: medium

Hunt Hypothesis

Adversaries may use Base64-encoded PowerShell commands to establish a reverse TCP shell, leveraging the Nishang toolkit to exfiltrate data undetected. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential command-and-control activity and mitigate lateral movement risks.

KQL Query

imProcessCreate
| where Process has_any ("powershell.exe","powershell_ise.exe") and CommandLine contains "-e" 
| mvexpand SS = split(CommandLine, " ") 
| where SS matches regex "[A-Za-z0-9+/]{50,}[=]{0,2}" 
| extend DecodeString = base64_decode_tostring(tostring(SS)) 
| extend FinalString = replace("\\0", "", DecodeString) 
| where FinalString has "tcpclient" and FinalString contains "$" and (FinalString contains "invoke" or FinalString contains "iex") 
| extend timestamp = TimeGenerated, AccountCustomEntity = User, HostCustomEntity = Dvc

Analytic Rule Definition

id: 3a8e307b-5037-4182-a4e2-e76d99cecab8
name: Nishang Reverse TCP Shell in Base64 (Normalized Process Events)
description: |
  'Looks for Base64-encoded commands associated with the Nishang reverse TCP shell.
  Ref: https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcp.ps1'
requiredDataConnectors: []
tactics:
  - Exfiltration
relevantTechniques:
  - T1011
query: |
  imProcessCreate
  | where Process has_any ("powershell.exe","powershell_ise.exe") and CommandLine contains "-e" 
  | mvexpand SS = split(CommandLine, " ") 
  | where SS matches regex "[A-Za-z0-9+/]{50,}[=]{0,2}" 
  | extend DecodeString = base64_decode_tostring(tostring(SS)) 
  | extend FinalString = replace("\\0", "", DecodeString) 
  | where FinalString has "tcpclient" and FinalString contains "$" and (FinalString contains "invoke" or FinalString contains "iex") 
  | extend timestamp = TimeGenerated, AccountCustomEntity = User, HostCustomEntity = Dvc

entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: AccountCustomEntity
  - entityType: Host
    fieldMappings:
      - identifier: FullName
        columnName: HostCustomEntity

Required Data Sources

Sentinel TableNotes
imProcessCreateEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/ASimProcess/imProcess_NishangReverseTCPShellBase64.yaml