T1546.013 IBM QRadar · QRadar

Detect PowerShell Profile in IBM QRadar

Adversaries may establish persistence by placing malicious commands into a PowerShell profile. A PowerShell profile script is a script that runs when PowerShell starts and can be used as a logon script to customize user environments. PowerShell supports several profile locations including: $PROFILE (current user, current host), $PROFILE.AllUsersCurrentHost (all users, current host), $PROFILE.CurrentUserAllHosts (current user, all hosts), and $PROFILE.AllUsersAllHosts (all users, all hosts — the most powerful). Malicious profile content executes whenever an interactive PowerShell session is started, providing persistent code execution in the user's context.

MITRE ATT&CK

Tactic
Privilege Escalation Persistence
Technique
T1546 Event Triggered Execution
Sub-technique
T1546.013 PowerShell Profile
Canonical reference
https://attack.mitre.org/techniques/T1546/013/

QRadar Detection Query

IBM QRadar (QRadar)
sql
SELECT
  DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS event_time,
  logsourcename(logsourceid) AS log_source,
  "sourceip",
  "username",
  "filename",
  QIDNAME(qid) AS event_name,
  "filepath",
  "processname",
  "processcommandline"
FROM events
WHERE
  LOGSOURCETYPEID(logsourceid) IN (12, 119)
  AND devicetime > (CURRENT_TIMESTAMP - 86400000)
  AND (
    LOWER("filename") IN (
      'microsoft.powershell_profile.ps1',
      'microsoft.vscode_profile.ps1',
      'microsoft.powershellise_profile.ps1',
      'profile.ps1'
    )
    OR (
      (LOWER("filepath") LIKE '%windowspowershell%' OR LOWER("filepath") LIKE '%\powershell\%')
      AND LOWER("filename") LIKE '%.ps1'
    )
  )
  AND qid IN (
    SELECT id FROM qidmap WHERE name LIKE '%File Created%' OR name LIKE '%File Modified%' OR name LIKE '%Sysmon%FileCreate%'
  )
  AND LOWER("processname") NOT IN (
    'powershell.exe', 'pwsh.exe', 'notepad.exe', 'code.exe',
    'devenv.exe', 'vim.exe', 'nano.exe'
  )
ORDER BY devicetime DESC
high severity medium confidence

Detects PowerShell profile file creation or modification by non-standard processes using Sysmon file creation events (EventID 11) or Windows Security audit events. Flags writes to profile.ps1 and host-specific profile files from processes outside the expected set of editors and PowerShell itself.

Data Sources

Windows Sysmon (LogSource Type 12)Windows Security Events (LogSource Type 119)

Required Tables

events

False Positives & Tuning

  • Endpoint management agents (Microsoft Intune, SCCM client) writing baseline PowerShell profiles as part of device configuration policies
  • Security tooling that legitimately patches or audits profile files as part of compliance hardening scripts
  • CI/CD agents on developer build machines that configure per-user shell environments before running pipeline steps
Download portable Sigma rule (.yml)

Other platforms for T1546.013


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Add Malicious Command to PowerShell Profile

    Expected signal: File modification event (Sysmon 11) for the PowerShell profile file. Process creation for powershell.exe executing Add-Content. PowerShell ScriptBlock Log Event ID 4104 shows the appended content. On next PowerShell launch, Event ID 4104 will show Invoke-Expression and DownloadString.

  2. Test 2Create AllUsers PowerShell Profile with Persistence

    Expected signal: File creation or modification event (Sysmon 11) for C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1. IsSystemProfile=true in detection. Process creation for powershell.exe with Add-Content. This is a high-severity detection — AllUsers profile modification.

  3. Test 3Verify Profile Persistence Execution

    Expected signal: File modification event for PowerShell profile. Process creation for powershell.exe (child session). File creation event for profile_executed.txt in Temp — confirms execution. The spawned PowerShell process loads the profile and executes the New-Item command.

Unlock Pro Content

Get the full detection package for T1546.013 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections