PowerShell profile script written to a known profile path
Matches Sysmon file creation of a PowerShell profile script — profile.ps1 or a per-host Microsoft.PowerShell_profile.ps1/ISE/VSCode variant — landing in a WindowsPowerShell\ or PowerShell\ folder, the concrete half of AN1245 that a single event can carry; the analytic's other half, correlating the write with a later PowerShell launch that omits -NoProfile, spans two events and Sigma has no join for it. The match is anchored on the last two path segments rather than the full path because Documents is frequently OneDrive- or UNC-redirected, and a full-path match would silently miss every redirected profile. Both the per-user and the all-users ($PSHOME) locations are included, since either gives an adversary unattended code execution on every new PowerShell session. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0451, not hand-written and not tested by its author. Any lab result is on this rule's own page.Full descriptionShow less
The detection
The 4 SIEM queries below are previews produced by Siemphony’s own translator, not pySigma, and none has been executed against a real backend — review before you deploy.
detection.yml
title: PowerShell profile script written to a known profile pathid: f1cff0e9-c670-4857-b1cb-02b559290d5bstatus: experimentaldescription: | Matches Sysmon file creation of a PowerShell profile script — profile.ps1 or a per-host Microsoft.PowerShell_profile.ps1/ISE/VSCode variant — landing in a WindowsPowerShell\ or PowerShell\ folder, the concrete half of AN1245 that a single event can carry; the analytic's other half, correlating the write with a later PowerShell launch that omits -NoProfile, spans two events and Sigma has no join for it. The match is anchored on the last two path segments rather than the full path because Documents is frequently OneDrive- or UNC-redirected, and a full-path match would silently miss every redirected profile. Both the per-user and the all-users ($PSHOME) locations are included, since either gives an adversary unattended code execution on every new PowerShell session. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0451, not hand-written and not tested by its author. Any lab result is on this rule's own page.references: - https://attack.mitre.org/techniques/T1546/013 - https://attack.mitre.org/detectionstrategies/DET0451author: Siemphony pipeline (machine-derived from MITRE ATT&CK v19.2)date: 2026-08-16tags: - attack.privilege-escalation - attack.persistence - attack.t1546.013logsource: category: file_event product: windowsdetection: selection: TargetFilename|endswith: - '\WindowsPowerShell\profile.ps1' - '\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' - '\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1' - '\WindowsPowerShell\Microsoft.VSCode_profile.ps1' - '\PowerShell\profile.ps1' - '\PowerShell\Microsoft.PowerShell_profile.ps1' - '\PowerShell\Microsoft.VSCode_profile.ps1' condition: selectionfalsepositives: - "A user customizing their own console appearance, aliases or module imports by editing profile.ps1 in a text editor or VS Code — the single most common event this path ever sees on a developer workstation." - "Endpoint management tooling (an MDM policy or GPO logon script) that centrally deploys a standard corporate profile.ps1 to the all-users PowerShell\\ path during provisioning." - "PowerShell module installers such as Oh My Posh or PSReadLine setup scripts that append an Import-Module line to the user's profile on first run."level: lowSentinel · KQL
Run this as a search.
DeviceFileEvents| where (FolderPath endswith "\\WindowsPowerShell\\profile.ps1" or FolderPath endswith "\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1" or FolderPath endswith "\\WindowsPowerShell\\Microsoft.PowerShellISE_profile.ps1" or FolderPath endswith "\\WindowsPowerShell\\Microsoft.VSCode_profile.ps1" or FolderPath endswith "\\PowerShell\\profile.ps1" or FolderPath endswith "\\PowerShell\\Microsoft.PowerShell_profile.ps1" or FolderPath endswith "\\PowerShell\\Microsoft.VSCode_profile.ps1")
Splunk · SPL
Run this as a search.
index=* (TargetFilename="*\\WindowsPowerShell\\profile.ps1" OR TargetFilename="*\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1" OR TargetFilename="*\\WindowsPowerShell\\Microsoft.PowerShellISE_profile.ps1" OR TargetFilename="*\\WindowsPowerShell\\Microsoft.VSCode_profile.ps1" OR TargetFilename="*\\PowerShell\\profile.ps1" OR TargetFilename="*\\PowerShell\\Microsoft.PowerShell_profile.ps1" OR TargetFilename="*\\PowerShell\\Microsoft.VSCode_profile.ps1")Elastic · ES|QL
Run this as a search.
FROM logs-*| WHERE (TO_LOWER(file.path) LIKE "*\\\\windowspowershell\\\\profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\windowspowershell\\\\microsoft.powershell_profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\windowspowershell\\\\microsoft.powershellise_profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\windowspowershell\\\\microsoft.vscode_profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\powershell\\\\profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\powershell\\\\microsoft.powershell_profile.ps1" OR TO_LOWER(file.path) LIKE "*\\\\powershell\\\\microsoft.vscode_profile.ps1")
Wazuh · XML rule
Deploy to your manager — this is a rule, not a search.
<group name="sigma,windows,file_event,"> <!-- Rule ids must be unique on your manager; 100000+ is the user range. --> <rule id="100000" level="5"> <!-- Set <if_sid> to the decoder/base rule for windows so this only evaluates relevant events. --> <field name="TargetFilename" type="pcre2">(?i)(\\WindowsPowerShell\\profile\.ps1$|\\WindowsPowerShell\\Microsoft\.PowerShell_profile\.ps1$|\\WindowsPowerShell\\Microsoft\.PowerShellISE_profile\.ps1$|\\WindowsPowerShell\\Microsoft\.VSCode_profile\.ps1$|\\PowerShell\\profile\.ps1$|\\PowerShell\\Microsoft\.PowerShell_profile\.ps1$|\\PowerShell\\Microsoft\.VSCode_profile\.ps1$)</field> <description>PowerShell profile script written to a known profile path</description> <mitre> <id>T1546.013</id> </mitre> </rule></group>
Verdicts · reactions · comments
Community
Verdicts from engineers who actually deployed it, and the conversation around it.
Nobody has run this in a real environment and said what happened.
Verdicts from engineers who deployed it
0 castNo verdicts reported yet. The first one is worth more than the tenth — say what you ran it against.
Log in to report a verdict.
Log in to join the discussion.
No comments yet. Someone who deploys this will have something to say about it.