Skip to content

Commit c3437da

Browse files
committed
Land rapid7#5451, @wchen-r7 Update filezilla_client_cred to use the new cred API
2 parents 57b7d10 + e431631 commit c3437da

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

modules/post/multi/gather/filezilla_client_cred.rb

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,44 @@ def check_filezilla(filezilladir)
103103
return nil
104104
end
105105

106+
107+
def report_cred(opts)
108+
service_data = {
109+
address: opts[:ip],
110+
port: opts[:port],
111+
service_name: opts[:service_name],
112+
protocol: 'tcp',
113+
workspace_id: myworkspace_id
114+
}
115+
116+
credential_data = {
117+
module_fullname: fullname,
118+
post_reference_name: self.refname,
119+
session_id: session_db_id,
120+
origin_type: :session,
121+
private_data: opts[:password],
122+
private_type: :password,
123+
username: opts[:user]
124+
}.merge(service_data)
125+
126+
login_data = {
127+
core: create_credential(credential_data),
128+
status: Metasploit::Model::Login::Status::UNTRIED,
129+
}.merge(service_data)
130+
131+
create_credential_login(login_data)
132+
end
133+
134+
def is_base64?(str)
135+
str.match(/^([A-Za-z0-9+\/]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$/) ? true : false
136+
end
137+
138+
139+
def try_decode_password(str)
140+
is_base64?(str) ? Rex::Text.decode_base64(str) : str
141+
end
142+
143+
106144
def get_filezilla_creds(paths)
107145

108146
sitedata = ""
@@ -155,14 +193,14 @@ def get_filezilla_creds(paths)
155193
else
156194
source_id = nil
157195
end
158-
report_auth_info(
159-
:host => loot['host'],
160-
:port => loot['port'],
161-
:sname => 'ftp',
162-
:source_id => source_id,
163-
:source_type => "exploit",
164-
:user => loot['user'],
165-
:pass => loot['password'])
196+
197+
report_cred(
198+
ip: loot['host'],
199+
port: loot['port'],
200+
service_name: 'ftp',
201+
username: loot['user'],
202+
password: try_decode_password(loot['password'])
203+
)
166204
end
167205
end
168206
end
@@ -214,7 +252,7 @@ def parse_accounts(data)
214252
print_status(" Server: %s:%s" % [account['host'], account['port']])
215253
print_status(" Protocol: %s" % account['protocol'])
216254
print_status(" Username: %s" % account['user'])
217-
print_status(" Password: %s" % account['password'])
255+
print_status(" Password: %s" % try_decode_password(account['password']))
218256
print_line("")
219257
end
220258
return creds

0 commit comments

Comments
 (0)