Deceiving Defender: The Texas Two Step
Utilizing a novel high-level methodology to bypass the increased protections of Windows Defender on Windows 11 systems in order to make mimikatz.exe viable again
Last updated
Utilizing a novel high-level methodology to bypass the increased protections of Windows Defender on Windows 11 systems in order to make mimikatz.exe viable again
Last updated
Mimikatz is an open source offensive security solution that allows users to dump stored credentials or Kerberos tickets stored in memory.
Mimikatz is a powerful tool that is often used by Red Teams to extract credentials from a target system. However, due to the tool's popularity, it's often signatured by Windows Defender as a malicious binary. Because the PE is not survivable, it can become difficult to leverage the tool if Windows Defender is enabled on the target.
Thankfully, mimikatz is an open source tool so we can try to recompile the tool and see if that's enough to break the signature that Windows Defender uses to detect mimikatz.
We retarget the solution provided by the program author. For our purposes we're not interested in compiling for Windows XP, so we can use an updated Platform Toolset (v143).
We comment out a line here
And we turn off treating warnings as errors
Note: Be sure to do this for all of the project files (mimikatz, mimilove, etc)
We notice a size difference between the binary provided by the author and the binary we were able to generate, lets see how it fares against Windows Defender.
Unfortunately, it doesn't seem like this is going to be enough to bypass Windows Defender.
Using ThreatCheck and Ghidra, we're able to identify the location of some bad instructions.
The strings give away the location of this portion of the code in the source.
After doing this a couple of times, we find that every string in mimikatz.exe is flagged. So at this point we can either continue to obfuscate every string in the source, or we can implement our defender bypasses. We're going to opt to implement a Windows Defender bypass. Let's try our classic bypasses.
Even after implementing these checks, we get caught by defender. Let's try something else.
There's another trick we have up our sleeves: encryption. The process goes something will go something like this:
Convert the mimikatz.exe into shellcode
Encrypt the shellcode
Load shell code into a dropper program
????
Profit
We have use pe2shc to convert mimikatz.exe into a shell code. The process is pretty straight forward.
We use standard aes encryption script written in python to encrypt our shellcode
Finally, we implement the code and it looks something like this:
We compile the above code
[Intentionally Left Blank]
And we now beat ThreatCheck!
And it looks like our file can survive on disk! But there's a problem.
If we run the program now, it'll get caught by Windows Defender. There's one more trick we can implement to bypass this.
Windows Defender only run its most expensive antivirus components on new executables. So if we insert fake code that we execute at run time, Windows Defender will register the signature of our executable as "safe" and we'll be free to do whatever we want on the system with our executable.
So we implement the following code:
This code checks if our executable is named "not_mimikatz.exe", and if so it executes "safe" functionality. Windows Defender will then register this executable as safe (the first step).
Then we rename the executable to "mimikatz.exe" and execute our malicious code (the second step). This is the Texas Two Step methodology for bypassing Windows Defender.
Interestingly enough, the Texas Two Step is only necessary to bypass Windows Defender on Windows 11 systems. Windows 10 systems seem to determine if a binary is safe purely on the results of the Windows Defender scanning/emulation (which we bypass with our encryption).
Windows 11 systems on the other hand, further analyze an executable's functionality when first executed.
In this writeup, we saw one way that Windows Defender on Windows 11 provides greater protection that Windows Defender on Windows 10. We also saw how an attacker could bypass that protection and execute one of the most useful Red Teaming tools with the Texas Two Step.
Windows Defender does offer protection against some threats, but an adversary committed to bypassing those defenses can utilize this and other techniques in order to leverage the plethora of open source tools that exists to compromise systems.