Root Access and Credential Exfiltration

Post-exploitation from Meterpreter to full root control and /etc/shadow dump on Metasploitable2

Summary

This stage continues directly from the Meterpreter session established in the Java RMI attack. The session was already running as root, meaning no additional privilege escalation was required — a direct violation of the principle of least privilege. From Meterpreter, the attack dropped into a native bash shell, confirmed uid=0(root), and exfiltrated /etc/shadow, which contained MD5-hashed passwords for 30+ system accounts. At this point the system was fully compromised: all data, all users, and all services are under attacker control.

Attack Technique Used

The technique is post-exploitation using Meterpreter. After confirming the session context with getuid, the attacker used the shell command to obtain an interactive system shell on Metasploitable. From that shell, standard Linux utilities were used to confirm privileges and exfiltrate sensitive credential data. The key actions were reading /etc/shadow to obtain password hashes for offline cracking and collecting basic system information (uname -a) to understand kernel age and exploitability.

Steps to Reproduce

Starting point: An active Meterpreter session from the Java RMI exploit (Attack 3).

meterpreter > getuid
Server username: root

meterpreter > shell
$ id
uid=0(root) gid=0(root) groups=0(root)
$ whoami
root
$ cat /etc/shadow
$ uname -a

Complete findings:

Detection (Wazuh)

On a modern, supported Linux distribution with a Wazuh agent installed, access to /etc/shadow is a high-severity event. Wazuh's file integrity monitoring (FIM) capability monitors sensitive files like /etc/shadow by default and would generate a critical alert when the file is read or modified. In this lab, Metasploitable's age (Ubuntu 8.04 from 2008) prevented agent deployment, but in a real environment an agent would log both the file access and any suspicious processes spawned from Meterpreter. Network monitoring would also observe the exfiltration of the shadow file contents leaving the system over the Meterpreter channel.

Remediation

MITRE ATT&CK Mapping

T1003.008 OS Credential Dumping: /etc/passwd and /etc/shadow, T1078 Valid Accounts, TA0006 Credential Access, TA0009 Collection, T1005 Data from Local System.

Screenshots with captions

Meterpreter root shell on Metasploitable2 showing uid=0(root), /etc/shadow dump, and Linux 2.6.24 kernel from 2008
Root shell confirmed — uid=0(root), full /etc/shadow dump showing MD5 hashed passwords for all 30+ system accounts, Linux kernel 2.6.24 from 2008.