This detection rule identifies the execution of Chinese BAT scripting tools performing local port enumeration, a behavior often associated with initial reconnaissance or lateral movement by threat actors leveraging custom automation scripts. Proactive hunting for this activity in Azure Sentinel is critical to uncover stealthy post-compromise actions that may evade standard signature-based defenses and reveal early indicators of supply chain or insider threats targeting network topology discovery.
rule CN_Hacktool_BAT_PortsOpen {
meta:
description = "Detects a chinese BAT hacktool for local port evaluation"
author = "Florian Roth"
score = 60
date = "12.10.2014"
strings:
$s0 = "for /f \"skip=4 tokens=2,5\" %%a in ('netstat -ano -p TCP') do (" ascii
$s1 = "in ('tasklist /fi \"PID eq %%b\" /FO CSV') do " ascii
$s2 = "@echo off" ascii
condition:
all of them
}
This YARA rule can be deployed in the following contexts:
This rule contains 3 string patterns in its detection logic.
Here are 5 specific false positive scenarios for the rule “Detects a Chinese BAT hacktool for local port evaluation,” including suggested filters and exclusions:
Scenario: Automated Network Inventory Script Execution
netstat or nmap via a .bat wrapper (e.g., PortScan_Daily.bat) which enumerates local listening ports on the host itself before scanning remote targets.C:\Scripts\Ops\PortScan_Daily.bat). Additionally, filter out events where the command line argument contains keywords like /inventory or --local-scan.Scenario: Scheduled Service Health Checks via Task Scheduler
svchost.exe or TaskSchedulerService and the executable name matches known monitoring BAT files (e.g., HealthCheck_PortStatus.bat). Filter based on a recurring time window (e.g., 09:00–17:00) if the job runs only during business hours.Scenario: Deployment of Chinese Enterprise Resource Planning (ERP) Modules