Non-interactive Shell Upgrade
Description
Identifies when a non-interactive terminal (tty) is being upgraded to a fully interactive shell. Attackers may upgrade a simple reverse shell to a fully interactive tty after obtaining initial access to a host, in order to obtain a more stable connection.
Query · eql
process where event.type == "start" and event.action == "exec" and (
(
process.name == "stty" and
process.args == "raw" and
process.args == "-echo" and
process.args_count >= 3
) or
(
process.name == "script" and
process.args in ("-qc", "-c") and
process.args == "/dev/null" and
process.args_count == 4
)
) and
not (
process.parent.command_line like ("linode-longview", "*bootstrap*", "*homebrew*", "*/home/*/.claude/shell-snapshots/snapshot*") or
process.parent.executable in ("/usr/bin/expect", "/usr/bin/nsh-single-command", "/usr/bin/runc") or
process.command_line == "stty -echo raw min 0 time 2" or
process.args like ("/dev/tty*", "/dev/serial/*") or
process.parent.args == "/usr/share/emacs/site-lisp/emacspeak/servers/dtk-exp"
)