Files
metasploit-gs/modules/post/linux/busybox/enum_hosts.rb
T

50 lines
1.4 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::File
2015-08-28 11:50:17 -05:00
include Msf::Post::Linux::BusyBox
def initialize
super(
2015-08-28 09:53:31 -05:00
'Name' => 'BusyBox Enumerate Host Names',
2015-08-28 09:37:18 -05:00
'Description' => %q{
This module will be applied on a session connected to a BusyBox shell. It will enumerate
host names related to the device executing BusyBox.
},
'Author' => 'Javier Vicente Vallejo',
'License' => MSF_LICENSE,
'Platform' => ['linux'],
'SessionTypes' => ['shell']
)
end
def run
2015-08-28 09:37:18 -05:00
print_status('Searching hosts files...')
2015-08-28 11:56:12 -05:00
if busy_box_file_exist?('/var/hosts')
2015-08-28 09:37:18 -05:00
hosts_file = '/var/hosts'
2015-08-28 11:56:12 -05:00
elsif busy_box_file_exist?('/var/udhcpd/udhcpd.leases')
2015-08-28 09:37:18 -05:00
hosts_file = '/var/udhcpd/udhcpd.leases'
else
2015-08-28 09:37:18 -05:00
print_error('Files not found')
return
end
2015-08-28 09:37:18 -05:00
read_hosts_file(hosts_file)
end
def read_hosts_file(file)
begin
2015-08-28 09:37:18 -05:00
str_file=read_file(file)
2015-09-05 22:56:11 -05:00
print_good("Hosts file found: #{file}.")
vprint_line(str_file)
2015-09-05 22:56:11 -05:00
p = store_loot('busybox.enum.hosts', 'text/plain', session, str_file, file, 'BusyBox device host names')
print_good("Hosts saved to #{p}.")
rescue EOFError
2015-08-28 09:37:18 -05:00
print_error("Nothing read from file: #{file}, file may be empty.")
end
end
end