CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/parser/unattend.rb
Views: 11780
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
7
class MetasploitModule < Msf::Auxiliary
8
9
def initialize(info={})
10
super( update_info( info,
11
'Name' => 'Auxilliary Parser Windows Unattend Passwords',
12
'Description' => %q{
13
This module parses Unattend files in the target directory.
14
15
See also: post/windows/gather/enum_unattend
16
},
17
'License' => MSF_LICENSE,
18
'Author' =>
19
[
20
'Ben Campbell',
21
],
22
'References' =>
23
[
24
['URL', 'https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/ff715801(v=win.10)'],
25
['URL', 'https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc749415(v=ws.10)'],
26
['URL', 'https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc732280(v=ws.10)']
27
],
28
))
29
30
register_options([
31
OptPath.new('PATH', [true, 'Directory or file to parse.']),
32
OptBool.new('RECURSIVE', [true, 'Recursively check for files', false]),
33
])
34
end
35
36
def run
37
if datastore['RECURSIVE']
38
ext = "**/*.xml"
39
else
40
ext = "/*.xml"
41
end
42
43
if datastore['PATH'].ends_with?('.xml')
44
filepath = datastore['PATH']
45
else
46
filepath = File.join(datastore['PATH'], ext)
47
end
48
49
Dir.glob(filepath) do |item|
50
print_status "Processing #{item}"
51
file = File.read(item)
52
begin
53
xml = REXML::Document.new(file)
54
rescue REXML::ParseException => e
55
print_error("#{item} invalid xml format.")
56
vprint_line(e.message)
57
next
58
end
59
60
results = Rex::Parser::Unattend.parse(xml)
61
table = Rex::Parser::Unattend.create_table(results)
62
print_line table.to_s unless table.nil?
63
print_line
64
end
65
end
66
end
67
68
69