metasploit-framework/modules/auxiliary/parser/unattend.rb

70 lines
1.8 KiB
Ruby
Raw Normal View History

2013-04-25 22:01:19 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2013-04-25 22:01:19 +00:00
##
require 'msf/core'
require 'rex/parser/unattend'
class Metasploit3 < Msf::Auxiliary
2013-09-05 19:57:40 +00:00
def initialize(info={})
super( update_info( info,
2013-09-27 21:04:03 +00:00
'Name' => 'Auxilliary Parser Windows Unattend Passwords',
'Description' => %q{
2013-09-05 19:57:40 +00:00
This module parses Unattend files in the target directory.
2013-04-25 22:01:19 +00:00
2013-09-05 19:57:40 +00:00
See also: post/windows/gather/enum_unattend
},
2013-09-27 21:04:03 +00:00
'License' => MSF_LICENSE,
'Author' =>
[
'Ben Campbell',
2013-09-05 19:57:40 +00:00
],
2013-09-27 21:04:03 +00:00
'References' =>
2013-09-05 19:57:40 +00:00
[
['URL', 'http://technet.microsoft.com/en-us/library/ff715801'],
2013-09-27 20:45:57 +00:00
['URL', 'http://technet.microsoft.com/en-us/library/cc749415(v=ws.10).aspx'],
['URL', 'http://technet.microsoft.com/en-us/library/c026170e-40ef-4191-98dd-0b9835bfa580']
2013-09-05 19:57:40 +00:00
],
))
2013-04-25 22:01:19 +00:00
2013-09-05 19:57:40 +00:00
register_options([
OptPath.new('PATH', [true, 'Directory or file to parse.']),
OptBool.new('RECURSIVE', [true, 'Recursively check for files', false]),
])
end
2013-04-25 22:01:19 +00:00
2013-09-05 19:57:40 +00:00
def run
if datastore['RECURSIVE']
ext = "**/*.xml"
else
ext = "/*.xml"
end
2013-04-25 22:01:19 +00:00
2013-09-05 19:57:40 +00:00
if datastore['PATH'].ends_with('.xml')
filepath = datastore['PATH']
else
filepath = File.join(datastore['PATH'], ext)
end
2013-04-25 23:55:10 +00:00
2013-09-05 19:57:40 +00:00
Dir.glob(filepath) do |item|
print_status "Processing #{item}"
file = File.read(item)
begin
xml = REXML::Document.new(file)
rescue REXML::ParseException => e
print_error("#{item} invalid xml format.")
vprint_line(e.message)
next
end
2013-04-25 22:25:05 +00:00
2013-09-05 19:57:40 +00:00
results = Rex::Parser::Unattend.parse(xml)
table = Rex::Parser::Unattend.create_table(results)
print_line table.to_s unless table.nil?
print_line
end
end
2013-04-25 22:01:19 +00:00
end