Cobalt Strike Bypassing Windows Defender use obfuscation

For all the red team members, all signs of trouble in the delivery of effective alternatives while not delay the extension of the organization is always a challenge. Like all other security solutions, like, Windows Defender effective in terms of universal produced by Cobalt Strike and other detection tools have become better.

In this example, we will generate by Cobalt Strike PowerShell load, and learn how to operate, bypassing Windows Defender on a Windows 10 PC execution. This is not to hide from Windows Defender simple solutions before and after the payload of the most elegant, but is one of the methods we use, and can work properly.

Creating the payload is as follows:

Screenshot of March 14 165 050

This will lead to payload.txt Create a PowerShell commands.

March 14 Screenshot of 165,300

If we try to run commands on the victim PC, Windows Defender will greet us, thus threatening its potential.

March 12 Screenshot of 213,046

In order to bypass the Windows Defender, we need to first understand how Cobalt Strike create its payload, and then change some of its signature, Windows Defender hope that it is safe.

First of all, obviously, can be of base64-encoded payload command format or by looking through * -encodedcommand * PowerShell symbol coding .

To decode the command, we need to cut

powershell.exe` `-nop` `-w` `hidden` `-encodedcommand

Separate and retain the rest.

Then use the following command decoder rest of the string.

echo` `'base64 payload'` `| ``base64` `-d

Screenshot March 14 170 240 of

生成的解码字符串初始包含base64编码的字符串,但尝试解码将不起作用并吐出乱码,因为该字符串也是从IEX明显经过Gzip压缩的(新对象IO.StreamReader(新对象IO。 Compression.GzipStream($ s [IO.Compression.CompressionMode] :: Decompress)))。ReadToEnd()部分,PowerShell命令。

现在我们需要了解此命令中的内容,因为这实际上是触发Windows Defender的部分,即有效负载。通过一些Google搜索,我找到了该PowerShell脚本,它完全可以完成[ http://chernodv.blogspot。 com.cy/2014/12/powershell-compression-decompression.html

](http://chernodv.blogspot.com.cy/2014/12/powershell-compression-decompression.html

$data` `= ``[System.Convert]``::FromBase64String(``'gzip base64'``)``$ms` `= ``New-Object` `System.IO.MemoryStream``$ms``.Write(``$data``, 0, ``$data``.Length)``$ms``.Seek(0,0) | ``Out-Null``$sr` `= ``New-Object` `System.IO.StreamReader(``New-Object` `System.IO.Compression.GZipStream(``$ms``, ``[System.IO.Compression.CompressionMode]``::Decompress))``$sr``.ReadToEnd() | ``set-clipboard

该脚本首先将对字符串进行base64解码,然后将其解压缩,从而为我们提供完整的代码。它随后将输出的内容复制到副本,以将其粘贴到文本文件中,以备后用。

March 14 Screenshot of 174,210

在** $ var_code **变量保存正在由Windows Defender的检测有效副本,我们需要换出绕过防御者。

进一步将** $ var_code **解码是多个ASCII字符,但此时不需要完全解码。

$enc``=``[System.Convert]``::FromBase64String(``'encoded string'``)

我们可以通过以下方式阅读部分内容:

$readString``=``[System.Text.Encoding]``::ASCII.GetString(``$enc``)

Windows 10 1

现在,以上内容显示了有关用户代理和攻击者IP的一些信息。

对于这类工作,最好的工具和首选工具是Daniel Bohannon的 Invoke-Obfuscation。可以在这里找到该项目的Github页面。

以Invoke-Obfuscation开始的命令是:

Import-Module` `.\``Invoke-Obfuscation``.psd1``Invoke-Obfuscation

Screenshot March 14 180 929 of

现在,我们需要定义需要纠正的有效替代部分。可以使用以下命令完成

Set scriptblock ``'final_base64payload'

March 14 181 156 screenshot

该工具将使用我们的脚本块,然后询问我们要进行的方式。在这种情况下,我选择了COMPRESS,然后选择了1。这并不意味着其他选项将不起作用,但是在撰写本文中,Inboke-Obfuscation将发挥神奇的作用,并打印出PowerShell命令,该命令经过充分处理,可能会绕过Windows Defender。

2

然后,只需键入Out,然后输入为其另存为PowerShell脚本的路径即可。

Out c:\payload.ps1

3

先前步骤中当前解压缩的有效负载如下所示。

Screenshot 1,837,473 14 May

因此,这全都归结为以下事实:我们需要用我们从Invoke-Obfuscation新创建的有效负载替换** [Byte []] $ var_code = [System.Convert] :: FromBase64String **内容。了一个新变量,我将其称为$煞,然后将Invoke-Obfuscation的输出内容放入其中。

重要提示 –您需要在最后一个|之后移除零件。来自Invoke-Obfuscation的输出,因为这是执行命令的命令。我们将不需要它,因为Cobalt Strike模板将为我们做到这一点。

4

如果您使用的是@sec_groundzero Aggressor脚本则结果应为Cobalt Strike中的信标和Slack通知。

5

6

如果我们使用Process Hacker来检查原始CS有效负载和修改后的CS有效负载,我们会发现我们没有更改信标的基本行为。

Process 2

Guess you like

Origin www.cnblogs.com/8gman/p/12341391.html