This detection identifies adversaries deploying a batch script named “Clear.bat” as part of their hacktool execution phase to establish persistence or execute initial command-and-control routines within Azure Sentinel environments. Proactive hunting for this specific artifact is critical because such scripts often serve as the first stage in an attack chain, enabling threat actors to clear logs, download additional payloads, or manipulate system configurations before escalating privileges.
rule Hacktools_CN_Burst_Clear {
meta:
description = "Disclosed hacktool set - file Clear.bat"
author = "Florian Roth"
date = "17.11.14"
score = 60
hash = "148c574a4e6e661aeadaf3a4c9eafa92a00b68e4"
strings:
$s0 = "del /f /s /q %systemdrive%\\*.log " fullword ascii
$s1 = "del /f /s /q %windir%\\*.bak " fullword ascii
$s4 = "del /f /s /q %systemdrive%\\*.chk " fullword ascii
$s5 = "del /f /s /q %systemdrive%\\*.tmp " fullword ascii
$s8 = "del /f /q %userprofile%\\COOKIES s\\*.* " fullword ascii
$s9 = "rd /s /q %windir%\\temp & md %windir%\\temp " fullword ascii
$s11 = "del /f /s /q %systemdrive%\\recycled\\*.* " fullword ascii
$s12 = "del /f /s /q \"%userprofile%\\Local Settings\\Temp\\*.*\" " fullword ascii
$s19 = "del /f /s /q \"%userprofile%\\Local Settings\\Temporary Internet Files\\*.*\" " ascii
condition:
5 of them
}
This YARA rule can be deployed in the following contexts:
This rule contains 9 string patterns in its detection logic.
Here are 5 specific false positive scenarios for the Disclosed hacktool set - file Clear.bat detection rule, including targeted filters and exclusions:
Scenario: Automated Build Pipeline Cleanup
.bat files (often named Clear.bat) to remove artifacts, clean working directories, or reset environments before the next pipeline stage. These agents often run under dedicated service accounts with elevated privileges.C:\ProgramData\Jenkins\workspace\*, D:\Builds\Agent\*\) and filter for specific user contexts like SYSTEM or Jenkins-Build-Service.Scenario: Endpoint Management Tool Maintenance
Clear.bat script deployed via Group Policy or application deployment packages.ccmexec.exe, IntuneManagementExtension.exe) and restrict the rule to exclude files located in C:\Program Files\Microsoft Intune Management Extension\ or similar vendor-specific installation paths.Scenario: Scheduled Daily Log Rotation
Clear.bat that archives old logs, truncates large event files, or clears temp folders (C:\Temp, `%TEMP%