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/scripts/meterpreter/multiscript.rb
Views: 11766
##1# WARNING: Metasploit no longer maintains or accepts meterpreter scripts.2# If you'd like to improve this script, please try to port it as a post3# module instead. Thank you.4##5678#Meterpreter script for running multiple scripts on a Meterpreter Session9#Provided by Carlos Perez at carlos_perez[at]darkoperator[dot]com10#Version: 0.211################## Variable Declarations ##################12session = client13# Setting Argument1415@@exec_opts = Rex::Parser::Arguments.new(16"-h" => [ false,"Help menu." ],17"-c" => [ true,"Collection of scripts to execute. Each script command must be enclosed in double quotes and separated by a semicolon."],18"-r" => [ true,"Text file with list of commands, one per line."]19)20#Setting Argument variables21commands = ""22script = []23help = 02425################## Function Declarations ##################26# Function for running a list of scripts stored in a array27def script_exec(session,scrptlst)28print_status("Running script List ...")29scrptlst.each_line do |scrpt|30next if scrpt.strip.length < 131next if scrpt[0,1] == "#"3233begin34script_components = scrpt.split35script = script_components.shift36script_args = script_components37print_status "\trunning script #{scrpt.chomp}"38session.execute_script(script, script_args)39rescue ::Exception => e40print_error("Error: #{e.class} #{e}")41print_error("Error in script: #{scrpt}")42end43end44end4546def usage47print_line("Multi Script Execution Meterpreter Script ")48print_line(@@exec_opts.usage)49end5051################## Main ##################52@@exec_opts.parse(args) do |opt, idx, val|53case opt5455when "-c"56commands = val.gsub(/;/,"\n")57when "-r"58script = val59if not ::File.exist?(script)60raise "Script List File does not exist!"61else62::File.open(script, "rb").each_line do |line|63commands << line64end65end66when "-h"67help = 168end69end707172if args.length == 0 or help == 173usage74else75print_status("Running Multiscript script.....")76script_exec(session,commands)77end787980