2011-03-22 23:04:41 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-03-22 23:04:41 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Post
|
2011-03-22 23:04:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
|
|
|
'Name' => 'Multi Gather Run Console Resource File',
|
|
|
|
'Description' => %q{ This module will read console commands from a resource file and
|
|
|
|
execute the commands in the specified Meterpreter session.},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
|
|
|
|
'Platform' => [ 'win' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter' ]
|
|
|
|
))
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
|
|
|
|
OptString.new('RESOURCE', [true, 'Full path to resource file to read commands from.', nil]),
|
|
|
|
|
|
|
|
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Run Method for when run command is issued
|
|
|
|
def run
|
|
|
|
print_status("Running module against #{sysinfo['Computer']}")
|
2016-04-20 12:11:34 +00:00
|
|
|
if not ::File.exist?(datastore['RESOURCE'])
|
2013-08-30 21:28:54 +00:00
|
|
|
raise "Resource File does not exists!"
|
|
|
|
else
|
|
|
|
::File.open(datastore['RESOURCE'], "rb").each_line do |cmd|
|
|
|
|
next if cmd.strip.length < 1
|
|
|
|
next if cmd[0,1] == "#"
|
|
|
|
begin
|
|
|
|
print_status "Running command #{cmd.chomp}"
|
|
|
|
session.console.run_single(cmd.chomp)
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_status("Error Running Command #{cmd.chomp}: #{e.class} #{e}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-07-27 02:39:49 +00:00
|
|
|
end
|