// Odin by Brandefense - Monograph 58 (Operation FalsePort) // Hunts Java processes initiating unapproved external TCP 3306 MySQL sessions and CLI invocations with risky JDBC properties or rogue listener tools. let Lookback = 7d; let ApprovedAutomationHosts = dynamic(["app-ci-01.corp.example", "db-etl-01.corp.example"]); let ApprovedExternalDatabaseIPs = dynamic(["198.51.100.10", "198.51.100.11"]); let SuspiciousJdbcOrListenerProcess = DeviceProcessEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedAutomationHosts)) | where ( ProcessCommandLine has_any ("allowLoadLocalInfile=true", "autoDeserialize=true", "queryInterceptors=", "socketFactory=", "authenticationPluginClassName=") or ProcessCommandLine has_any ("JNDIExploit", "MySQL_Fake_Server", "java-chains", "fakemysql") ) | project Timestamp, DeviceName, AccountName, SignalType = "RiskyJdbcOrListenerCLI", Detail = ProcessCommandLine; let UnapprovedJavaMySqlEgress = DeviceNetworkEvents | where Timestamp >= ago(Lookback) | where not(DeviceName in~ (ApprovedAutomationHosts)) | where InitiatingProcessFileName in~ ("java", "java.exe") | where RemoteIPType == "Public" and RemotePort == 3306 | where not(RemoteIP in (ApprovedExternalDatabaseIPs)) | project Timestamp, DeviceName, AccountName = InitiatingProcessAccountName, SignalType = "UnapprovedJavaPublic3306Egress", Detail = strcat(InitiatingProcessFileName, " -> ", RemoteIP, ":", tostring(RemotePort)); union SuspiciousJdbcOrListenerProcess, UnapprovedJavaMySqlEgress | 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