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/multi/gather/run_console_rc_file.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67def initialize(info = {})8super(9update_info(10info,11'Name' => 'Multi Gather Run Console Resource File',12'Description' => %q{13This module will read console commands from a resource file and14execute the commands in the specified Meterpreter session.15},16'License' => MSF_LICENSE,17'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],18'Platform' => [ 'win' ],19'SessionTypes' => [ 'meterpreter' ]20)21)22register_options(23[2425OptString.new('RESOURCE', [true, 'Full path to resource file to read commands from.', nil]),2627]28)29end3031# Run Method for when run command is issued32def run33print_status("Running module against #{sysinfo['Computer']}")34if !::File.exist?(datastore['RESOURCE'])35raise 'Resource File does not exist!'36else37::File.open(datastore['RESOURCE'], 'rb').each_line do |cmd|38next if cmd.strip.empty?39next if cmd[0, 1] == '#'4041begin42print_status "Running command #{cmd.chomp}"43session.console.run_single(cmd.chomp)44rescue ::Exception => e45print_status("Error Running Command #{cmd.chomp}: #{e.class} #{e}")46end47end48end49end50end515253