# OffSet7: Potential Data Exfiltration Activity Via CommandLine Tools

> Design for the QRadar Rule Wizard. Not an importable rule and not tested in QRadar.

- Rule type: Event rule (Local), create disabled
- Log source types: Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1

## Building blocks

### BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_iwr (match)
All test lines must match (AND).
- when **Process Path / Process Name** ends with: `\powershell_ise.exe`, `\powershell.exe`, `\pwsh.exe`, `\cmd.exe`
- when **Command** contains: `curl`, `Invoke-RestMethod`, `Invoke-WebRequest`, `irm`, `iwr`, `wget`
- when **Command** contains: ` -ur`, ` -me`, ` -b`, ` POST`

### BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_curl (match)
All test lines must match (AND).
- when **Process Path / Process Name** ends with: `\curl.exe`
- when **Command** contains: `--ur`

### BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_curl_data (match)
All test lines must match (AND).
- when **Command** contains: ` -d`, ` --data`

### BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_wget (match)
All test lines must match (AND).
- when **Process Path / Process Name** ends with: `\wget.exe`
- when **Command** contains: `--post-data`, `--post-file`

### BB:OffSet7:Potential Data Exfiltration Activity Via Command:payloads (match)
Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.
- when **Command** matches the regular expression: `net\s+view`, `sc\s+query`
- when **Command** contains: `Get-Content`, `GetBytes`, `hostname`, `ifconfig`, `ipconfig`, `netstat`, `nltest`, `qprocess`, `systeminfo`, `tasklist`, `ToBase64String`, `whoami`
- when **Command** contains: `type`, ` >`, ` C:\`

## Main rule — option A (building blocks)

1. when the event(s) were detected by one or more of these log source types: `Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1`
2. when an event matches the condition built from these building blocks: `(BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_iwr OR (ALL of [BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_curl, BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_curl_data]) OR BB:OffSet7:Potential Data Exfiltration Activity Via Command:selection_wget) AND BB:OffSet7:Potential Data Exfiltration Activity Via Command:payloads`

## Main rule — option B (AQL filter test)

1. when the event matches this AQL filter query: `devicetype=12 AND ((((LOWER("Process Path") LIKE '%\powershell_ise.exe' OR LOWER("Process Path") LIKE '%\powershell.exe' OR LOWER("Process Path") LIKE '%\pwsh.exe' OR LOWER("Process Path") LIKE '%\cmd.exe') OR (LOWER("Process Name") LIKE '%\powershell_ise.exe' OR LOWER("Process Name") LIKE '%\powershell.exe' OR LOWER("Process Name") LIKE '%\pwsh.exe' OR LOWER("Process Name") LIKE '%\cmd.exe')) AND (LOWER(Command) LIKE '%curl %' OR LOWER(Command) LIKE '%invoke-restmethod%' OR LOWER(Command) LIKE '%invoke-webrequest%' OR LOWER(Command) LIKE '%irm %' OR LOWER(Command) LIKE '%iwr %' OR LOWER(Command) LIKE '%wget %') AND (LOWER(Command) LIKE '% -ur%' AND LOWER(Command) LIKE '% -me%' AND LOWER(Command) LIKE '% -b%' AND LOWER(Command) LIKE '% post %')) OR (((LOWER("Process Path") LIKE '%\curl.exe' OR LOWER("Process Name") LIKE '%\curl.exe') AND LOWER(Command) LIKE '%--ur%') AND (LOWER(Command) LIKE '% -d %' OR LOWER(Command) LIKE '% --data %')) OR ((LOWER("Process Path") LIKE '%\wget.exe' OR LOWER("Process Name") LIKE '%\wget.exe') AND (LOWER(Command) LIKE '%--post-data%' OR LOWER(Command) LIKE '%--post-file%'))) AND ((Command MATCHES '(?i)net\s+view' OR Command MATCHES '(?i)sc\s+query') OR (LOWER(Command) LIKE '%get-content%' OR LOWER(Command) LIKE '%getbytes%' OR LOWER(Command) LIKE '%hostname%' OR LOWER(Command) LIKE '%ifconfig%' OR LOWER(Command) LIKE '%ipconfig%' OR LOWER(Command) LIKE '%netstat%' OR LOWER(Command) LIKE '%nltest%' OR LOWER(Command) LIKE '%qprocess%' OR LOWER(Command) LIKE '%systeminfo%' OR LOWER(Command) LIKE '%tasklist%' OR LOWER(Command) LIKE '%tobase64string%' OR LOWER(Command) LIKE '%whoami%') OR (LOWER(Command) LIKE '%type %' AND LOWER(Command) LIKE '% > %' AND LOWER(Command) LIKE '% c:\%'))`

## Rule response

- Severity 7, credibility 6, relevance 7
- Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
- Respond no more than once per 30 minutes per Log Source (tune per environment)

## Limitations

- QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.

Source rule: Potential Data Exfiltration Activity Via CommandLine Tools (7d1aaf3d-4304-425c-b7c3-162055e0b3ab). Author: Nasreddine Bencherchali (Nextron Systems). Licence: DRL-1.1.
