Files
metasploit-gs/modules/post/windows/gather/enum_hostfile.rb
T

54 lines
1.3 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::File
2013-08-30 16:28:54 -05:00
def initialize(info={})
super(update_info(info,
'Name' => 'Windows Gather Windows Host File Enumeration',
'Description' => %q{
This module returns a list of entries in the target system's hosts file.
},
'License' => BSD_LICENSE,
'Author' => [ 'vt <nick.freeman[at]security-assessment.com>'],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter', 'shell' ]
))
end
2013-08-30 16:28:54 -05:00
def run
# read in the hosts in the hosts file.
hosts = read_file "C:\\WINDOWS\\System32\\drivers\\etc\\hosts"
2013-08-30 16:28:54 -05:00
# Store the original hosts file
p = store_loot(
'hosts.confige',
'text/plain',
session,
hosts,
2013-08-30 16:28:54 -05:00
'hosts_file.txt',
'Windows Hosts File'
)
2013-08-30 16:28:54 -05:00
# Print out each line that doesn't start w/ a comment
entries = []
hosts.each_line do |line|
2013-08-30 16:28:54 -05:00
next if line =~ /^[\r|\n|#]/
entries << line.strip
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
# Show results
if not entries.empty?
print_line("Found entries:")
entries.each do |e|
print_good(e.to_s)
end
end
2013-08-30 16:28:54 -05:00
print_status("Hosts file saved: #{p.to_s}")
end
end