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/msf-json-rpc.ru
Views: 11655
# msf-json-rpc.ru1# Start using thin:2# thin --rackup msf-json-rpc.ru --address localhost --port 8081 --environment development --tag msf-json-rpc start3#45require 'pathname'6@framework_path = File.expand_path(File.dirname(__FILE__))7root = Pathname.new(@framework_path).expand_path8@framework_lib_path = root.join('lib')9$LOAD_PATH << @framework_lib_path.to_path unless $LOAD_PATH.include?(@framework_lib_path)1011require 'msfenv'1213if ENV['MSF_LOCAL_LIB']14$LOAD_PATH << ENV['MSF_LOCAL_LIB'] unless $LOAD_PATH.include?(ENV['MSF_LOCAL_LIB'])15end1617run Msf::WebServices::JsonRpcApp1819#20# Ensure that framework is loaded before any external requests can be routed to the running21# application. This stops the possibility of the rack application being alive, but all22# requests failing.23#24warmup do |app|25client = Rack::MockRequest.new(app)26response = client.get('/api/v1/health')2728warmup_error_message = "Metasploit JSON RPC did not successfully start up. Unexpected response returned: '#{response.body}'"29begin30parsed_response = JSON.parse(response.body)31rescue JSON::ParserError => e32raise warmup_error_message, e33end3435expected_response = { 'data' => { 'status' => 'UP' } }36is_valid_response = parsed_response == expected_response3738unless is_valid_response39raise warmup_error_message40end41end424344