nettitude / PoshC2

A proxy aware C2 framework used to aid red teamers with post-exploitation and lateral movement.
BSD 3-Clause "New" or "Revised" License
1.8k stars 326 forks source link

[BUG] Stage2-Core.ps1 gets flagged by Windows Defender #164

Closed 0xvm closed 4 years ago

0xvm commented 4 years ago

Description

Windows defender with defs. 1.321.1947.0 ( 22 Aug 2020 ) flags Stage2-Core.ps1 as malicious. This results in the Stage2-Core.ps1 functions not getting loaded ( although the implant successfully connects and communicates with the C2 server ).

The offending function appear to be "Get-Screenshot". One can either delete the offending function or modify/ obfuscate it. A rather simplistc example that evades Defender while retaining functionality is here: https://github.com/0xvm/PoshC2/commit/dc0eb345ba7137a23e94562e48b68afe3a922d09.

Execution Environment:

All of this must be filled in Data Value
Full Posh version (all the text between the === at the top of the Implant Handler) =============== PoshC2 v7.0 (837846a 2020-08-20 22:12:50) ===============
OS & version Clients: Windows 10 x64 1809 and Windows 10 x64 1910, Server: Linux KALi 5.7.0-kali1-amd64 #1 SMP Debian 5.7.6-1kali2 (2020-07-01) x86_64 GNU/Linux
Using Docker/containerisation? Nope.

Implant Info

Defensive Technologies

To Reproduce

Steps to reproduce the behavior:

  1. Create a new posh project.
  2. Start posh-server and the implant handler.
  3. Execute the powershell encoded command variant on target (i.e. powershell -exec bypass -Noninteractive -windowstyle hidden -e WwBTAHkA .... [snipped]).
  4. Following the initial communication with the C2 the implant attempts to load Stage2-Core.ps1, however this gets flagged by Windows Defender [refer to screenshot below].
  5. Trying to execute any function listed in Stage2-Core.ps1, such as Get-Proxy, will result in an error [refer to screenshot below].

Expected behavior

Stage2-Core.ps1 should be able to evade Windows Defender

Screenshots

image

Attach files if required

Additional context

benpturner commented 4 years ago

Thanks for the heads up! Thats a nice find, I think in the first instance we will pull out the get-screenshot functions from the stage2-core.ps1 and try again. My suspicion is its the Get-ScreenshotMulti as it uses add-type which we could put into a separate function to start with

benpturner commented 4 years ago

If you fancy giving that a go and doing a PR that would be very helpful, don't mind helping get it through. If not i'll have a look when I get a second.

0xvm commented 4 years ago

Many thanks for the quick reply,

I submitted pull request #165 Let me know what you think, i'll be happy to review this further.

benpturner commented 4 years ago

Thanks, I was also adding some of this to a separate file when you raised it before you did this PR - https://github.com/nettitude/PoshC2/pull/171. Let me know if this fixes it otherwise i'll merge your PR

Console commented 4 years ago

Closing issue as changes have now been merged into Master with pull request #171 to resolve defender detections of core implant.