Skip to content

Commit 11ef366

Browse files
committed
Properly close hashlist
1 parent 89d4f01 commit 11ef366

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

modules/auxiliary/analyze/jtr_aix.rb

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,58 +38,60 @@ def run
3838
wordlist.close
3939
end
4040

41-
hashlist = Rex::Quickfile.new("jtrtmp")
42-
4341
myloots = myworkspace.loots.find(:all, :conditions => ['ltype=?', 'aix.hashes'])
44-
unless myloots.nil? or myloots.empty?
45-
myloots.each do |myloot|
46-
usf = ''
47-
begin
48-
File.open(myloot.path, "rb") do |f|
49-
usf = f.read
50-
end
51-
rescue Exception => e
52-
print_error("Unable to read #{myloot.path} \n #{e}")
53-
next
54-
end
55-
usf.each_line do |row|
56-
row.gsub!(/\n/, ":#{myloot.host.address}\n")
57-
hashlist.write(row)
42+
return if myloots.nil? or myloots.empty?
43+
44+
loot_data = ''
45+
46+
myloots.each do |myloot|
47+
usf = ''
48+
begin
49+
File.open(myloot.path, "rb") do |f|
50+
usf = f.read
5851
end
52+
rescue Exception => e
53+
print_error("Unable to read #{myloot.path} \n #{e}")
54+
next
55+
end
56+
usf.each_line do |row|
57+
row.gsub!(/\n/, ":#{myloot.host.address}\n")
58+
loot_data << row
5959
end
60-
hashlist.close
60+
end
6161

62-
print_status("HashList: #{hashlist.path}")
62+
hashlist = Rex::Quickfile.new("jtrtmp")
63+
hashlist.write(row)
64+
hashlist.close
6365

64-
print_status("Trying Format:des Wordlist: #{wordlist.path}")
65-
john_crack(hashlist.path, :wordlist => wordlist.path, :rules => 'single', :format => 'des')
66-
print_status("Trying Format:des Rule: All4...")
67-
john_crack(hashlist.path, :incremental => "All4", :format => 'des')
68-
print_status("Trying Format:des Rule: Digits5...")
69-
john_crack(hashlist.path, :incremental => "Digits5", :format => 'des')
66+
print_status("HashList: #{hashlist.path}")
7067

71-
cracked = john_show_passwords(hashlist.path)
68+
print_status("Trying Format:des Wordlist: #{wordlist.path}")
69+
john_crack(hashlist.path, :wordlist => wordlist.path, :rules => 'single', :format => 'des')
70+
print_status("Trying Format:des Rule: All4...")
71+
john_crack(hashlist.path, :incremental => "All4", :format => 'des')
72+
print_status("Trying Format:des Rule: Digits5...")
73+
john_crack(hashlist.path, :incremental => "Digits5", :format => 'des')
7274

75+
cracked = john_show_passwords(hashlist.path)
7376

74-
print_status("#{cracked[:cracked]} hashes were cracked!")
7577

76-
cracked[:users].each_pair do |k,v|
77-
if v[0] == "NO PASSWORD"
78-
passwd=""
79-
else
80-
passwd=v[0]
81-
end
82-
print_good("Host: #{v.last} User: #{k} Pass: #{passwd}")
83-
report_auth_info(
84-
:host => v.last,
85-
:port => 22,
86-
:sname => 'ssh',
87-
:user => k,
88-
:pass => passwd
89-
)
78+
print_status("#{cracked[:cracked]} hashes were cracked!")
79+
80+
cracked[:users].each_pair do |k,v|
81+
if v[0] == "NO PASSWORD"
82+
passwd=""
83+
else
84+
passwd=v[0]
9085
end
86+
print_good("Host: #{v.last} User: #{k} Pass: #{passwd}")
87+
report_auth_info(
88+
:host => v.last,
89+
:port => 22,
90+
:sname => 'ssh',
91+
:user => k,
92+
:pass => passwd
93+
)
9194
end
92-
9395
end
9496

9597
end

0 commit comments

Comments
 (0)