← Back to SOC feed Coverage →

Windows Shell/Scripting Application File Write to Suspicious Folder

sigma HIGH SigmaHQ
T1059
imFileEvent
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 SigmaHQ →
Retrieved: 2026-03-25T03:05:59Z · Confidence: medium

Hunt Hypothesis

Adversaries may use scripting tools to write malicious files to suspicious folders as part of persistence or command and control activities. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential malware deployment or data exfiltration attempts.

Detection Rule

Sigma (Original)

title: Windows Shell/Scripting Application File Write to Suspicious Folder
id: 1277f594-a7d1-4f28-a2d3-73af5cbeab43
status: test
description: Detects Windows shells and scripting applications that write files to suspicious folders
references:
    - Internal Research
author: Florian Roth (Nextron Systems)
date: 2021-11-20
modified: 2023-03-29
tags:
    - attack.execution
    - attack.t1059
logsource:
    category: file_event
    product: windows
detection:
    selection_1:
        Image|endswith:
            - '\bash.exe'
            - '\cmd.exe'
            - '\cscript.exe'
            - '\msbuild.exe'  # https://github.com/elastic/detection-rules/blob/c76a39796972ecde44cb1da6df47f1b6562c9770/rules/windows/defense_evasion_execution_msbuild_started_by_office_app.toml
            - '\powershell.exe'
            - '\pwsh.exe'
            - '\sh.exe'
            - '\wscript.exe'
        TargetFilename|startswith:
            - 'C:\PerfLogs\'
            - 'C:\Users\Public\'
    selection_2:
        Image|endswith:
            - '\certutil.exe'
            - '\forfiles.exe'
            - '\mshta.exe'
            # - '\rundll32.exe' # Potential FP
            - '\schtasks.exe'
            - '\scriptrunner.exe'
            - '\wmic.exe'  # https://app.any.run/tasks/c903e9c8-0350-440c-8688-3881b556b8e0/
        TargetFilename|contains:
            - 'C:\PerfLogs\'
            - 'C:\Users\Public\'
            - 'C:\Windows\Temp\'
    condition: 1 of selection_*
falsepositives:
    - Unknown
level: high

KQL (Azure Sentinel)

imFileEvent
| where ((TargetFilePath endswith "\\bash.exe" or TargetFilePath endswith "\\cmd.exe" or TargetFilePath endswith "\\cscript.exe" or TargetFilePath endswith "\\msbuild.exe" or TargetFilePath endswith "\\powershell.exe" or TargetFilePath endswith "\\pwsh.exe" or TargetFilePath endswith "\\sh.exe" or TargetFilePath endswith "\\wscript.exe") and (TargetFileName startswith "C:\\PerfLogs\\" or TargetFileName startswith "C:\\Users\\Public\\")) or ((TargetFilePath endswith "\\certutil.exe" or TargetFilePath endswith "\\forfiles.exe" or TargetFilePath endswith "\\mshta.exe" or TargetFilePath endswith "\\schtasks.exe" or TargetFilePath endswith "\\scriptrunner.exe" or TargetFilePath endswith "\\wmic.exe") and (TargetFileName contains "C:\\PerfLogs\\" or TargetFileName contains "C:\\Users\\Public\\" or TargetFileName contains "C:\\Windows\\Temp\\"))

False Positive Guidance

MITRE ATT&CK Context

Original source: https://github.com/SigmaHQ/sigma/blob/master/rules/windows/file/file_event/file_event_win_shell_write_susp_directory.yml