LoFP LoFP / some batch files are written to the system32 directory tree for legitimate purposes, such as system maintenance or configuration. investigate the batch file to determine if it is legitimate and modify the search to add exclusions, as necessary.

Techniques

Sample rules

Batch File Write to System32

Description

The following analytic detects the creation of a batch file (.bat) within the Windows system directory tree, specifically in the System32 or SysWOW64 folders. It leverages data from the Endpoint datamodel, focusing on process and filesystem events to identify this behavior. This activity is significant because writing batch files to system directories can be indicative of malicious intent, such as persistence mechanisms or system manipulation. If confirmed malicious, this could allow an attacker to execute arbitrary commands with elevated privileges, potentially compromising the entire system.

Detection logic


| tstats `security_content_summariesonly`
  count min(_time) as firstTime
        max(_time) as lastTime

FROM datamodel=Endpoint.Filesystem where

Filesystem.action IN (
    "created",
    "modified"
)
Filesystem.file_path IN (
    "*:\\Windows\\System32\\*",
    "*:\\Windows\\SysWOW64\\*"
)
Filesystem.file_name IN (
    "*.bat",
    "*.cmd"
)

by Filesystem.action Filesystem.dest Filesystem.file_access_time
   Filesystem.file_create_time Filesystem.file_hash
   Filesystem.file_modify_time Filesystem.file_name
   Filesystem.file_path Filesystem.file_acl
   Filesystem.file_size Filesystem.process_guid
   Filesystem.process_id Filesystem.user Filesystem.vendor_product


| `drop_dm_object_name(Filesystem)`

| `security_content_ctime(firstTime)`

| `security_content_ctime(lastTime)`

| `batch_file_write_to_system32_filter`