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/test/functional/meterpreter/meterpreter_java_spec.rb
Views: 11623
$:.unshift(File.join(File.dirname(__FILE__)))1$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))2$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'test', 'lib'))34require 'fileutils'5require 'meterpreter_spec_helper'6require 'meterpreter_specs'78module MsfTest9describe "JavaMeterpreter" do10# This include brings in all the spec helper methods11include MsfTest::MeterpreterSpecHelper1213# This include brings in all the specs that are generic across the14# meterpreter platforms15include MsfTest::MeterpreterSpecs1617# This include brings in all the specs that are specific to the java18# meterpreter19include MsfTest::JavaMeterpreterSpecs2021before :all do22@verbose = true2324@meterpreter_type = "java"2526## Set up an outupt directory27@output_directory = File.join(File.dirname(__FILE__), "test_output_#{@meterpreter_type}")2829if File.directory? @output_directory30FileUtils.rm_rf(@output_directory)31end3233Dir.mkdir(@output_directory)34@default_file = "#{@output_directory}/default"3536create_session_java37end3839before :each do40end4142after :each do43@session.init_ui(@input, @output)44end4546after :all do47# FileUtils.rm_rf("*.jpeg")48# FileUtils.rm_rf("payload.jar")49FileUtils.rm_rf(@output_directory)50end5152def create_session_java53## Setup for win3254@framework = Msf::Simple::Framework.create5556test_modules_path = File.join(File.dirname(__FILE__), '..', '..', 'modules')57@framework.modules.add_module_path(test_modules_path)5859@exploit_name = 'test/java_tester'60@payload_name = 'java/meterpreter/bind_tcp'61@input = Rex::Ui::Text::Input::Stdio.new62@output = Rex::Ui::Text::Output::File.new(@default_file)6364# Initialize the exploit instance65exploit = @framework.exploits.create(@exploit_name)6667## Fire it off against a known-vulnerable host68@session = exploit.exploit_simple(69'Options' => {},70'Payload' => @payload_name,71'LocalInput' => @input,72'LocalOutput' => @output73)7475puts @session.inspect7677## If a session came back, try to interact with it.78if @session79@session.load_stdapi80else81raise Exception "Couldn't get a session!"82end83end84end85end868788