# OffSet7: Metasploit Or Impacket Service Installation Via SMB PsExec

> 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 channel)

## Building blocks

### BB:OffSet7:Metasploit Or Impacket Service Installation Via :selection (match)
All test lines must match (AND).
- when **Event ID** is equal to (case-insensitive): `4697`
- when **Service Filename** matches the regular expression: `^%systemroot%\\[a-zA-Z]{8}\.exe$`
- when **Service Name** matches the regular expression: `(^[a-zA-Z]{4}$)|(^[a-zA-Z]{8}$)|(^[a-zA-Z]{16}$)`
- when **custom property for ServiceStartType** is equal to (case-insensitive): `3` — No QRadar property mapped for "ServiceStartType": create a custom event property (regex or JSON) on the DSM first.
- when **custom property for ServiceType** is equal to (case-insensitive): `0x10` — No QRadar property mapped for "ServiceType": create a custom event property (regex or JSON) on the DSM first.

### BB:OffSet7:Metasploit Or Impacket Service Installation Via :filter (exclusion)
All test lines must match (AND).
- when **Service Name** is equal to (case-insensitive): `PSEXESVC`

## 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 channel)`
2. when an event matches the condition built from these building blocks: `BB:OffSet7:Metasploit Or Impacket Service Installation Via :selection AND NOT BB:OffSet7:Metasploit Or Impacket Service Installation Via :filter`

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

Not available: the AQL conversion failed for this rule.

## 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

- AQL conversion failed (field 'ServiceStartType' is not supported); only the building-block design is available.
- 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.
- Regular expressions (|re) use Java regex in QRadar; verify syntax in the Rule Wizard.

Source rule: Metasploit Or Impacket Service Installation Via SMB PsExec (6fb63b40-e02a-403e-9ffd-3bcc1d749442). Author: Bartlomiej Czyz, Relativity. Licence: DRL-1.1.
