Bypassing Windows Defender: One TCP Socket Away From Meterpreter and Beacon Sessions
Last updated
Was this helpful?
Last updated
Was this helpful?
If you've tried executing an out of the box meterpreter payload on the box with Windows Defender, you know it may get picked up right away as can be seen in the below gif:
This quick lab shows how I was able to execute the off the shelf meterpreter payload against the latest Windows Defender (7th of May at the time of writing) by delivering the shellcode over a TCP socket.
The technique that allowed me to bypass Windows Defender is simple:
Victim machine (10.0.0.7) opens up a listening TCP socket on on port 443 (or any other)
Socket on the victim machine waits for incoming shellcode
Attacking machine (10.0.0.5) connects to the victim socket and sends the shellcode as binary data
Victim machine receives the shellcode, allocates executable memory and moves the shellcode there
Victim machine executes the shellcode received over the network and initiates meterpreter (or cobalt strike beacon) second stage download
Attacking machine serves the stage and catches the shell
Let's execute it on the victim machine and check if the socket on port 443 has been opened:
Let's generate a staged meterpreter payload and output it to C format:
Let's setup an msf handler to catch the meterpreter session on the attacking machine:
We can now take the shellcode from the C file and echo it out as a binary data, pipe it to the victim machine (where a TCP socket is listening on 443) via netcat:
We are now ready to execute the attack. Below shows all of the above in action:
Cmd shell in the middle of the screen opens the TCP socket (port 443) on the victim machine
Windows Defender below the cmd shell shows the signatures are up to date
Top right - msfconsole is waiting and ready to send the second stage from the attacking system
Bottom right - attacker sends the shellcode to the victim over the wire via netcat
Top right - msfconsole serves the second stage to the victim and establishes the meterpreter session
Why this works? I can only speculate. I am a huge fan of Windows Defender and I think it is doing an amazing job at catching evil and I am sure this will be caught very soon.
Let's write, compile a simple PoC C++ program (see section) that will do all of the steps explained in the overview section.