Exploit: misconfigured SUID on vim to gain root. Detect via logs and process list; respond by killing sessions and hardening.
Following the successful SSH compromise in Lab 2, access was upgraded from a BSD shell to a Meterpreter session. The user lacks root privileges, so the next step is privilege escalation. For this lab, the vim binary is intentionally misconfigured with the SUID bit to demonstrate a common escalation path.
The SUID (Set User ID) permission causes an executable to run with the file owner’s privileges, not the caller’s. It appears as an s in the owner’s execute position in ls -l output.
-rwsr-xr-x 1 root root 12345 Dec 27 12:00 example_program
When a non-root user runs example_program, it executes with root privileges. Misconfiguring SUID on powerful binaries (like editors or shells) can enable trivial escalation.
From Meterpreter, spawn an interactive shell:
/bin/sh -i
Initially, vim behaved oddly inside this pseudo-tty (missing editor commands). Inspecting environment variables revealed the TERM variable was unset.
TERM not set.
export TERM=xterm.With SUID on vim, invoking a shell from inside the editor yields a root shell:
vim
:!sh
:!sh spawns a privileged shell.
Review authentication and command logs to confirm abuse of vim to spawn a shell:
vim usage launching /bin/sh.Correlate with process listings to confirm interactive shells and ownership changes:
ronny to root.Terminate malicious sessions and clean up. Kill processes tied to the compromised user and any suspicious root shells:
On the attacker side, access is lost:
This lab demonstrates how a misconfigured SUID binary and an improperly configured environment (TERM) can be combined to achieve root. While production systems rarely ship with SUID on editors, legacy systems and ad-hoc admin changes can introduce these flaws. The workflow mirrors real assessments: identify SUID candidates, fix environment/pty issues, and pivot to a root shell.