[Osquery_manager] Startup Items artifact saved query #16078
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Startup Items Persistence Detection (Cross-Platform)
Advanced cross-platform queries for detecting malicious persistence mechanisms through startup items, autostart entries, and launch configurations. Implements a dual-detection approach combining signature-based filtering with Living off the Land (LotL) attack pattern recognition across Windows, macOS, and Linux systems.
Read https://p.elstc.co/paste/Bl5p6ffG#Ef0urSr4IAmt7C-qNrfaN1CHyYq0Ewxh2JIBn6cwAVx
Core Forensic Artifacts Coverage
Queries by Platform
🪟 Windows - Startup Items (Dual-Detection)
Description
Advanced dual-detection query combining signature-based filtering with Living off the Land (LotL) attack pattern recognition. Detects both non-whitelisted legitimate binaries AND abuse of legitimate Windows tools for malicious persistence. Filters out high-volume known-good tasks while flagging suspicious patterns regardless of code signature status.
Detection Focus:
-e,-enc,-EncodedCommand)MITRE ATT&CK Mapping:
Result
Query returns prioritized results with LotL indicators first, followed by non-whitelisted items. Each result includes detection method, detection reason, executable hashes, code signature information, and file metadata.
Platform
windowsInterval
3600seconds (1 hour)Query ID
startup_items_windows_elasticECS Field Mappings
process.name→nameprocess.executable→pathfile.path→pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.directory→directoryuser.name→usernamerule.category→typeevent.outcome→statusregistry.path→sourcecode_signature.subject_name→subject_namecode_signature.status→signature_resultevent.category→detection_methodrule.description→detection_reasonSQL Query
🐧 Linux - Startup Items (Dual-Detection)
Description
Comprehensive dual-detection query for Linux persistence mechanisms combining user-created configurations with Living off the Land attack pattern recognition. Detects systemd services, cron jobs, and XDG autostart entries while identifying malicious use of bash, curl, base64 decoding, and other legitimate tools. Maintains cross-distribution compatibility using location-based filtering.
Detection Focus:
/etc/systemd/system/@rebootjobs in user crontabs-cflag abusecurl | bash,wget | sh)/dev/shm,/tmp)/dev/tcp/redirection)nohup,disown)MITRE ATT&CK Mapping:
Result
Query returns prioritized results with LotL indicators first, followed by non-whitelisted items. Includes detection method, detection reason, file hashes, ownership, permissions, and timestamps.
Platform
linuxInterval
3600seconds (1 hour)Query ID
startup_items_linux_elasticECS Field Mappings
process.name→nameprocess.executable→pathprocess.command_line→argsfile.path→pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.uid→uidfile.gid→gidfile.mode→modeuser.name→usernameservice.id→service_idrule.category→typeevent.outcome→statusregistry.path→sourceevent.category→detection_methodrule.description→detection_reasonSQL Query
🍎 macOS - Startup Items (Dual-Detection)
Description
Advanced dual-detection query for macOS persistence mechanisms combining signature validation with Living off the Land attack pattern recognition. Detects LaunchAgents, LaunchDaemons, and legacy startup/login items while identifying malicious use of bash, curl, osascript, and other legitimate macOS tools. Filters out Apple-signed system components while flagging suspicious patterns regardless of code signature status.
Note: macOS 10.13+ login items stored in
backgrounditems.btmbinary format may not be fully captured by the osquerystartup_itemstable.Detection Focus:
-cflag abuseosascript -e)-cor-e)/tmp,/private/tmp)/dev/tcp/redirection)MITRE ATT&CK Mapping:
Result
Query returns prioritized results with LotL indicators first, then unsigned/non-Apple signed items. Includes detection method, detection reason, code signature status, file hashes, ownership, permissions, and timestamps.
Platform
darwinInterval
3600seconds (1 hour)Query ID
startup_items_darwin_elasticECS Field Mappings
process.name→nameprocess.executable→pathfile.path→pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.uid→uidfile.gid→gidfile.mode→modeuser.name→usernamerule.category→typeevent.outcome→statuscode_signature.signed→signedcode_signature.subject_name→identifierregistry.path→sourceevent.category→detection_methodrule.description→detection_reasonSQL Query
Detection Value Proposition
Why These Queries Matter:
Persistence is a Critical Detection Point: Adversaries must establish persistence to maintain access. These queries detect the most common persistence mechanisms across all major platforms.
Dual-Detection Approach: Combines two complementary detection strategies:
Cross-Platform Coverage: Unified detection approach across Windows, macOS, and Linux enables consistent threat hunting workflows.
Actionable Context: Each detection includes the specific reason (e.g., "PowerShell base64 encoded command", "Download and pipe to shell"), enabling rapid analyst triage.
MITRE ATT&CK Alignment: Direct mapping to persistence techniques enables threat-informed defense and ATT&CK Navigator integration.
References
This PR was AI assisted with Claude Code