socq

SOC query translator — daily hunting intents to KQL + AQL, with a built-in Windows event-ID catalogue

v1.3.1
Linux

Quick start

Install via jcli

jcli install socq

Daily SOC intents → ready-to-paste queries

# Find a user's sign-ins for the last 7 days (KQL for Sentinel)
socq --target sentinel find-user --name "alice@example.com" --last-7d

# Same intent, Defender XDR dialect (Timestamp instead of TimeGenerated)
socq --target defender find-user --name "alice@example.com" --last-7d

# QRadar AQL, last 24 hours (default)
socq --target qradar find-user --name "alice"

# Failed logins above a threshold
socq --target sentinel failed-logins --user "alice" --threshold 10 --last-24h

# All connections from a host to a specific destination IP
socq --target defender host-connections --host WIN-001 --to-ip 1.2.3.4 --last-3d

# Hash IOC hunt across endpoint telemetry
socq --target defender ioc-hash --sha256 ab12cd34...

# Time window via explicit START/STOP
socq --target qradar ioc-ip --ip 10.0.0.5 --between "2026-06-01 00:00" "2026-06-04 12:00"

Event-ID catalogue (built-in lookup)

# Look up a Windows Security Audit event by ID (410 entries, offline)
socq event winos 4624
socq event winos 4769

# Free-text search across summary + detail + category
socq event winos --search "pre-auth"
socq event winos --search "lockout"

# Hierarchical source slot — linux / cisco / siem catalogues land later
socq event linux 1100

Port-number reference (security flag)

# Port lookup with colour-coded status (green SECURE / red INSECURE / …)
socq port 22
socq port 23
socq port 6379

# Free-text search across the curated catalogue
socq port --search wireguard
socq port --search smb

# Compact one-liner per row across the whole catalogue
socq port --list

Discovery + ergonomics

# List every recipe with the SIEMs it supports
socq list-recipes

# Per-recipe prerequisites + analyst notes + MITRE tags + doc citations
socq explain kerberos-anomaly

# Wrap the query with a 4-line header comment (target / recipe / time / source)
socq --target sentinel --header find-user --name alice --last-24h

# Copy directly to the clipboard via wl-copy / xclip / xsel
socq --target qradar --copy ioc-ip --ip 1.2.3.4

# Markdown export — wraps the emitted query in a fenced code block
# tagged `kql` / `sql` so it pastes cleanly into runbooks
socq --target sentinel --format md find-user --name alice --last-24h
socq --target defender --format md --header host-processes --host WIN-001

Reference subcommands (new in v1.1)

# MITRE ATT&CK technique lookup — ~60 curated enterprise techniques
socq ttp T1059.001          # by T-code
socq ttp "powershell"       # by name (case-insensitive substring)
# → tactic + summary + attack.mitre.org URL + list of matching recipes

# Investigation packs — ordered multi-recipe playbooks
socq pack                   # list available packs
socq pack bec               # BEC walkthrough (find-user → risky-signins → mfa-fatigue → …)
socq pack ransomware        # ransomware playbook
socq pack credential-theft  # credential-theft hunt
socq pack insider-exfil     # insider exfiltration scenario
socq pack initial-access    # initial-access discovery
socq pack privilege-escalation

# KQL / AQL syntax quick-reference cards
socq syntax operators       # core operator tables, per dialect
socq syntax time            # time-window patterns
socq syntax aggregation     # summarize / group-by recipes

Why socq

Recipe catalogue

RecipeSentinelDefenderQRadarWhat it answers
find-userSign-ins / activity for a username
failed-loginsFailed sign-ins above a threshold
new-userAccount creation events
privilege-grantRole / admin group changes
risky-signinsEntra ID Protection risk detections
host-processes4688 / DeviceProcessEvents
host-connectionsOutbound connections from a host
dns-to-domainDNS queries to a domain
host-file-writes4663 / Sysmon 11 / DeviceFileEvents
host-logons4624 / 4625 / DeviceLogonEvents
alerts-by-severityNative alerts / offenses
email-by-senderEmail delivery events
ioc-hashSHA-256 / SHA-1 / MD5 IOC
ioc-ipIP IOC across endpoints + flows
ioc-domainDomain / URL IOC
rdp-sourcesRDP source IPs (logon type 10)
smb-anomalySMB (445 / 139) traffic
kerberos-anomaly4768 / 4769 ticket events
legacy-authBasic / legacy auth sign-ins
cloud-app-activityCloudAppEvents by user / app
v1.1 — 8 new hunting recipes:
oauth-consentOAuth consent grants (consent-phishing). T1528, T1098.003
inbox-rulesNew / modified inbox rules — BEC tradecraft. T1564.008, T1114.003
mail-forwardingSet-Mailbox with ForwardingSmtpAddress / ForwardingAddress. T1114.003, T1098.002
encoded-powershellPowerShell -EncodedCommand / -enc invocations. T1059.001, T1027
lolbin-execCurated LOLBin process list (certutil, mshta, rundll32, regsvr32, …). T1218, T1059, T1140
pim-role-activationEntra PIM just-in-time admin activations. T1078.004, T1098.003
conditional-access-changeEntra CA policy create / update / delete. T1556, T1484.002
mfa-fatigueRepeated MFA challenges within 15 min followed by a success (push-bombing). T1621, T1110.004

Investigation packs

Memo-style ordered playbooks — each step picks a recipe with a one-line rationale, in the order an on-call analyst typically runs them. Recipe slugs are compile-time-checked against the catalogue so a renamed recipe never silently breaks a pack.

PackScenario
becBusiness Email Compromise — mailbox compromise, fraudulent invoice, unexpected forwarding
ransomwareEDR fires on encryption activity, or user reports .encrypted files / ransom note
credential-theftRisky sign-in, password-spray hit, or stolen-creds tip-off
insider-exfilHR notice of departure + suspicion of data-theft staging
initial-accessFirst-touch discovery — phishing link clicked, exposed-RDP brute force, etc.
privilege-escalationSuspected lateral movement / admin-group abuse / PIM tampering

Reference subcommands