// Odin by Brandefense - Monograph 73 // Hunts Linux UID-0 toor account creation, sshd_config AllowUsers edits, Rust bore tunnel processes, and unexpected daemon egress. let Lookback = 7d; let ApprovedAdminAndBastionHosts = dynamic(["linux-bastion-01.corp.example", "sec-audit-01.corp.example"]); let LinuxPrivescSshAndBoreProcessEvents = DeviceProcessEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedAdminAndBastionHosts)) | where ( (FileName in~ ("useradd", "usermod", "chpasswd") and ProcessCommandLine has "toor") or (FileName in~ ("sed", "tee", "awk", "cp", "mv") and ProcessCommandLine has "/etc/ssh/sshd_config" and ProcessCommandLine has_any ("AllowUsers", "PermitRootLogin")) or (FileName =~ "bore" and ProcessCommandLine has "local" and ProcessCommandLine has "--to") or (ProcessCommandLine has_any ("bore.tgz", "pwnkit", "cow_restart", "id_toor", "allowusers.sh", "temizlik")) ) | project Timestamp, DeviceName, AccountName, SignalType = "LinuxSshPersistenceOrBoreProcess", Detail = strcat(FileName, ": ", ProcessCommandLine); let UnexpectedLinuxTunnelPublicEgress = DeviceNetworkEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedAdminAndBastionHosts)) | where RemoteIPType == "Public" | where ( InitiatingProcessFileName =~ "bore" or (InitiatingProcessFileName in~ ("sshd", "php-fpm", "apache2", "nginx") and RemotePort in (80, 443, 7835, 8000)) ) | project Timestamp, DeviceName, AccountName = InitiatingProcessAccountName, SignalType = "UnexpectedLinuxTunnelOrDaemonEgress", Detail = strcat(InitiatingProcessFileName, " -> ", RemoteIP, ":", tostring(RemotePort)); union LinuxPrivescSshAndBoreProcessEvents, UnexpectedLinuxTunnelPublicEgress | 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