This is a fun little lab to illustrate that sometimes changing just 1 byte in the shellcode is enough to bypass certain antivirus products, including the latest Windows Defender at the time of writing 11th Jan, 2019.
In this lab I'm using Windows 10 (1803) as a victim system, Kali running Cobalt Strike and Windows 7 where bad C++ happens.
Out of the Box Payload Getting Caught
As you probably know, default / out of the box payloads are usually caught by antivirus vendors immedialy. No exception is the Cobalt Strike's default stageless beacon which gets flagged by Windows Defender on Windows 10:
Can we do something about it?
1 Byte Trick
Let's generate a Cobalt Strike shellcode for our listener in C:
Note that the first byte of the shellcode is \xfc.
For the next step, I'm using a classic shellcode injection technique I played with in T1055: Process Injection.
Let's put the shellcode we got into the launcher, but with a small twist:
Change \xfc to any other byte value. I chose \xfd (line 80)
Store the correct first byte \xfc in a char variable (line 81)
Before copying the full shellcode to the newly allocated memory, flip the bad byte \xfd with a good one \xfc (line 86)
Build the executable
Profit?
Below is the source code if you want to test it in your environment:
On the left - Windows 10 with Windows Defender turned on and on the right is Cobalt Strike receiving the beacon checkin once our shellcode is invoked:
This is a quick and dirty proof of concept and hence the console window is visible for a brief moment, meaning a target user can suspect nefarious activity.
Below shows that the beacon that called back is stable and working as expected:
Below is another quick demo showing that the latest Windows updates were installed at the time of testing the POC on 11th Jan, 2019:
Default Payload
Below shows that if the Cobalt Strike shellcode was injected as is, it immediately gets flagged:
Conclusion
Although not completely stealthy - the console window is visible for a brief moment during shellcode exeution, this short lab demonstrates that sometimes all it takes to evade AV detection is 1 one byte way.