Skip to content

Instantly share code, notes, and snippets.

@tstromberg
Created October 10, 2022 21:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tstromberg/e31349d33f5e17c0b8fe35e240edbde6 to your computer and use it in GitHub Desktop.
Save tstromberg/e31349d33f5e17c0b8fe35e240edbde6 to your computer and use it in GitHub Desktop.
-- Find ssh sessions that are hiding from 'w'/'who'
SELECT * FROM (
SELECT p.pid,p.name,p.cmdline,GROUP_CONCAT(DISTINCT pof.path) AS open_files
FROM processes p
LEFT JOIN process_open_files pof ON p.pid = pof.pid
WHERE p.name = "sshd"
GROUP BY p.pid
)
WHERE cmdline LIKE "%@notty%"
OR
INSTR(open_files, "/dev/ptmx") = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment