/code-health:threat-huntingfrom Code Health
Writes Sigma detection rules for proactive threat hunting, including log source mapping, detection patterns, and MITRE ATT&CK alignment.
Ships in Code Health. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Threat hunting с использованием Sigma rules, detection engineering, анализ безопасности.
title: Suspicious PowerShell Execution
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects suspicious PowerShell command execution
author: Your Name
date: 2024/01/15
references:
- https://attack.mitre.org/techniques/T1059/001/
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\powershell.exe'
CommandLine|contains:
- '-enc'
- '-EncodedCommand'
- 'bypass'
- 'hidden'
condition: selection
falsepositives:
- Legitimate admin scripts
level: medium
tags:
- attack.execution
- attack.t1059.001
# String matching
detection:
selection:
CommandLine|contains: 'mimikatz'
# Multiple conditions
detection:
selection1:
Image|endswith: '\cmd.exe'
selection2:
CommandLine|contains:
- 'whoami'
- 'net user'
condition: selection1 and selection2
# Exclusions
detection:
selection:
EventType: 'ProcessCreate'
filter:
User: 'SYSTEM'
condition: selection and not filter
# Regex
detection:
selection:
CommandLine|re: '.*\.(ps1|bat|cmd).*-[eE].*'
| Modifier | Description |
|---|---|
contains | String contains |
startswith | String starts with |
endswith | String ends with |
re | Regular expression |
base64 | Base64 encoded |
all | All items must match |
cidr | IP CIDR range |
title: Suspicious Script Execution
logsource:
category: process_creation
detection:
selection:
Image|endswith:
- '\powershell.exe'
- '\pwsh.exe'
- '\cmd.exe'
- '\wscript.exe'
- '\cscript.exe'
CommandLine|contains:
- 'downloadstring'
- 'invoke-expression'
- 'iex'
- 'bypass'
condition: selection
title: Scheduled Task Creation
logsource:
product: windows
service: security
detection:
selection:
EventID: 4698
filter:
TaskName|contains:
- 'Microsoft'
- 'Windows'
condition: selection and not filter
title: Windows Defender Disabled
logsource:
product: windows
service: security
detection:
selection:
EventID: 5001
condition: selection
level: high
title: LSASS Memory Access
logsource:
category: process_access
product: windows
detection:
selection:
TargetImage|endswith: '\lsass.exe'
GrantedAccess|contains:
- '0x1010'
- '0x1410'
filter:
SourceImage|endswith:
- '\wmiprvse.exe'
- '\taskmgr.exe'
condition: selection and not filter
level: critical
| Log | Event IDs | Use Case |
|---|---|---|
| Security | 4624, 4625 | Logon events |
| Security | 4688 | Process creation |
| Security | 4698-4702 | Scheduled tasks |
| Sysmon | 1 | Process create |
| Sysmon | 3 | Network connection |
| Sysmon | 7 | Image load (DLL) |
| Sysmon | 10 | Process access |
| PowerShell | 4103, 4104 | Script block logging |
logsource:
product: linux
service: auditd
detection:
selection:
type: 'EXECVE'
a0|contains: '/bin/bash'
a1|contains: '-c'
# Suspicious PowerShell
index=windows sourcetype=WinEventLog:Security EventCode=4688
| where match(CommandLine, "(?i)(invoke-expression|iex|downloadstring)")
| stats count by User, CommandLine, Computer
# Failed logins
index=windows sourcetype=WinEventLog:Security EventCode=4625
| stats count by src_ip, user
| where count > 10
# Rare processes
index=windows sourcetype=WinEventLog:Security EventCode=4688
| rare NewProcessName limit=20
// Suspicious command lines
process.command_line: (*mimikatz* OR *sekurlsa* OR *kerberos*)
// Encoded PowerShell
process.name: "powershell.exe" AND
process.command_line: (*-enc* OR *-EncodedCommand*)
// Network connections to rare ports
event.category: "network" AND
destination.port: (4444 OR 5555 OR 8888)
1. HYPOTHESIS
- What attack are we detecting?
- MITRE ATT&CK technique?
2. DATA REQUIREMENTS
- What logs needed?
- Are they being collected?
3. LOGIC DEVELOPMENT
- Write Sigma rule
- Test against known-bad
4. TESTING
- Atomic Red Team simulation
- Check false positives
5. TUNING
- Add exclusions
- Adjust thresholds
6. DEPLOYMENT
- Convert to SIEM format
- Set alerting
# Install sigmac
pip install sigma-cli
# Convert to Splunk
sigma convert -t splunk rule.yml
# Convert to Elastic
sigma convert -t elasticsearch rule.yml
# Convert to QRadar
sigma convert -t qradar rule.yml
from sigma.parser.rule import SigmaRule
from sigma.backends.splunk import SplunkBackend
def convert_sigma_to_splunk(rule_path: str) -> str:
"""Convert Sigma rule to Splunk query"""
with open(rule_path, 'r') as f:
rule = SigmaRule.from_yaml(f.read())
backend = SplunkBackend()
return backend.generate(rule)
def validate_sigma_rule(rule_path: str) -> dict:
"""Validate Sigma rule syntax"""
try:
with open(rule_path, 'r') as f:
rule = SigmaRule.from_yaml(f.read())
return {
"valid": True,
"title": rule.title,
"level": rule.level,
"tags": rule.tags
}
except Exception as e:
return {
"valid": False,
"error": str(e)
}
# Install Atomic Red Team
IEX (IWR 'https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1' -UseBasicParsing)
# Run specific test
Invoke-AtomicTest T1059.001 -TestNumbers 1
# Run and generate logs
Invoke-AtomicTest T1003.001 -GetPrereqs
Invoke-AtomicTest T1003.001 -TestNumbers 1,2,3
# Cleanup
Invoke-AtomicTest T1059.001 -Cleanup
# Threat Hunt: [Name]
## Hypothesis
Based on [intelligence/observation], we believe [threat actor/technique]
may be present in our environment.
## MITRE ATT&CK
- Technique: [T1xxx]
- Tactic: [Tactic name]
## Data Sources Required
- [ ] Windows Security Events
- [ ] Sysmon
- [ ] Network logs
- [ ] EDR telemetry
## Detection Logic
### Query 1: [Description]
```query
[SIEM query here]
[Query here]
| Timestamp | Host | User | Finding | Severity |
|---|---|---|---|---|
| [Time] | [Host] | [User] | [Finding] | [H/M/L] |
## Tips
1. **Start with hypothesis** - что ищем?
2. **Know your baseline** - что "нормально"
3. **Use MITRE ATT&CK** - структурируй охоту
4. **Document everything** - для повторяемости
5. **Tune rules** - уменьшай false positives
6. **Automate testing** - Atomic Red Team
7. **Share intelligence** - community rules
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jhamidun/claude-code-config-pack --plugin code-health9 skills in this plugin
/config-healthЗдоровье конфига Claude Code: битые ссылки, вес промпта, лимит памяти, живость MCP. Триггеры: «проверь конфиг», «вес промпта». НЕ чужой скилл→skill-manager; НЕ код→health-inline/health-inlineЧинит codebase health инлайн: /health bugs|cleanup|deps|reuse|security — детекция→фикс→верификация. Только pnpm+TypeScript-репо. НЕ одна красная сборка→build-fix./leak-scanPII/деанон перед публикацией (leak_scan.py) + prompt-injection в чужом скилле (skill_injection_scan.py). Триггеры: «обезличь репо», «проверь скилл перед установкой».Other plugins' skills for the same job