move jtr output to -o function

master
h00die 2019-03-22 21:03:06 -04:00
parent f00c38cfe2
commit 6d59b29884
1 changed files with 21 additions and 24 deletions

View File

@ -106,8 +106,6 @@ class Creds
cmd_creds_help
when 'add'
creds_add(*args)
when 'export'
creds_export
else
# then it's not actually a subcommand
args.unshift(subcommand) if subcommand
@ -129,9 +127,6 @@ class Creds
print_line "Usage - Listing credentials:"
print_line " creds [filter options] [address range]"
print_line
print_line "Usage - Exporting in JtR format:"
print_line " creds export"
print_line
print_line "Usage - Adding credentials:"
print_line " creds add uses the following named parameters."
{
@ -171,7 +166,9 @@ class Creds
print_line
print_line "General options"
print_line " -h,--help Show this help information"
print_line " -o <file> Send output to a file in csv format"
print_line " -o <file> Send output to a file in csv/jtr (john the ripper) format."
print_line " If file name ends in '.jtr', that format will be used."
print_line " csv by default."
print_line " -d,--delete Delete one or more credentials"
print_line
print_line "Filter options for listing"
@ -534,10 +531,25 @@ class Creds
end
if output_file.nil?
print_line(tbl.to_s)
print_line(tbl.to_s)
else
# create the output file
::File.open(output_file, "wb") { |f| f.write(tbl.to_csv) }
if output_file.end_with? '.jtr'
hashlist = ::File.open(output_file, "wb")
['Metasploit::Credential::NonreplayableHash',
'Metasploit::Credential::PostgresMD5',
'Metasploit::Credential::NTLMHash'].each do |type|
framework.db.creds(type: type).each do |core|
formatted = hash_to_jtr(core)
unless formatted.nil?
hashlist.puts formatted
end
end
end
hashlist.close
else #csv
# create the output file
::File.open(output_file, "wb") { |f| f.write(tbl.to_csv) }
end
print_status("Wrote creds to #{output_file}")
end
@ -567,21 +579,6 @@ class Creds
end
def creds_export
hashlist = Rex::Quickfile.new("jtr_hashes")
count = 0
['Metasploit::Credential::NonreplayableHash',
'Metasploit::Credential::PostgresMD5',
'Metasploit::Credential::NTLMHash'].each do |type|
framework.db.creds(type: type).each do |core|
formatted = hash_to_jtr(core)
unless formatted.nil?
count += 1
hashlist.puts formatted
end
end
end
hashlist.close
print_status("#{count} JtR formatted hashes written to #{hashlist.path}")
end
end