// Odin by Brandefense - Monograph 57 (Operation SapperSync) // Hunts hidden container persistence scripts, ImageMagick MSL coder invocations, local-upload skill writes, and selected process connections to TCP 9099. let Lookback = 7d; let ApprovedBuildHosts = dynamic(["app-ci-01.corp.example", "img-worker-01.corp.example"]); let ContainerAndMslProcess = DeviceProcessEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedBuildHosts)) | where ( ProcessCommandLine has_any ("/usr/local/bin/runtime-entrypoint", "/usr/local/bin/.agent_sync", "/etc/periodic/15min/.runtime-sync") or (FileName in~ ("magick", "convert", "identify") and (ProcessCommandLine has ".msl" or ProcessCommandLine has "msl:")) or (FileName in~ ("unzip", "python", "python3", "tar") and ProcessCommandLine has_any ("SKILL.md", "demo-skill.zip") and ProcessCommandLine has "_meta.json") ) | project Timestamp, DeviceName, AccountName, SignalType = "ContainerSyncOrMslProcess", Detail = ProcessCommandLine; let ContainerAndSkillFiles = DeviceFileEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedBuildHosts)) | where ( FolderPath in ("/usr/local/bin", "/etc/periodic/15min", "/opt/runtime") and FileName in ("runtime-entrypoint", ".agent_sync", ".runtime-sync", "VERSION", "CHANNEL") ) or (FileName == "_meta.json" and FolderPath has_any ("/tmp", "/var/www", "/uploads")) | project Timestamp, DeviceName, AccountName = InitiatingProcessAccountName, SignalType = "PersistenceOrSkillFileWrite", Detail = strcat(FolderPath, "/", FileName, " via ", InitiatingProcessFileName); let Port9099ArchiveEgress = DeviceNetworkEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedBuildHosts)) | where RemotePort == 9099 | where InitiatingProcessFileName in~ ("curl", "wget", "python", "python3", "busybox", "sh", "ash") | project Timestamp, DeviceName, AccountName = InitiatingProcessAccountName, SignalType = "Port9099StagingEgress", Detail = strcat(InitiatingProcessFileName, " -> ", RemoteIP, ":", tostring(RemotePort)); union ContainerAndMslProcess, ContainerAndSkillFiles, Port9099ArchiveEgress | summarize FirstSeen = min(Timestamp), LastSeen = max(Timestamp), EventCount = count(), Signals = make_set(SignalType, 6), SampleDetails = make_set(Detail, 5) by DeviceName, AccountName | order by LastSeen desc