agentleFS
fatihkanfatihkan/badi/.claude/skills-vault/pentest-detection/SKILL.md

pentest-detection

Skill8 starsChanged 3 months agoMITView on GitHub

Detection engineering — Sigma, Splunk SPL, Elastic KQL, Microsoft Sentinel KQL, YARA, Suricata rule writing advisory. Triggers on detection engineering, Sigma rule, Splunk SPL, Elastic KQL, Sentinel KQL, YARA, Suricata, Snort, SIEM rule, EDR rule, hunting query.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After the pentest, map every finding to a detection rule:

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

pentest-detection

Defensive detection-rule writing. Converts pentest findings into detection rules — to catch future attacks.

Triggers

  • "write a Sigma rule"
  • "Splunk SPL query"
  • "KQL hunting query"
  • "Sentinel rule"
  • "YARA signature"
  • "Suricata rule"
  • "detection coverage analysis"

Sigma (Vendor-Agnostic)

title: Suspicious PowerShell Encoded Command Execution
id: 12345678-1234-1234-1234-1234567890ab
status: experimental
description: Detects PowerShell with -EncodedCommand flag, common in payloads
references:
  - https://attack.mitre.org/techniques/T1059/001/
author: Security Team
date: 2026/05/15
tags:
  - attack.execution
  - attack.t1059.001
logsource:
  product: windows
  service: powershell
  category: process_creation
detection:
  selection:
    EventID: 4104
    ScriptBlockText|contains:
      - '-EncodedCommand'
      - '-enc '
      - '-e '
  filter:
    User|startswith: 'NT AUTHORITY\SYSTEM'
  condition: selection and not filter
falsepositives:
  - Legitimate admin scripts
level: high

Splunk SPL

index=windows EventCode=4104
| where match(ScriptBlockText, "-EncodedCommand|-enc\s|-e\s")
| stats count by Computer, User, ScriptBlockText
| where count > 1
| sort -count

Elastic KQL

event.code:"4104"
AND powershell.file.script_block_text:(*-EncodedCommand* OR *-enc * OR *-e *)
AND NOT user.name:"SYSTEM"

Microsoft Sentinel KQL

SecurityEvent
| where EventID == 4104
| where EventData has_any ("-EncodedCommand", "-enc ", "-e ")
| where Account != "NT AUTHORITY\\SYSTEM"
| summarize count() by Computer, Account, EventData
| where count_ > 0

YARA (Malware/File Signature)

rule SuspiciousPowerShellLoader {
    meta:
        author = "Security Team"
        date = "2026-05-15"
        description = "Detects PowerShell with base64 + IEX pattern"
        tags = "attack.t1059.001"

    strings:
        $iex = "IEX" nocase
        $invoke = "Invoke-Expression" nocase
        $b64 = /[A-Za-z0-9+\/]{50,}={0,2}/   // base64 blob >= 50 char
        $download = "DownloadString" nocase
        $bypass = "ExecutionPolicy Bypass" nocase

    condition:
        ($iex or $invoke) and $b64 and ($download or $bypass)
}

Suricata (Network IDS)

alert http any any -> any any (msg:"Possible SQL Injection in URI"; \
  flow:established,to_server; \
  http.uri; content:"' OR '1"; nocase; \
  classtype:web-application-attack; sid:1000001; rev:1;)

alert dns any any -> any any (msg:"DNS Query to Suspicious DGA Domain"; \
  dns.query; content:"|"; depth:30; pcre:"/^[a-z0-9]{20,}\.(com|net)$/i"; \
  classtype:trojan-activity; sid:1000002; rev:1;)

Detection Coverage Mapping

After the pentest, map every finding to a detection rule:

finding: BloodHound LDAP enumeration
mitre: T1087.002 (Account Discovery: Domain Account)
detection:
  - sigma:
      file: bloodhound_ldap_query.yml
      query: large_ldap_query_pattern
  - splunk: |
      index=windows EventCode=4662
      | where ObjectName="DC=*"
      | stats count by SubjectUserName
      | where count > 1000
  - sentinel: |
      SecurityEvent
      | where EventID == 4662
      | where ObjectName contains "DC="
      | summarize count() by Account
      | where count_ > 1000

Atomic Red Team Mapping

Aligning ART tests with pentest findings:

# Pentest finding: PsExec lateral
# ART test: T1021.002 - Test 1 (PsExec.exe)

# Detection test
Invoke-AtomicTest T1021.002-1

# Run the query in the SIEM; it should return hits
# If no hit comes back, there's a coverage gap

Detection Rule Test Strategy

1. Positive test: simulated attack -> rule fires
2. Negative test: normal activity -> no false positive
3. Tuning: baseline 7-30 days, calculate false positive rate
4. Action: low confidence -> alert only, high -> auto-isolate

Output Template

## Detection Coverage — <engagement>

### Finding -> Detection Rule
| Finding | ATT&CK | Sigma | Splunk | Sentinel | Coverage |
|-------|--------|-------|--------|----------|----------|
| Kerberoast | T1558.003 | DC1234 | yes | yes | FULL |
| PsExec lateral | T1021.002 | DC1235 | yes | no | PARTIAL |
| BloodHound LDAP | T1087.002 | (new) | (new) | (new) | NEW |
| DCSync | T1003.006 | DC1236 | yes | yes | FULL |

### Gap Analysis
- BloodHound LDAP enum: NO coverage in any SIEM
  -> Suggest a new Sigma rule (attached to this report)
- PsExec: not in Sentinel
  -> Write a Sentinel detection rule template

### Test
- Atomic Red Team T1021.002-1 -> Splunk: HIT, Sentinel: MISS
- Recommended action: Sentinel detection rule ship

Out-of-Scope

  • Production SIEM changes (rule writing only; deployment is the client's)
  • Real-time blue team operations

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.