Detection rules › Sigma

PowerShell Script With File Upload Capabilities

Status
test
Severity
low
Log source
product windows, category ps_script
Author
frack113
Source
github.com/SigmaHQ/sigma

Detects PowerShell scripts leveraging the "Invoke-WebRequest" cmdlet to send data via either "PUT" or "POST" method.

MITRE ATT&CK coverage

TacticTechniques
ExfiltrationT1020 Automated Exfiltration

Event coverage

Rule body yaml

title: PowerShell Script With File Upload Capabilities
id: d2e3f2f6-7e09-4bf2-bc5d-90186809e7fb
status: test
description: Detects PowerShell scripts leveraging the "Invoke-WebRequest" cmdlet to send data via either "PUT" or "POST" method.
references:
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1020/T1020.md
    - https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
    - https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4
author: frack113
date: 2022-01-07
modified: 2025-07-18
tags:
    - attack.exfiltration
    - attack.t1020
logsource:
    product: windows
    category: ps_script
    definition: bade5735-5ab0-4aa7-a642-a11be0e40872
detection:
    selection_cmdlet:
        ScriptBlockText|contains:
            - 'Invoke-RestMethod'
            - 'Invoke-WebRequest'
            - 'irm '
            - 'iwr '
    selection_flag:
        ScriptBlockText|contains:
            - '-Method "POST"'
            - '-Method "PUT"'
            - '-Method POST'
            - '-Method PUT'
            - "-Method 'POST'"
            - "-Method 'PUT'"
    condition: all of selection_*
falsepositives:
    - Unknown
level: low

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_cmdlet

selection_cmdlet:
    ScriptBlockText|contains:
        - 'Invoke-RestMethod'
        - 'Invoke-WebRequest'
        - 'irm '
        - 'iwr '

Stage 2: selection_flag

selection_flag:
    ScriptBlockText|contains:
        - '-Method "POST"'
        - '-Method "PUT"'
        - '-Method POST'
        - '-Method PUT'
        - "-Method 'POST'"
        - "-Method 'PUT'"

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
ScriptBlockTextmatch
  • -Method "POST"
  • -Method "PUT"
  • -Method 'POST'
  • -Method 'PUT'
  • -Method POST
  • -Method PUT
  • Invoke-RestMethod corpus 4 (sigma 3, splunk 1)
  • Invoke-WebRequest corpus 3 (sigma 3)
  • irm
  • iwr corpus 3 (sigma 3)