{"id":2994,"date":"2025-04-07T22:02:49","date_gmt":"2025-04-07T22:02:49","guid":{"rendered":"https:\/\/www.hackmosphere.fr\/bypass-windows-defender-antivirus-in-2025-evasion-techniques-using-direct-syscalls-and-xor-encryption-part-2\/"},"modified":"2026-06-20T15:45:47","modified_gmt":"2026-06-20T15:45:47","slug":"bypass-windows-defender-antivirus-in-2025-evasion-techniques-using-direct-syscalls-and-xor-encryption-part-2","status":"publish","type":"post","link":"https:\/\/www.hackmosphere.fr\/en\/bypass-windows-defender-antivirus-in-2025-evasion-techniques-using-direct-syscalls-and-xor-encryption-part-2\/","title":{"rendered":"Bypassing Windows Defender Antivirus in 2026: Evasion Techniques Using Direct System Calls and XOR Encryption \u2013 Part 2"},"content":{"rendered":"\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\"><strong>Reading Time<\/strong>: 10 minutes<br\/><strong>Technical Level<\/strong>: Advanced<\/p>\n\n<p class=\"wp-block-paragraph\"><strong>Update: <\/strong> This post was last updated in June 2026.<br\/><\/p>\n\n<p class=\"wp-block-paragraph\">This is the second and final article on Defender evasion in 2026. In the first article (available <strong><a href=\"https:\/\/www.hackmosphere.fr\/en\/bypassing-windows-defender-antivirus-in-2025-evasion-techniques-using-direct-syscalls-and-xor-encryption-part-1\/\" target=\"_blank\" rel=\"noopener\">here<\/a><\/strong>), we covered the basics needed to understand the Windows execution flow, what antivirus software is, and how it works. <\/p>\n\n<p class=\"wp-block-paragraph\">We also explained how to set up a lab so you can practice with complete peace of mind. Finally, we provided basic C++ code to execute shellcode generated using msfvenom. Obviously, this code was detected immediately. <\/p>\n\n<p class=\"wp-block-paragraph\">This second part discusses how to implement techniques to bypass static &amp; dynamic Windows Defender detections.<\/p>\n\n<p class=\"wp-block-paragraph\">All the code we present in this article is accessible here: https: <a href=\"https:\/\/Github.com\/hackmosphere\/DefenderBypass\">\/\/Github.com\/hackmosphere\/DefenderBypass.<\/a> We aim to provide several code examples that should help you understanding the different steps of bypassing AV. <\/p>\n\n<div style=\"height:36px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\"><strong>Disclaimer<\/strong><\/p>\n\n<p class=\"wp-block-paragraph\">This is not a tutorial to make a malware, but a practical case for educational purpose only.<\/p>\n\n<p class=\"wp-block-paragraph\">Furthermore, the code will likely stop working as soon as it is made public. It&#8217;s up to you to get it working again by making some (often minor) changes to it (hint: Take a look at threatcheck.exe) \ud83d\ude0a<\/p>\n\n<div style=\"height:44px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h3 class=\"wp-block-heading\">Core Principle reminders<\/h3>\n\n<p class=\"wp-block-paragraph\">Our approach relies on several pillars:<\/p>\n\n<ol class=\"wp-block-list\">\n<li>Setting up the lab<\/li>\n\n\n\n<li>Getting a basic shellcode loader to work<\/li>\n\n\n\n<li>Avoiding static detection<\/li>\n\n\n\n<li>Avoiding dynamic detection by using direct syscalls (through SysWhispers2) and remote process injection<\/li>\n<\/ol>\n\n<div style=\"height:49px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h2 class=\"wp-block-heading\">Bypass Defender&#8217;s static detection<\/h2>\n\n<p class=\"wp-block-paragraph\">Now that the lab is ready and the first injection done, let&#8217;s get started with evasion!<\/p>\n\n<p class=\"wp-block-paragraph\">As mentioned above, we now want to avoid static detection, where Windows Defender looks for well-known patterns. In the code that was given in the first article, the shellcode generated by msfvenom was not encrypted. Windows Defender has therefore detected it directly, since msfvenom contains well-known IOCs (Indicator Of Compromise).  <\/p>\n\n<h3 class=\"wp-block-heading\">XOR encryption to hide shellcode<\/h3>\n\n<p class=\"wp-block-paragraph\">XOR encryption will be used to encrypt our shellcode, making it undetectable. Some people use more advanced encryption methods, such as AES, which works well but isn\u2019t really necessary as long as the shellcode\u2019s original form is completely altered using a unique key.<\/p>\n\n<p class=\"wp-block-paragraph\">In other terms, XOR encryption of the shellcode prevents signature detection and known pattern-based heuristics, allowing the shellcode to remain undetected when on disk (at rest, not being executed). To do this : <\/p>\n\n<ul class=\"wp-block-list\">\n<li>Use again &#8220;<a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/myEncoder3.py\">myEncoder3.py<\/a>&#8221; from the Github<ul><li>First, the raw shellcode is displayed in hex<\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li>Second, the shellcode is encrypted with key &#8220;ukbf&#8221; and displays it in hex. Of course, we&#8217;ll use this part (note: make sure you use your own key value \ud83d\ude09) <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"635\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-11-1024x635.png\" alt=\"XOR encrypting the shellcode\" class=\"wp-image-2915\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-11-1024x635.png 1024w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-11-980x607.png 980w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-11-480x298.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">Now that we have the XOR encrypted version of our shellcode, in hexadecimal, we need to add it to our code together with some logic to decrypt it at runtime.<\/p>\n\n<p class=\"wp-block-paragraph\"><strong>OPSEC :<\/strong> This means that on disk, the data appears encrypted. It is then decrypted at run time in-memory: Modern EDRs can read memory and detect decrypted payloads. Specific methods must be used against that to encrypt unused data in-memory. For instance, look at &#8220;<a href=\"https:\/\/github.com\/Cracked5pider\/Ekko\">Ekko<\/a>&#8221; to understand this principle. Anyways, for AVs such as Windows Defender, we do not need to implement that \ud83d\ude0a    <\/p>\n\n<div style=\"height:43px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\">The C++ file &#8220;<a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/injectCryptXOR.cpp\">injectCryptXOR.cpp<\/a>&#8220;, compared to &#8220;<a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/injectBasic.cpp\">injectBasic.cpp<\/a>&#8221; adds code to XOR decrypt the given encrypted shellcode. Here are the key steps of our implementation : <\/p>\n\n<figure class=\"wp-block-image size-full\"><img alt=\"\" alt=\"\" loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"389\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-12.png\" alt=\"\" class=\"wp-image-2917\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-12.png 979w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-12-480x191.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 979px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><strong>Code explanation : <\/strong> Compared to the previous code, we added :<\/p>\n\n<ul class=\"wp-block-list\">\n<li>The XOR &#8220;key[]&#8221; variable, which is to be changed at every compilation<\/li>\n\n\n\n<li>A new array &#8220;encryptedShellcode[]&#8221; to receive the encrypted shellcode<\/li>\n\n\n\n<li>The XOR decryption logic<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\"><strong>Run &#8220;SecondExample.exe&#8221; in the exclusion folder <\/strong>:<\/p>\n\n<ol class=\"wp-block-list\">\n<li>In the folder <em>where you have an exclusion, <\/em>this should provide you with a Meterpreter reverse shell in your attacking machine \ud83d\ude0a (don&#8217;t forget to relaunch the listener on your Kali machine, we got to bounce our head to the wall because of this simple mistake&#8230;)<\/li>\n\n\n\n<li>Try dropping it to a folder where no exclusion is in place: you should be fine?<\/li>\n<\/ol>\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"643\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-13.png\" alt=\"Dropping to disk got detected again.\" class=\"wp-image-2919\" style=\"width:450px\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-13.png 623w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-13-480x495.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 623px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">Nooo it still cannot be put on disk!<\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"407\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-14.png\" alt=\"Meme saying we don't wanna make things too easy.\" class=\"wp-image-2921\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-14.png 979w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-14-480x200.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 979px, 100vw\" \/><\/figure>\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h3 class=\"wp-block-heading\">IAT (Import Address Table) &amp; Win32 API monitoring<\/h3>\n\n<h4 class=\"wp-block-heading\">Import Address Table :<\/h4>\n\n<p class=\"wp-block-paragraph\">The Import Address Table (IAT) is a data structure in a binary executable that holds information about the system APIs and functions, that the executable references for dynamic linking.<\/p>\n\n<p class=\"wp-block-paragraph\">Antivirus software often look at it for static detection because it provides crucial insights into how a potentially malicious program interacts with system libraries and other code.<\/p>\n\n<p class=\"wp-block-paragraph\">For instance, the import address table would tell Defender if CreateFile(), ReadFile(), WriteProcessMemory() or VirtualAlloc() are called.<\/p>\n\n<h4 class=\"wp-block-heading\">Win32 API monitoring :<\/h4>\n\n<p class=\"wp-block-paragraph\">As a reminder, Win32 APIs are a set of programming interfaces provided by Microsoft for developing 32-bit Windows applications. Allowing direct interaction with the operating system\u2019s core functionality, such as creating files or processes.<\/p>\n\n<p class=\"wp-block-paragraph\">Win32 API monitoring is the process of tracking and analyzing system-level API calls made by applications running on a Windows operating system, to detect and analyze their behavior.<\/p>\n\n<p class=\"wp-block-paragraph\">Antivirus software may monitor these calls to see which APIs are being called, in real time. This is more of a dynamic detection method than a static one, but we\u2019ve included it here because we\u2019re lazy and are now going to implement a technique that will help us bypass both of these defenses!<\/p>\n\n<p class=\"has-text-align-center wp-block-paragraph\"><br\/><strong>? Do you know what we are thinking about ? <br\/><br\/>! Direct syscalls!<\/strong><\/p>\n\n<div style=\"height:52px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h3 class=\"wp-block-heading\">Direct syscalls<\/h3>\n\n<p class=\"wp-block-paragraph\">Before delving why syscalls bypass both of these detections, let&#8217;s explain what a syscall is.<\/p>\n\n<p class=\"wp-block-paragraph\">In the <a href=\"https:\/\/www.hackmosphere.fr\/en\/bypassing-windows-defender-antivirus-in-2025-evasion-techniques-using-direct-syscalls-and-xor-encryption-part-1\/\" target=\"_blank\" rel=\"noopener\">first article<\/a>, we provided an imaged overview of the Windows execution flow. Let&#8217;s try to provide another point of view of the execution and explain what is a syscalls. <\/p>\n\n<p class=\"wp-block-paragraph\">In the image below, Example.exe is simply creating a process :<\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"421\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-15.png\" alt=\"Syscall explanation\" class=\"wp-image-2923\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-15.png 979w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-15-480x206.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 979px, 100vw\" \/><\/figure>\n\n<div style=\"height:48px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h4 class=\"wp-block-heading\">Bypassing Win32 API monitoring using syscalls<\/h4>\n\n<p class=\"wp-block-paragraph\">Win32 API monitoring relies on tracking high-level API calls (e.g. CreateFile() or VirtualAlloc()). Direct syscalls, however, interact directly with system services (e.g. NtCreateFile() or NtAllocateVirtualMemory()) and bypass these API abstractions entirely. <\/p>\n\n<div style=\"height:54px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h4 class=\"wp-block-heading\">Avoiding IAT monitoring using syscalls<\/h4>\n\n<p class=\"wp-block-paragraph\">IAT (Import Address Table) checks rely on identifying which API functions are imported by an executable in order to analyze potential threats. However, direct system calls do not rely on imported function references. Instead, they access system services directly using identifiers that are not listed in standard IAT entries.<\/p>\n\n<p class=\"wp-block-paragraph\">As a result, malware using direct syscalls will not be detected by merely inspecting the IAT or commonly used Win32 APIs.<\/p>\n\n<div style=\"height:52px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\">Let&#8217;s verify the assumption by implementing <a href=\"https:\/\/github.com\/jthuraisamy\/SysWhispers2\">SysWhispers2<\/a> (Installation instructions are on the Github). In our own repository, the C++ file &#8220;<a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/injectSyscall-LocalProcess.cpp\">injectSyscall-LocalProcess.cpp<\/a>&#8221; adds code to use direct syscalls instead of basic Win32 API calls. Here are the key steps of our implementation:  <\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"195\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture1.png\" alt=\"picture1\" class=\"wp-image-4300\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture1.png 601w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture1-480x156.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 601px, 100vw\" \/><\/figure>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"344\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture2.png\" alt=\"picture2\" class=\"wp-image-4302\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture2.png 601w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture2-480x275.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 601px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><strong>Code explanation : <\/strong> Compared to the previous code &#8220;injectXOR.cpp&#8221;, we added :<\/p>\n\n<ul class=\"wp-block-list\">\n<li>\u2022 #include \u201csyscalls_common.h\u201d, a header file generated directly by SysWhispers2 that contains its main logic<\/li>\n\n\n\n<li>We use <strong>`malloc`<\/strong> to create a decoded buffer on the <strong>heap<\/strong> (in case we have a very large payload), and we call <strong>`free(decoded)`<\/strong> at the end to prevent memory leaks<\/li>\n\n\n\n<li>  We subtract <strong>1<\/strong> when calculating the payload size because the compiler automatically adds a <strong>null terminator<\/strong> (\\0) to the end of string literals.\n<ul class=\"wp-block-list\">\n<li>Code: char key[] = &#8220;L0c4L!iN7act0r!&#8221;;<\/li>\n\n\n\n<li>Memory: The computer actually stores L0c4L!iN7act0r!\\0<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The decryption logic must use key[i % (sizeof(key) &#8211; 1)]. Without the <strong>-1<\/strong>, the loop would include the <strong>null terminator<\/strong> (0x00) in the XOR operation. Since data XOR 0 does nothing, that byte remains encrypted, corrupting the shellcode and causing the payload to crash  <\/li>\n\n\n\n<li>Inside the &#8220;\/\/Shellcode Execution&#8221; part of the code :<ul><li>Start with setting variables to setup our logic, such as handles to processes and pointers<\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li>Core Injection Steps:<ul><li>NtAllocateVirtualMemory(): Allocates memory in target process<\/li><\/ul><ul><li>NtWriteVirtualMemory(): Writes payload into allocated memory<\/li><\/ul><ul><li>NtProtectVirtualMemory(): Makes the memory executable<\/li><\/ul><ul><li>NtCreateThreadEx(): Creates a new thread to run the injected code<\/li><\/ul><ul><li>WaitForSingleObject(): Waits for thread completion<\/li><\/ul><ul><li>CloseHandle(): Gracefully closes the handle<\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li>VirtualFree(): Cleans up allocated memory<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h4 class=\"wp-block-heading\">Implementation and Compilation of Direct System Calls for Process Injection<\/h4>\n\n<p class=\"wp-block-paragraph\"><strong>Generating Syscall Headers and Assembly Stubs<\/strong>: Before configuring Visual Studio, you must generate the necessary files using the <a href=\"https:\/\/github.com\/jthuraisamy\/SysWhispers2\">SysWhispers2<\/a> script:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>Run the following command to generate the &#8220;common&#8221; set of system calls:<\/li>\n<\/ul>\n\n<ol class=\"wp-block-list\"><\/ol>\n\n<pre class=\"wp-block-code\"><code>python.exe .\\syswhispers.py --preset common -o syscalls_common<\/code><\/pre>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"259\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture3.png\" alt=\"picture3\" class=\"wp-image-4304\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture3.png 528w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture3-480x235.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 528px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><strong>Importing Syscall Headers and Source Files into the Solution<\/strong><\/p>\n\n<ul class=\"wp-block-list\">\n<li>Right-click the project name (<strong>ProcessInjection<\/strong>) in Solution Explorer.<\/li>\n\n\n\n<li>Select <strong>&#8220;Add<\/strong> &gt; &#8221; or &#8221; <strong>Existing Item&#8221;&#8230;<\/strong><\/li>\n\n\n\n<li>Select and add the following four files:<ul><li>syscalls_common.h<\/li><\/ul><ul><li>injectSyscall-LocalProcess.cpp<\/li><\/ul><ul><li>syscalls_common.c<\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li>syscalls_common_stubs.std.x64.asm<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"264\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture4.png\" alt=\"picture4\" class=\"wp-image-4306\"\/><\/figure>\n\n<p class=\"wp-block-paragraph\"><strong>Activating the Assembly Language Compiler (MASM)<\/strong><\/p>\n\n<ul class=\"wp-block-list\">\n<li>In the top menu, click on <strong>Project<\/strong>.<\/li>\n\n\n\n<li>Select <strong>Build Customizations&#8230;<\/strong><\/li>\n\n\n\n<li>Check the box for <strong>masm(.targets, .props)<\/strong> and click <strong>OK<\/strong>.<\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"464\" height=\"309\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture5.png\" alt=\"picture5\" class=\"wp-image-4308\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture5.png 464w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/picture5-300x200.png 300w\" sizes=\"(max-width: 464px) 100vw, 464px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><strong>Configuring Assembly File Properties<\/strong><\/p>\n\n<ul class=\"wp-block-list\">\n<li>In the <strong>Solution Explorer<\/strong> (on the right), locate the file: syscalls_common_stubs.std.x64.asm.<\/li>\n\n\n\n<li>Right-click the file and select <strong>Properties<\/strong> at the bottom of the context menu.<\/li>\n\n\n\n<li>In the <strong>General<\/strong> section, locate the <strong>Item Type<\/strong> field.<\/li>\n\n\n\n<li>Change the selection to <strong>Microsoft Macro Assembler<\/strong>.<\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"461\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image.png\" alt=\"image\" class=\"wp-image-4310\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image.png 680w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-480x325.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 680px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">5- Compiling the Final Executable  <\/p>\n\n<ul class=\"wp-block-list\">\n<li>Go to the top menu and click <strong>Build<\/strong>.<\/li>\n\n\n\n<li>Click &#8221; <strong>Rebuild Solution<\/strong>.&#8221;<\/li>\n<\/ul>\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\"><strong>Run the new version of &#8220;SecondExample.exe&#8221;:<\/strong><\/p>\n\n<ol class=\"wp-block-list\">\n<li>In the folder <em>where you have an exclusion, <\/em>this should provide you with a Meterpreter reverse shell in your attacking machine \ud83d\ude0a (don&#8217;t forget to relaunch the listener on your Kali machine)<\/li>\n\n\n\n<li>  Try dropping it to a folder where no exclusion is in place: you should be fine?<\/li>\n<\/ol>\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img alt=\"\" alt=\"\" loading=\"lazy\" decoding=\"async\" width=\"417\" height=\"297\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-25.png\" alt=\"\" class=\"wp-image-2943\" style=\"width:450px\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-25.png 417w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-25-300x214.png 300w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-25-400x284.png 400w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/figure>\n\n<p class=\"has-text-align-center wp-block-paragraph\">Congratulations! You have successfully bypassed anti-cheat detection!<\/p>\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"740\" height=\"502\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-18.png\" alt=\"Rambo congratulates you for that!\" class=\"wp-image-2929\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-18.png 740w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-18-480x326.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 740px, 100vw\" \/><\/figure>\n\n<div style=\"height:54px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>Don&#8217;t get out of focus! trying to execute it still raises Defender&#8217;s detection&#8230;<\/strong><\/p>\n\n<div style=\"height:57px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h2 class=\"wp-block-heading\"><a>Bypass Defender&#8217;s dynamic detection<\/a><\/h2>\n\n<p class=\"wp-block-paragraph\">Now that we can successfully drop anything to disk without being detected, another hard part lies into being able to execute our malware, without being flagged &#8220;on-the-run&#8221;.<\/p>\n\n<p class=\"wp-block-paragraph\">Dynamic detection is triggered on the fact that our payload is doing something that Defender thinks is malicious. We will therefore try to understand what behavior is considered malicious. <\/p>\n\n<h3 class=\"wp-block-heading\">Injecting calc.exe to assess our payload<\/h3>\n\n<p class=\"wp-block-paragraph\">We want to make sure that it is in fact our shellcode that is the problem not the loader&#8217;s code. To do so, let&#8217;s change the shellcode data so that it launches a harmless executable: &#8220;calc.exe&#8221;. For easiness, we also put the binary file directly on the <a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/calc_payload.bin\">repository<\/a>.  <\/p>\n\n<p class=\"wp-block-paragraph\">If you don&#8217;t trust us (you should inherently not), we provide the msfvenom command for you to generate it alone \ud83d\ude0a Then encrypt it, as you did previously, using the following commands :<\/p>\n\n<ul class=\"wp-block-list\">\n<li><em>msfvenom -p windows\/exec EXITFUNC=thread CMD=calc.exe -f exe -o calc.exe<\/em><\/li>\n\n\n\n<li><em>python3.exe .\\myEncoder3.py .\\Payloads\\calc_payload.bin luyftd<\/em><\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"541\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-19.png\" alt=\"Using myEncoder3.py to XOR encrypt the shellcode\" class=\"wp-image-2931\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-19.png 979w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-19-480x265.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 979px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><br\/>Let\u2019s save it to disk and run it:<strong> It works!<\/strong><\/p>\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"690\" height=\"701\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-1.png\" alt=\"image\" class=\"wp-image-4312\" style=\"width:405px;height:auto\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-1.png 690w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-1-480x488.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 690px, 100vw\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\"><em>So our assumption was right<\/em>: Defender doesn&#8217;t like the activity performed by the <strong><em>shellcode<\/em><\/strong>. We are therefore sure nothing is wrong with our injection process! <\/p>\n\n<div style=\"height:48px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<h3 class=\"wp-block-heading\">Injecting shellcode into another process<\/h3>\n\n<p class=\"wp-block-paragraph\">The most obvious reason would be the fact that our reverse shell, by definition, <em>uses networking to connect back to our machine<\/em>. If that is true, then we should try to inject our payload inside another process, which may be allowed to use networking. <\/p>\n\n<p class=\"wp-block-paragraph\">Let\u2019s verify this assumption by modifying our code. The C++ file<a href=\"https:\/\/github.com\/Hackmosphere\/DefenderBypass\/blob\/main\/injectSyscall-RemoteProcess.cpp\">\u201cinjectSyscall-RemoteProcess.cpp\u201d<\/a>adds code to inject the specified shellcode into another process. We chose to use the 7-Zip file manager binary because it has network permissions (for accessing network shares or software updates).   Here are the key steps of our implementation, shown in two images:  <\/p>\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"554\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-21.png\" alt=\"Part 1 of the remote injection process\" class=\"wp-image-2935\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-21.png 975w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-21-480x273.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 975px, 100vw\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"623\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-22.png\" alt=\"Part 2 aof the remote injection process\" class=\"wp-image-2937\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-22.png 975w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/03\/image-22-480x307.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 975px, 100vw\" \/><\/figure>\n<\/div>\n\n<p class=\"wp-block-paragraph\"><strong>Code explanation : <\/strong> Compared to the previous code &#8220;injectSyscall-LocalProcess.cpp&#8221;, we added :<\/p>\n\n<ul class=\"wp-block-list\">\n<li>Retrieval of a handle to a remote process (7zFM.exe) using &#8220;NtOpenProcess()&#8221; and a custom &#8220;getHandle()&#8221; function. While previously, we were getting a handle to the current process using &#8220;GetCurrentProcess()&#8221; <\/li>\n\n\n\n<li>Our shellcode in then injected into this remote process, by allocating memory and writing the shellcode to it (as done in the last example)<\/li>\n<\/ul>\n\n<div style=\"height:38px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n<p class=\"wp-block-paragraph\"><strong>Run the &#8220;FinalExample.exe&#8221;:<\/strong><\/p>\n\n<ol class=\"wp-block-list\">\n<li>In the folder <em>where you have an exclusion, <\/em>this should provide you with a Meterpreter reverse shell in your attacking machine \ud83d\ude0a (don&#8217;t forget to relaunch the listener on your Kali machine)<\/li>\n<\/ol>\n\n<ul class=\"wp-block-list\">\n<li>Drop it to the Desktop<\/li>\n<\/ul>\n\n<ul class=\"wp-block-list\">\n<li>Not detected, Good ! Now run it<strong>(don&#8217;t forget to launch 7zFM.exe <\/strong>otherwise you can&#8217;t inject into it !) : <\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"432\" src=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-2.png\" alt=\"image\" class=\"wp-image-4314\" srcset=\"https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-2.png 939w, https:\/\/www.hackmosphere.fr\/wp-content\/uploads\/2025\/04\/image-2-480x221.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 939px, 100vw\" \/><\/figure>\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>Wow, we made it! \ud83d\ude00 <\/strong><\/p>\n\n<p class=\"wp-block-paragraph\">Now it is time to make a privilege escalation to reach Administrator or SYSTEM level. This will need another blog post! <\/p>\n\n<h1 class=\"wp-block-heading\">Conclusion<\/h1>\n\n<p class=\"wp-block-paragraph\">In this second article, we show-cased various techniques that when added together, allowed us to bypass Defender detection, despite using a very well-known shellcode.<\/p>\n\n<p class=\"wp-block-paragraph\">We also provided basic to advanced C++ code, explaining the different steps undertaken.<\/p>\n\n<p class=\"wp-block-paragraph\">Now it is your turn to upgrade your skills \ud83d\ude0a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reading Time: 10 minutesTechnical Level: Advanced Update: This post was last updated in June 2026. This is the second and final article on Defender evasion in 2026. In the first article (available here), we covered the basics needed to understand the Windows execution flow, what antivirus software is, and how it works. We also explained [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2888,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_titles_title":"Windows Defender antivirus bypass in 2025 - part 2","_seopress_titles_desc":"Discover how hackers bypass an antivirus such as Windows Defender, using advanced techniques such as direct syscalls and shellcode encryption","_seopress_robots_index":"","_seopress_robots_follow":"","_seopress_robots_imageindex":"","_seopress_robots_snippet":"","_seopress_robots_primary_cat":"none","_seopress_robots_breadcrumbs":"","_seopress_robots_freeze_modified_date":"","_seopress_robots_custom_modified_date":"","_seopress_robots_canonical":"","_seopress_social_fb_title":"","_seopress_social_fb_desc":"","_seopress_social_fb_img":"","_seopress_social_fb_img_attachment_id":0,"_seopress_social_fb_img_width":0,"_seopress_social_fb_img_height":0,"_seopress_social_twitter_title":"","_seopress_social_twitter_desc":"","_seopress_social_twitter_img":"","_seopress_social_twitter_img_attachment_id":0,"_seopress_social_twitter_img_width":0,"_seopress_social_twitter_img_height":0,"_seopress_redirections_value":"","_seopress_redirections_enabled":"","_seopress_redirections_enabled_regex":"","_seopress_redirections_logged_status":"both","_seopress_redirections_param":"","_seopress_redirections_type":301,"_seopress_analysis_target_kw":"","_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-2994","post","type-post","status-publish","format-standard","has-post-thumbnail","category-red-team"],"_links":{"self":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/2994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/comments?post=2994"}],"version-history":[{"count":4,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/2994\/revisions"}],"predecessor-version":[{"id":4321,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/2994\/revisions\/4321"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/media\/2888"}],"wp:attachment":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/media?parent=2994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/categories?post=2994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/tags?post=2994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}