Skip to content

Commit 1d8c461

Browse files
committed
Do last code cleaning
1 parent eacf70a commit 1d8c461

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

modules/auxiliary/gather/mybb_get_type_db.rb

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,17 @@ class Metasploit3 < Msf::Auxiliary
1010

1111
def initialize(info = {})
1212
super(update_info(info,
13-
'Name' => 'Determinant Databases MyBB ',
13+
'Name' => 'Determinant Databases MyBB ',
1414
'Description' => %q{
15-
Determine the database in the forum.
16-
This affects versions <= 1.6.12
15+
This module checks if MyBB is running behind an URL. Also uses a malformed query to
16+
force an error and fingerprint the backend database used by MyBB.
1717
},
18-
'Author' =>
18+
'Author' =>
1919
[
2020
#http://www.linkedin.com/pub/arthur-karmanovskii/82/923/812
21-
'Arthur Karmanovskii <fnsnic[at]gmail.com>'#Discovery and Metasploit Module
22-
],
23-
'License' => MSF_LICENSE,
24-
'References' =>
25-
[
26-
[ 'URL', 'https://github.com/rapid7/metasploit-framework/pull/3070' ]
21+
'Arthur Karmanovskii <fnsnic[at]gmail.com>' # Discovery and Metasploit Module
2722
],
23+
'License' => MSF_LICENSE,
2824
'DisclosureDate' => 'Feb 13 2014'))
2925

3026
register_options(
@@ -44,49 +40,49 @@ def check
4440
'intcheck' => 1
4541
}
4642
})
47-
if res.nil?
48-
print_error("Failed to retrieve webpage.")
49-
return Exploit::CheckCode::Unknown
50-
end
5143

52-
if res.code != 200
53-
print_error("Unable to query to host: #{datastore['RHOST']}:#{datastore['RPORT']} (#{datastore['TARGETURI']}).")
44+
if res.nil? || res.code != 200
5445
return Exploit::CheckCode::Unknown
5546
end
5647

5748
#Check PhP
5849
php_version = res['X-Powered-By']
5950
if php_version
60-
php_version = " PHP Version: #{php_version}".ljust(40)
51+
php_version = "PHP #{php_version}"
6152
else
62-
php_version = " PHP Version: unknown".ljust(40)
53+
php_version = "PHP version unknown"
6354
end
6455

6556
#Check Web-Server
6657
web_server = res['Server']
6758
if web_server
68-
web_server = " Server Version: #{web_server}".ljust(40)
59+
web_server = "#{web_server}"
6960
else
70-
web_server = " Server Version: unknown".ljust(40)
61+
web_server = "unknown web server"
7162
end
7263

7364
#Check forum MyBB
7465
if res.body.match("&#077;&#089;&#066;&#066;")
75-
print_good("Congratulations! This forum is MyBB :) "+"HOST: "+datastore['RHOST'].ljust(15)+php_version+web_server)
66+
print_good("#{peer} - MyBB forum found running on #{web_server} / #{php_version}")
7667
return Exploit::CheckCode::Detected
7768
else
78-
print_status("This forum is not guaranteed to be MyBB"+"HOST: "+datastore['RHOST'].ljust(15)+php_version+web_server)
79-
return Exploit::CheckCode::Unknown
80-
end
81-
rescue RuntimeError => err
82-
print_error("Unhandled error in #{datastore['RHOST']}: #{err.class}: #{err}")
8369
return Exploit::CheckCode::Unknown
8470
end
71+
rescue
72+
return Exploit::CheckCode::Unknown
73+
end
8574

8675
end
8776

8877

8978
def run
79+
print_status("#{peer} - Checking MyBB...")
80+
unless check == Exploit::CheckCode::Detected
81+
print_error("#{peer} - MyBB not found")
82+
return
83+
end
84+
85+
print_status("#{peer} - Checking database...")
9086
uri = normalize_uri(target_uri.path, 'memberlist.php')
9187
response = send_request_cgi(
9288
{
@@ -97,17 +93,17 @@ def run
9793
}
9894
})
9995
if response.nil?
100-
print_error("Failed to retrieve webpage.")
96+
print_error("#{peer} - Timeout...")
10197
return
10298
end
10399

104100
#Resolve response
105101
if response.body.match(/SELECT COUNT\(\*\) AS users FROM mybb_users u WHERE 1=1 AND u.username NOT REGEXP\(\'\[a-zA-Z\]\'\)/)
106-
print_good("Database is: PostgreSQL ;)")
102+
print_good("#{peer} - Running PostgreSQL Database")
107103
elsif response.body.match(/General error\: 1 no such function\: REGEXP/)
108-
print_good("Database is: SQLite ;)")
104+
print_good("#{peer} - Running SQLite Database")
109105
else
110-
print_status("Database MySQL or this is not forum MyBB or unknown Database")
106+
print_status("#{peer} - Running MySQL or unknown database")
111107
end
112108
end
113109
end

0 commit comments

Comments
 (0)