text code block:from logs-endpoint.events.network-* | keep @timestamp, host.os.type, event.type, event.action, process.executable, destination.ip, agent.id, host.name | where @timestamp > now() - 1 hours and host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and not ( process.executable in ("/usr/local/bin/prometheus", "/app/extra/chrome") or process.executable like "/usr/local/prometheus/*/prometheus" or process.executable like "/usr/share/elastic-agent/*" or process.executable like "/var/lib/docker/overlay*connectord" or process.executable like "/opt/rumble/bin/rumble-agent*" or process.executable like "/opt/gitlab/*" or process.executable like "/opt/google/chrome/chrome*" ) | stats Esql.event_count = count(), Esql.destination_ip_count_distinct = count_distinct(destination.ip), Esql.agent_id_count_distinct = count_distinct(agent.id), Esql.host_name_values = values(host.name), Esql.agent_id_values = values(agent.id) by process.executable | where Esql.agent_id_count_distinct == 1 and Esql.destination_ip_count_distinct > 250 | sort Esql.event_count asc | limit 100
Install detection rules in Elastic Security
Detect Potential Subnet Scanning Activity from Compromised Host in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).