--- title: "Batch File Write to System32" excerpt: "User Execution, Malicious File" categories: - Endpoint last_modified_at: 2021-09-16 toc: true toc_label: "" tags: - User Execution - Execution - Malicious File - Execution - Splunk Enterprise - Splunk Enterprise Security - Splunk Cloud - Endpoint --- [Try in Splunk Security Cloud](https://www.splunk.com/en_us/cyber-security.html){: .btn .btn--success} #### Description The search looks for a batch file (.bat) written to the Windows system directory tree. - **Type**: TTP - **Product**: Splunk Enterprise, Splunk Enterprise Security, Splunk Cloud - **Datamodel**: [Endpoint](https://docs.splunk.com/Documentation/CIM/latest/User/Endpoint) - **Last Updated**: 2021-09-16 - **Author**: Michael Haag, Rico Valdez, Splunk - **ID**: 503d17cb-9eab-4cf8-a20e-01d5c6987ae3 #### [ATT&CK](https://attack.mitre.org/) | ID | Technique | Tactic | | ----------- | ----------- |--------------- | | [T1204](https://attack.mitre.org/techniques/T1204/) | User Execution | Execution | | [T1204.002](https://attack.mitre.org/techniques/T1204/002/) | Malicious File | Execution | #### Search ``` | tstats `security_content_summariesonly` count FROM datamodel=Endpoint.Processes where Processes.process_name=* by _time span=1h Processes.process_id Processes.process_name Processes.dest | `drop_dm_object_name(Processes)` | join process_guid, _time [ | tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime FROM datamodel=Endpoint.Filesystem where Filesystem.file_path IN ("*\\system32\\*", "*\\syswow64\\*") Filesystem.file_name="*.bat" by _time span=1h Filesystem.dest Filesystem.file_create_time Filesystem.file_name Filesystem.file_path | `drop_dm_object_name(Filesystem)` | fields _time dest file_create_time file_name file_path process_name process_path process] | dedup file_create_time | table dest file_create_time, file_name, file_path, process_name | `batch_file_write_to_system32_filter` ``` #### Associated Analytic Story * [SamSam Ransomware](/stories/samsam_ransomware) #### 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. In addition, confirm the latest CIM App 4.20 or higher is installed and the latest TA for the endpoint product. #### Required field * _time * Filesystem.dest * Filesystem.file_name * Filesystem.user * Filesystem.file_path * Processes.process_id * Processes.process_name * Processes.dest #### Kill Chain Phase * Delivery #### Known False Positives It is possible for this search to generate a notable event for a batch file write to a path that includes the string "system32", but is not the actual Windows system directory. As such, you should confirm the path of the batch file identified by the search. In addition, a false positive may be generated by an administrator copying a legitimate batch file in this directory tree. You should confirm that the activity is legitimate and modify the search to add exclusions, as necessary. #### RBA | Risk Score | Impact | Confidence | Message | | ----------- | ----------- |--------------|--------------| | 63.0 | 70 | 90 | A file - $file_name$ was written to system32 has occurred on endpoint $dest$ by user $user$. | #### Reference #### Test Dataset Replay any dataset to Splunk Enterprise by using our [`replay.py`](https://github.com/splunk/attack_data#using-replaypy) tool or the [UI](https://github.com/splunk/attack_data#using-ui). Alternatively you can replay a dataset into a [Splunk Attack Range](https://github.com/splunk/attack_range#replay-dumps-into-attack-range-splunk-server) * [https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1204.002/batch_file_in_system32/windows-sysmon.log](https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1204.002/batch_file_in_system32/windows-sysmon.log) [*source*](https://github.com/splunk/security_content/tree/develop/detections/endpoint/batch_file_write_to_system32.yml) \| *version*: **2**