2022-09-22 09:18:03 +00:00
|
|
|
SELECT s.family,
|
|
|
|
protocol,
|
|
|
|
s.local_port,
|
|
|
|
s.remote_port,
|
|
|
|
s.local_address,
|
|
|
|
s.remote_address,
|
|
|
|
p.name,
|
|
|
|
p.path,
|
|
|
|
p.cmdline AS child_cmd,
|
|
|
|
p.cwd,
|
|
|
|
s.pid,
|
|
|
|
s.net_namespace,
|
|
|
|
p.parent AS parent_pid,
|
|
|
|
pp.cmdline AS parent_cmd,
|
|
|
|
hash.sha256,
|
|
|
|
CONCAT(
|
|
|
|
MIN(s.remote_port, 32768),
|
|
|
|
",",
|
|
|
|
protocol,
|
|
|
|
",",
|
|
|
|
MIN(p.uid, 500),
|
|
|
|
",",
|
|
|
|
p.name
|
|
|
|
) AS exception_key
|
2022-09-20 21:46:47 +00:00
|
|
|
FROM process_open_sockets s
|
2022-09-22 09:18:03 +00:00
|
|
|
LEFT JOIN processes p ON s.pid = p.pid
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
2022-09-20 21:46:47 +00:00
|
|
|
WHERE protocol > 0
|
2022-09-22 09:18:03 +00:00
|
|
|
AND s.remote_port > 0
|
|
|
|
AND s.remote_address NOT IN ('127.0.0.1', '::ffff:127.0.0.1', '::1')
|
|
|
|
AND s.remote_address NOT LIKE 'fe80:%'
|
|
|
|
AND s.remote_address NOT LIKE '127.%'
|
|
|
|
AND s.remote_address NOT LIKE '192.168.%'
|
|
|
|
AND s.remote_address NOT LIKE '172.1%'
|
|
|
|
AND s.remote_address NOT LIKE '172.2%'
|
|
|
|
AND s.remote_address NOT LIKE '172.30.%'
|
|
|
|
AND s.remote_address NOT LIKE '172.31.%'
|
|
|
|
AND s.remote_address NOT LIKE '::ffff:172.%'
|
|
|
|
AND s.remote_address NOT LIKE '10.%'
|
|
|
|
AND s.remote_address NOT LIKE '::ffff:10.%'
|
|
|
|
AND s.remote_address NOT LIKE 'fc00:%'
|
|
|
|
AND s.state != 'LISTEN'
|
|
|
|
-- DNS clients
|
|
|
|
AND NOT (
|
|
|
|
remote_port = 53
|
|
|
|
AND protocol IN (6, 17)
|
|
|
|
AND p.name IN (
|
|
|
|
'1password',
|
|
|
|
'apt',
|
|
|
|
'apt-get',
|
|
|
|
'Brackets',
|
|
|
|
'chainctl',
|
|
|
|
'chrome',
|
|
|
|
'chronyd',
|
|
|
|
'cloud_sql_proxy',
|
|
|
|
'code',
|
|
|
|
'containerd',
|
|
|
|
'controlplane',
|
|
|
|
'crc',
|
|
|
|
'curl',
|
|
|
|
'dig',
|
|
|
|
'dnf',
|
|
|
|
'electron',
|
|
|
|
'firefox',
|
|
|
|
'.firefox-wrappe',
|
|
|
|
'flameshot',
|
|
|
|
'gh',
|
|
|
|
'git-remote-http',
|
|
|
|
'gitsign',
|
|
|
|
'gnome-software',
|
|
|
|
'go',
|
|
|
|
'grafana-server',
|
|
|
|
'grype',
|
|
|
|
'host',
|
|
|
|
'htop',
|
|
|
|
'istioctl',
|
|
|
|
'jcef_helper',
|
|
|
|
'k6',
|
|
|
|
'k9s',
|
|
|
|
'ko',
|
|
|
|
'kolide-pipeline',
|
|
|
|
'launcher',
|
|
|
|
'NetworkManager',
|
|
|
|
'ngrok',
|
|
|
|
'nix',
|
|
|
|
'node',
|
|
|
|
'nscd',
|
|
|
|
'obs',
|
|
|
|
'obs-browser-page',
|
|
|
|
'obs-ffmpeg-mux',
|
|
|
|
'obsidian',
|
|
|
|
'opera',
|
|
|
|
'pacman',
|
|
|
|
'ping',
|
|
|
|
'podman',
|
|
|
|
'prometheus',
|
|
|
|
'rootlessport',
|
|
|
|
'signal-desktop',
|
|
|
|
'slack',
|
|
|
|
'slirp4netns',
|
|
|
|
'snapd',
|
|
|
|
'snap-store',
|
|
|
|
'Socket Process',
|
|
|
|
'spotify',
|
|
|
|
'ssh',
|
|
|
|
'steam',
|
|
|
|
'steamwebhelper',
|
|
|
|
'syncthing',
|
|
|
|
'systemd-resolve',
|
|
|
|
'tailscaled',
|
|
|
|
'.tailscaled-wra',
|
|
|
|
'terraform',
|
|
|
|
'terraform-provi',
|
|
|
|
'tkn',
|
|
|
|
'traceroute',
|
|
|
|
'vcluster',
|
|
|
|
'wget',
|
|
|
|
'whois',
|
|
|
|
'xmobar',
|
|
|
|
'yay',
|
|
|
|
'zoom'
|
|
|
|
)
|
2022-09-21 11:42:51 +00:00
|
|
|
)
|
2022-09-22 09:18:03 +00:00
|
|
|
|
|
|
|
-- General exceptions
|
|
|
|
AND NOT exception_key IN (
|
2022-09-21 11:42:51 +00:00
|
|
|
'123,17,500,chronyd',
|
|
|
|
'22067,6,500,syncthing',
|
2022-09-21 17:34:10 +00:00
|
|
|
'22,6,500,ssh',
|
2022-09-22 09:18:03 +00:00
|
|
|
'22,6,,',
|
|
|
|
-- shortlived SSH (git push)
|
2022-09-21 01:56:01 +00:00
|
|
|
'27024,6,500,steam',
|
2022-09-22 09:18:03 +00:00
|
|
|
'3100,6,500,firefox',
|
2022-09-20 21:46:47 +00:00
|
|
|
'3307,6,500,cloud_sql_proxy',
|
|
|
|
'4070,6,500,spotify',
|
|
|
|
'443,17,500,chrome',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,17,500,jcef_helper',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,17,500,spotify',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,0,dnf',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,0,launcher',
|
|
|
|
'443,6,0,pacman',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,0,tailscaled',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,6,0,.tailscaled-wra',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,472,grafana-server',
|
|
|
|
'443,6,500,1password',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,Brackets',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,chainctl',
|
|
|
|
'443,6,500,chrome',
|
|
|
|
'443,6,500,cloud_sql_proxy',
|
|
|
|
'443,6,500,code',
|
|
|
|
'443,6,500,containerd',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,500,controlplane',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,crc',
|
|
|
|
'443,6,500,electron',
|
|
|
|
'443,6,500,firefox',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,6,500,.firefox-wrappe',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,flameshot',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,gh',
|
|
|
|
'443,6,500,git-remote-http',
|
|
|
|
'443,6,500,gitsign',
|
|
|
|
'443,6,500,gnome-software',
|
|
|
|
'443,6,500,go',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,grafana-server',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,grype',
|
|
|
|
'443,6,500,htop',
|
|
|
|
'443,6,500,istioctl',
|
|
|
|
'443,6,500,k6',
|
|
|
|
'443,6,500,k9s',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,wget',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,ko',
|
|
|
|
'443,6,500,kolide-pipeline',
|
|
|
|
'443,6,500,ngrok',
|
|
|
|
'443,6,500,nix',
|
|
|
|
'443,6,500,node',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,6,500,obs',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,obs-browser-page',
|
|
|
|
'443,6,500,obs-ffmpeg-mux',
|
|
|
|
'443,6,500,obsidian',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,500,signal-desktop',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,slack',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,slirp4netns',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,snap-store',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,6,500,Socket Process',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,spotify',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,podman',
|
2022-09-21 01:56:01 +00:00
|
|
|
'443,6,500,steamwebhelper',
|
2022-09-21 11:42:51 +00:00
|
|
|
'443,6,500,terraform',
|
2022-09-21 17:34:10 +00:00
|
|
|
'443,6,500,terraform-provi',
|
2022-09-20 21:46:47 +00:00
|
|
|
'443,6,500,tkn',
|
|
|
|
'443,6,500,vcluster',
|
|
|
|
'443,6,500,xmobar',
|
|
|
|
'443,6,500,yay',
|
|
|
|
'443,6,500,zoom',
|
|
|
|
'5228,6,500,chrome',
|
2022-09-22 09:18:03 +00:00
|
|
|
'8006,6,500,chrome',
|
2022-09-21 01:56:01 +00:00
|
|
|
'80,6,0,dnf',
|
2022-09-22 09:18:03 +00:00
|
|
|
'6000,6,500,ssh',
|
|
|
|
'443,6,0,influxd',
|
|
|
|
'443,6,0,dockerd',
|
2022-09-21 01:56:01 +00:00
|
|
|
'80,6,0,NetworkManager',
|
2022-09-21 17:34:10 +00:00
|
|
|
'80,6,0,tailscaled',
|
|
|
|
'80,6,0,.tailscaled-wra',
|
2022-09-22 09:18:03 +00:00
|
|
|
'80,6,500,curl',
|
|
|
|
'443,6,500,celery',
|
|
|
|
'443,6,500,gunicorn',
|
2022-09-20 21:46:47 +00:00
|
|
|
'80,6,500,firefox',
|
2022-09-22 09:18:03 +00:00
|
|
|
'443,6,500,Discord',
|
|
|
|
'443,6,500,authentik-proxy',
|
2022-09-21 17:34:10 +00:00
|
|
|
'80,6,500,.firefox-wrappe',
|
2022-09-21 01:56:01 +00:00
|
|
|
'80,6,500,steam',
|
2022-09-21 11:42:51 +00:00
|
|
|
'80,6,500,steamwebhelper',
|
2022-09-22 09:18:03 +00:00
|
|
|
'80,6,500,syncthing',
|
|
|
|
'8801,17,500,zoom',
|
|
|
|
'9090,6,500,k6',
|
|
|
|
'9090,6,500,firefox',
|
|
|
|
'9090,6,500,prometheus',
|
|
|
|
'3100,6,500,k6',
|
|
|
|
'443,6,0,snapd',
|
|
|
|
'9090,6,500,rootlessport'
|
|
|
|
)
|
2022-09-21 11:42:51 +00:00
|
|
|
|
2022-09-22 09:18:03 +00:00
|
|
|
-- Other more complicated situations
|
|
|
|
AND NOT (
|
|
|
|
p.name = 'rootlessport'
|
|
|
|
AND remote_port > 1024
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
p.name = 'syncthing'
|
|
|
|
AND (
|
|
|
|
remote_port IN (53, 80, 88, 110, 443, 587, 993, 3306, 7451)
|
|
|
|
OR remote_port > 8000
|
|
|
|
)
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
p.name IN (
|
|
|
|
'chrome',
|
|
|
|
'Google Chrome Helper',
|
|
|
|
'Brave Browser Helper',
|
|
|
|
'Chromium Helper',
|
|
|
|
'Opera Helper'
|
|
|
|
)
|
|
|
|
AND remote_port IN (
|
|
|
|
53,
|
|
|
|
3100,
|
|
|
|
443,
|
|
|
|
80,
|
|
|
|
8006,
|
|
|
|
9000,
|
|
|
|
5004,
|
|
|
|
8009,
|
|
|
|
8080,
|
|
|
|
8888,
|
|
|
|
8443,
|
|
|
|
5228,
|
|
|
|
32211,
|
|
|
|
53,
|
|
|
|
10001,
|
|
|
|
3478,
|
|
|
|
19305,
|
|
|
|
19306,
|
|
|
|
19307,
|
|
|
|
19308,
|
|
|
|
19309
|
|
|
|
)
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
p.name IN ('thunderbird')
|
|
|
|
AND remote_port IN (53, 143, 443, 587, 465, 585, 993)
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
p.name IN ('spotify', 'Spotify Helper', 'Spotify')
|
|
|
|
AND remote_port IN (53, 443, 8009, 4070, 32211)
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
remote_port IN (443, 53)
|
|
|
|
AND p.name LIKE 'terraform-provider-%'
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
remote_port iN (443, 53)
|
|
|
|
AND p.name LIKE 'kubectl.%'
|
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
p.cmdline LIKE '%google-cloud-sdk/lib/gcloud.py%'
|
|
|
|
AND remote_port IN (80, 53, 443)
|
|
|
|
)
|
2022-09-20 21:46:47 +00:00
|
|
|
GROUP BY s.pid
|