metasploit-framework/modules/auxiliary/analyze/jtr_aix.rb

98 lines
2.3 KiB
Ruby
Raw Normal View History

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
#
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Auxiliary::JohnTheRipper
def initialize
super(
2012-01-11 17:11:23 +00:00
'Name' => 'John the Ripper AIX Password Cracker',
'Description' => %Q{
This module uses John the Ripper to identify weak passwords that have been
acquired from passwd files on AIX systems.
},
'Author' =>
[
'theLightCosine',
'hdm'
] ,
'License' => MSF_LICENSE # JtR itself is GPLv2, but this wrapper is MSF (BSD)
)
end
def run
wordlist = Rex::Quickfile.new("jtrtmp")
begin
wordlist.write( build_seed().join("\n") + "\n" )
ensure
wordlist.close
end
myloots = myworkspace.loots.find(:all, :conditions => ['ltype=?', 'aix.hashes'])
2013-08-19 18:14:13 +00:00
return if myloots.nil? or myloots.empty?
loot_data = ''
myloots.each do |myloot|
usf = ''
begin
File.open(myloot.path, "rb") do |f|
usf = f.read
end
2013-08-19 18:14:13 +00:00
rescue Exception => e
print_error("Unable to read #{myloot.path} \n #{e}")
next
end
usf.each_line do |row|
row.gsub!(/\n/, ":#{myloot.host.address}\n")
loot_data << row
end
2013-08-19 18:14:13 +00:00
end
2013-08-19 18:14:13 +00:00
hashlist = Rex::Quickfile.new("jtrtmp")
2013-08-19 19:33:01 +00:00
hashlist.write(loot_data)
2013-08-19 18:14:13 +00:00
hashlist.close
2013-08-19 18:14:13 +00:00
print_status("HashList: #{hashlist.path}")
2013-08-19 18:14:13 +00:00
print_status("Trying Format:des Wordlist: #{wordlist.path}")
john_crack(hashlist.path, :wordlist => wordlist.path, :rules => 'single', :format => 'des')
print_status("Trying Format:des Rule: All4...")
john_crack(hashlist.path, :incremental => "All4", :format => 'des')
print_status("Trying Format:des Rule: Digits5...")
john_crack(hashlist.path, :incremental => "Digits5", :format => 'des')
2013-08-19 18:14:13 +00:00
cracked = john_show_passwords(hashlist.path)
2013-08-19 18:14:13 +00:00
print_status("#{cracked[:cracked]} hashes were cracked!")
cracked[:users].each_pair do |k,v|
if v[0] == "NO PASSWORD"
passwd=""
else
passwd=v[0]
end
2013-08-19 18:14:13 +00:00
print_good("Host: #{v.last} User: #{k} Pass: #{passwd}")
report_auth_info(
:host => v.last,
:port => 22,
:sname => 'ssh',
:user => k,
:pass => passwd
)
end
end
end