Install any skill in seconds. Free to start, no credit card required.
Get Started Free →SQL-powered forensic investigation and system interrogation using osquery to query operating systems as relational databases. Enables rapid evidence collection, threat hunting, and incident response across Linux, macOS, and Windows endpoints. Use when: (1) Investigating security incidents and collecting forensic artifacts, (2) Threat hunting across endpoints for suspicious activity, (3) Analyzing running processes, network connections, and persistence mechanisms, (4) Collecting system state duri
.claude/skills/aiskillstore-forensics-osquery/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 103% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 98% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 237% | 0% |
| case-22 | ✓→✗ | ▼ Worse | 300% | 0% |
| case-17 | ✓→✓ | = Same ✓ | 651% | 0% |
osquery transforms operating systems into queryable relational databases, enabling security analysts to investigate compromises using SQL rather than traditional CLI tools. This skill provides forensic investigation workflows, common detection queries, and incident response patterns for rapid evidence collection across Linux, macOS, and Windows endpoints.
Core capabilities:
bash# Launch interactive shell osqueryi # Check running processes SELECT pid, name, path, cmdline, uid FROM processes WHERE name LIKE '%suspicious%'; # Identify listening network services SELECT DISTINCT processes.name, listening_ports.port, listening_ports.address, processes.pid, processes.path FROM listening_ports JOIN processes USING (pid) WHERE listening_ports.address != '127.0.0.1'; # Find processes with deleted executables (potential malware) SELECT name, path, pid, cmdline FROM processes WHERE on_disk = 0; # Check persistence mechanisms (Linux/macOS cron jobs) SELECT command, path FROM crontab;
bash# Single query execution osqueryi --json "SELECT * FROM logged_in_users;" # Export query results for analysis osqueryi --json "SELECT * FROM processes;" > processes_snapshot.json # Check for suspicious kernel modules (Linux) osqueryi --line "SELECT name, used_by, status FROM kernel_modules WHERE name NOT IN (SELECT name FROM known_good_modules);"
For rapid assessment of potentially compromised systems:
Progress: ] 1. Collect running processes and command lines ] 2. Identify network connections and listening ports ] 3. Check user accounts and recent logins ] 4. Examine persistence mechanisms (scheduled tasks, startup items) ] 5. Review suspicious file modifications and executions ] 6. Document findings with timestamps and process ancestry ] 7. Export evidence to JSON for preservation
Work through each step systematically. Use bundled triage script for automated collection.
Execute triage: ./scripts/osquery_triage.sh > incident_triage_$(date +%Y%m%d_%H%M%S).json
When hunting for specific MITRE ATT&CK techniques:
sql -- Example: Hunt for credential dumping (T1003) SELECT p.pid, p.name, p.cmdline, p.path, p.parent, pm.permissions FROM processes p JOIN process_memory_map pm ON p.pid = pm.pid WHERE p.name IN ('mimikatz.exe', 'procdump.exe', 'pwdump.exe') OR p.cmdline LIKE '%sekurlsa%' OR (pm.path = '/etc/shadow' OR pm.path LIKE '%SAM%');
Detecting persistence across platforms:
Linux/macOS Persistence:
sql-- Cron jobs SELECT * FROM crontab; -- Systemd services (Linux) SELECT name, path, status, source FROM systemd_units WHERE source != '/usr/lib/systemd/system'; -- Launch Agents/Daemons (macOS) SELECT name, path, program, run_at_load FROM launchd WHERE run_at_load = 1; -- Bash profile modifications SELECT * FROM file WHERE path IN ('/etc/profile', '/etc/bash.bashrc', '/home/*/.bashrc', '/home/*/.bash_profile');
Windows Persistence:
sql-- Registry Run keys SELECT key, name, path, type FROM registry WHERE key LIKE '%Run%' OR key LIKE '%RunOnce%'; -- Scheduled tasks SELECT name, action, path, enabled FROM scheduled_tasks WHERE enabled = 1; -- Services SELECT name, display_name, status, path, start_type FROM services WHERE start_type = 'AUTO_START'; -- WMI event consumers SELECT name, command_line_template FROM wmi_cli_event_consumers;
Review results for:
Investigating suspicious network activity:
sql-- Active network connections with process details SELECT p.name, p.pid, p.path, p.cmdline, ps.remote_address, ps.remote_port, ps.state FROM processes p JOIN process_open_sockets ps ON p.pid = ps.pid WHERE ps.remote_address NOT IN ('127.0.0.1', '::1', '0.0.0.0') ORDER BY ps.remote_port; -- Listening ports mapped to processes SELECT DISTINCT p.name, lp.port, lp.address, lp.protocol, p.path, p.cmdline FROM listening_ports lp LEFT JOIN processes p ON lp.pid = p.pid WHERE lp.address NOT IN ('127.0.0.1', '::1') ORDER BY lp.port; -- DNS lookups (requires events table or process monitoring) SELECT name, domains, pid FROM dns_resolvers;
Investigation checklist:
Analyzing file modifications and suspicious files:
sql-- Recently modified files in sensitive locations SELECT path, filename, size, mtime, ctime, md5, sha256 FROM hash WHERE path LIKE '/etc/%' OR path LIKE '/tmp/%' OR path LIKE 'C:\Windows\Temp\%' AND mtime > (strftime('%s', 'now') - 86400); -- Last 24 hours -- Executable files in unusual locations SELECT path, filename, size, md5, sha256 FROM hash WHERE (path LIKE '/tmp/%' OR path LIKE '/var/tmp/%' OR path LIKE 'C:\Users\%\AppData\%') AND (filename LIKE '%.exe' OR filename LIKE '%.sh' OR filename LIKE '%.py'); -- SUID/SGID binaries (Linux/macOS) - potential privilege escalation SELECT path, filename, mode, uid, gid FROM file WHERE (mode LIKE '%4%' OR mode LIKE '%2%') AND path LIKE '/usr/%' OR path LIKE '/bin/%';
File analysis workflow:
Standard process investigation queries:
sql-- Processes with network connections SELECT p.pid, p.name, p.path, p.cmdline, ps.remote_address, ps.remote_port FROM processes p JOIN process_open_sockets ps ON p.pid = ps.pid; -- Process tree (parent-child relationships) SELECT p1.pid, p1.name AS process, p1.cmdline, p2.pid AS parent_pid, p2.name AS parent_name, p2.cmdline AS parent_cmdline FROM processes p1 LEFT JOIN processes p2 ON p1.parent = p2.pid; -- High-privilege processes (UID 0 / SYSTEM) SELECT pid, name, path, cmdline, uid, euid FROM processes WHERE uid = 0 OR euid = 0;
Track user accounts and authentication:
sql-- Currently logged in users SELECT user, tty, host, time, pid FROM logged_in_users; -- User accounts with login shells SELECT username, uid, gid, shell, directory FROM users WHERE shell NOT LIKE '%nologin%'; -- Recent authentication events (requires auditd/Windows Event Log integration) SELECT * FROM user_events WHERE time > (strftime('%s', 'now') - 3600); -- Sudo usage history (Linux/macOS) SELECT username, command, time FROM sudo_usage_history ORDER BY time DESC LIMIT 50;
Identify configuration changes:
sql-- Kernel configuration and parameters (Linux) SELECT name, value FROM kernel_info; SELECT path, key, value FROM sysctl WHERE key LIKE 'kernel.%'; -- Installed packages (detect unauthorized software) SELECT name, version, install_time FROM deb_packages ORDER BY install_time DESC LIMIT 20; -- Debian/Ubuntu SELECT name, version, install_time FROM rpm_packages ORDER BY install_time DESC LIMIT 20; -- RHEL/CentOS -- System information SELECT hostname, computer_name, local_hostname FROM system_info;
osqueryd --audit flag for detailed logging.curl, yara) in osqueryd configurations unless explicitly needed.scripts/osquery_triage.sh - Automated triage collection script for rapid incident responsescripts/osquery_hunt.py - Threat hunting query executor with MITRE ATT&CK mappingscripts/parse_osquery_json.py - Parse and analyze osquery JSON outputscripts/osquery_to_timeline.py - Generate forensic timelines from osquery resultsreferences/table-guide.md - Comprehensive osquery table reference for forensic investigationsreferences/mitre-attack-queries.md - Pre-built queries mapped to MITRE ATT&CK techniquesreferences/platform-differences.md - Platform-specific tables and query variations (Linux/macOS/Windows)references/osqueryd-deployment.md - Deploy osqueryd for continuous monitoring and fleet managementassets/osquery.conf - Production osqueryd configuration template for security monitoringassets/forensic-packs/ - Query packs for incident response scenariosir-triage.conf - Initial triage queriespersistence-hunt.conf - Persistence mechanism detectionlateral-movement.conf - Lateral movement indicatorscredential-access.conf - Credential dumping detectionDetect webshells on compromised web servers:
sql-- Check web server processes with suspicious child processes SELECT p1.name AS webserver, p1.pid, p1.cmdline, p2.name AS child, p2.cmdline AS child_cmdline FROM processes p1 JOIN processes p2 ON p1.pid = p2.parent WHERE p1.name IN ('httpd', 'nginx', 'apache2', 'w3wp.exe') AND p2.name IN ('bash', 'sh', 'cmd.exe', 'powershell.exe', 'perl', 'python'); -- Files in web directories with recent modifications SELECT path, filename, mtime, md5, sha256 FROM hash WHERE path LIKE '/var/www/%' OR path LIKE 'C:\inetpub\wwwroot\%' AND (filename LIKE '%.php' OR filename LIKE '%.asp' OR filename LIKE '%.jsp') AND mtime > (strftime('%s', 'now') - 604800); -- Last 7 days
Identify ransomware indicators:
sql-- Processes writing to many files rapidly (potential encryption activity) SELECT p.name, p.pid, p.cmdline, COUNT(fe.path) AS files_modified FROM processes p JOIN file_events fe ON p.pid = fe.pid WHERE fe.action = 'WRITE' AND fe.time > (strftime('%s', 'now') - 300) GROUP BY p.pid HAVING files_modified > 100; -- Look for ransom note files SELECT path, filename FROM file WHERE filename LIKE '%DECRYPT%' OR filename LIKE '%README%' OR filename LIKE '%RANSOM%'; -- Check for file extension changes (encrypted files) SELECT path, filename FROM file WHERE filename LIKE '%.locked' OR filename LIKE '%.encrypted' OR filename LIKE '%.crypto';
Detect privilege escalation attempts:
sql-- Processes running as root from non-standard paths SELECT pid, name, path, cmdline, uid, euid FROM processes WHERE (uid = 0 OR euid = 0) AND path NOT LIKE '/usr/%' AND path NOT LIKE '/sbin/%' AND path NOT LIKE '/bin/%' AND path NOT LIKE 'C:\Windows\%'; -- SUID binaries (Linux/macOS) SELECT path, filename, uid, gid FROM file WHERE mode LIKE '%4%' AND path NOT IN (SELECT path FROM known_suid_binaries); -- Sudoers file modifications SELECT * FROM file WHERE path = '/etc/sudoers' AND mtime > (strftime('%s', 'now') - 86400);
Forward osqueryd logs to SIEM platforms:
Configure osqueryd result logging:
json{ "options": { "logger_plugin": "filesystem", "logger_path": "/var/log/osquery", "disable_logging": false } }
Combine with endpoint detection:
Enrich findings with threat intel:
Solution: Verify table availability and platform compatibility
osqueryi ".schema processes"osqueryi ".tables"Solution: Optimize query performance and scheduling
SELECT * FROM osquery_info; SELECT * FROM osquery_schedule;Solution: Ensure proper privilege escalation
sudo osqueryi--json or --csv flags)osquery enables detection and investigation of techniques across the ATT&CK matrix:
See references/mitre-attack-queries.md for technique-specific detection queries.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-17 | pass→pass | 3,968 | 2,846 | -28% | 1 | 1 | 0% | 686 | 5,155 | +651% | 0 | 0 | — |
case-01 | pass→pass | 7,995 | 6,888 | -14% | 1 | 1 | 0% | 1,330 | 5,875 | +342% | 0 | 0 | — |
case-02 | pass→pass | 5,989 | 6,267 | +5% | 1 | 1 | 0% | 1,116 | 6,032 | +441% | 0 | 0 | — |
case-03 | pass→pass | 6,166 | 4,261 | -31% | 1 | 1 | 0% | 1,286 | 5,513 | +329% | 0 | 0 | — |
case-04 | pass→pass | 9,604 | 10,860 | +13% | 1 | 1 | 0% | 1,889 | 6,904 | +265% | 0 | 0 | — |
case-05 | pass→pass | 12,023 | 6,498 | -46% | 1 | 1 | 0% | 2,192 | 5,946 | +171% | 0 | 0 | — |
case-06 | pass→pass | 12,916 | 9,907 | -23% | 1 | 1 | 0% | 2,560 | 6,898 | +169% | 0 | 0 | — |
case-07 | fail→pass | 15,765 | 9,339 | -41% | 1 | 1 | 0% | 3,242 | 6,566 | +103% | 0 | 0 | — |
case-08 | pass→pass | 17,634 | 10,088 | -43% | 1 | 1 | 0% | 3,546 | 6,635 | +87% | 0 | 0 | — |
case-09 | pass→pass | 8,134 | 6,209 | -24% | 1 | 1 | 0% | 1,590 | 5,952 | +274% | 0 | 0 | — |
case-10 | pass→pass | 8,603 | 8,129 | -6% | 1 | 1 | 0% | 1,750 | 6,333 | +262% | 0 | 0 | — |
case-11 | fail→pass | 15,299 | 8,052 | -47% | 1 | 1 | 0% | 3,107 | 6,159 | +98% | 0 | 0 | — |
case-12 | pass→pass | 6,543 | 5,175 | -21% | 1 | 1 | 0% | 1,281 | 5,420 | +323% | 0 | 0 | — |
case-13 | fail→pass | 13,300 | 3,648 | -73% | 1 | 1 | 0% | 1,591 | 5,367 | +237% | 0 | 0 | — |
case-14 | pass→pass | 4,975 | 6,722 | +35% | 1 | 1 | 0% | 995 | 5,962 | +499% | 0 | 0 | — |
case-15 | pass→pass | 4,378 | 6,015 | +37% | 1 | 1 | 0% | 751 | 5,753 | +666% | 0 | 0 | — |
case-16 | pass→pass | 6,353 | 5,054 | -20% | 1 | 1 | 0% | 1,256 | 5,606 | +346% | 0 | 0 | — |
case-18 | pass→pass | 6,699 | 6,226 | -7% | 1 | 1 | 0% | 1,132 | 5,792 | +412% | 0 | 0 | — |
case-19 | pass→pass | 4,321 | 2,983 | -31% | 1 | 1 | 0% | 671 | 5,176 | +671% | 0 | 0 | — |
case-20 | pass→pass | 10,472 | 14,342 | +37% | 1 | 1 | 0% | 2,026 | 7,097 | +250% | 0 | 0 | — |
case-21 | pass→pass | 5,090 | 4,639 | -9% | 1 | 1 | 0% | 972 | 5,557 | +472% | 0 | 0 | — |
case-22 | pass→fail | 7,462 | 5,255 | -30% | 1 | 1 | 0% | 1,407 | 5,627 | +300% | 0 | 0 | — |
case-23 | pass→pass | 6,903 | 5,214 | -24% | 1 | 1 | 0% | 1,181 | 5,552 | +370% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.