hypnguyen1209/offensive-claude / skills/threat-hunting
threat-hunting
FlaggedUse when hunting threats or engineering detections — ATT&CK Detection-Strategies, Sigma + correlation with Detection-as-Code CI, Windows endpoint hunting (Sysmon/ETW/LSASS/LOLBins), network C2 hunting (JA4+, beaconing, DNS tunneling), cloud-identity hunting, Atomic Red Team purple-team validation
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.2 KB |
| references/cloud-identity-hunting.md | markdown | 9.2 KB |
| references/methodology-hunt-loop.md | markdown | 7.9 KB |
| references/network-c2-hunting.md | markdown | 8.6 KB |
| references/purple-team-validation.md | markdown | 6.4 KB |
| references/sigma-rule-engineering.md | markdown | 9.6 KB |
| references/windows-endpoint-hunting.md | markdown | 10.6 KB |
| scripts/beacon_hunter.py | script | 9.8 KB |
| scripts/cloudtrail_hunt.py | script | 7.8 KB |
| scripts/coverage_matrix.py | script | 7.2 KB |
| scripts/dac_validate.py | script | 6.1 KB |
| scripts/entra_hunt.kql | other | 4.8 KB |
| scripts/evtx_hunt.py | script | 9.5 KB |
| scripts/sigma_pipeline.sh | script | 2.3 KB |
| scripts/sysmon_config_2025.xml | config | 6.9 KB |
scripts/entra_hunt.kql
View on GitHub// =============================================================================
// entra_hunt.kql - Entra ID / M365 / Defender cloud-identity hunting pack
//
// USAGE: paste each query into Microsoft Sentinel Logs or Advanced Hunting
// (Microsoft 365 Defender). Tune the lookback (ago(Nd)) and tenant
// baselines (allowed ASNs, sanctioned device-code apps) before alerting.
//
// Tables: SigninLogs, AuditLogs, MicrosoftGraphActivityLogs, IdentityLogonEvents,
// DeviceProcessEvents, DeviceFileEvents (M365D / Sentinel).
//
// ATT&CK: T1528 (Steal App Access Token), T1566 (Phishing),
// T1550.001 (App Access Token), T1078.004 (Cloud Accounts),
// T1098 (Account Manipulation), T1114 (Email Collection).
//
// Defensive hunting pack. Authorized use only.
// =============================================================================
// -- 1) Device-code phishing: device-code sign-ins from newly-seen source -----
// STORM-2372 / Tycoon2FA / EvilTokens pattern. AppIds: Auth Broker / OfficeHome.
let watchApps = dynamic([
"29d9ed98-a469-4536-ade2-f981bc1d605e", // Microsoft Authentication Broker
"4765445b-32c6-49b0-83e6-1d93765276ca"]); // OfficeHome (credential-relay variant)
SigninLogs
| where TimeGenerated > ago(14d)
| where AuthenticationProtocol == "deviceCode" and ResultType == 0
| extend asn = tostring(AutonomousSystemNumber), city = tostring(LocationDetails.city)
| summarize firstSeen = min(TimeGenerated), asns = make_set(asn),
ips = make_set(IPAddress), cities = make_set(city)
by UserPrincipalName, AppDisplayName, AppId
| where firstSeen > ago(7d) // device-code newly appearing for this user/app
| extend watched = AppId in (watchApps)
| order by watched desc, firstSeen desc;
// -- 2) Post-token Graph enumeration within 1h of a device-code sign-in -------
let dc = SigninLogs
| where TimeGenerated > ago(7d)
| where AuthenticationProtocol == "deviceCode" and ResultType == 0
| project UserPrincipalName, IPAddress, t0 = TimeGenerated;
MicrosoftGraphActivityLogs
| where TimeGenerated > ago(7d)
| where RequestUri has_any ("/messages", "/mailFolders", "/drive", "/contacts", "/users", "/me/")
| join kind=inner dc on $left.UserId == $right.UserPrincipalName
| where TimeGenerated between (t0 .. (t0 + 1h))
| summarize calls = count(), uris = make_set(RequestUri, 25) by UserPrincipalName, IPAddress
| where calls > 50; // mass harvesting of mailbox/files/contacts
// -- 3) Illicit OAuth consent / risky app credential added --------------------
AuditLogs
| where TimeGenerated > ago(14d)
| where OperationName in ("Consent to application",
"Add app role assignment grant to user",
"Add service principal credentials",
"Update application - Certificates and secrets management")
| mv-expand tr = TargetResources
| extend mods = tostring(tr.modifiedProperties)
| where mods has_any ("Mail.Read","Mail.ReadWrite","Files.ReadWrite.All",
"Directory.Read.All","User.Read.All","full_access_as_app","offline_access")
| project TimeGenerated, OperationName, InitiatedBy = tostring(InitiatedBy.user.userPrincipalName),
AppId = tostring(tr.id), mods;
// -- 4) PRT (Primary Refresh Token) replay from multiple geos same day --------
SigninLogs
| where TimeGenerated > ago(7d)
| where AuthenticationProtocol == "primaryRefreshToken"
| summarize geos = make_set(tostring(LocationDetails.countryOrRegion)),
ips = make_set(IPAddress), devices = make_set(tostring(DeviceDetail.deviceId))
by UserPrincipalName, bin(TimeGenerated, 1d)
| where array_length(geos) > 1; // PRT used from >1 country in a day
// -- 5) Malicious inbox rule created shortly after sign-in (exfil/persistence) -
OfficeActivity
| where TimeGenerated > ago(14d)
| where Operation in ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules")
| extend params = tostring(Parameters)
| where params has_any ("ForwardTo", "RedirectTo", "DeleteMessage",
"MoveToFolder", "RSS Feeds", "Archive")
| project TimeGenerated, UserId, Operation, OriginatingServer, params;
// -- 6) New device registered to tenant (token-survives-revocation persistence)-
AuditLogs
| where TimeGenerated > ago(14d)
| where OperationName in ("Add registered device", "Register device", "Add device")
| extend dev = tostring(TargetResources[0].displayName)
| project TimeGenerated, InitiatedBy = tostring(InitiatedBy.user.userPrincipalName),
dev, Result;
// -- 7) Defender: LSASS / cloudAP access feeding PRT theft (endpoint join) -----
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName in~ ("dsregcmd.exe","mimikatz.exe") or ProcessCommandLine has "cloudap"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine;
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |