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/tools/modules/solo.rb
Views: 11766
#!/usr/bin/env ruby12module Msf3module Modules4end5end67msfbase = __FILE__8while File.symlink?(msfbase)9msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))10end1112$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))1314require 'json'1516module_path = ARGV.shift1718# Usage when we don't have a module name19def usage(mod='MODULE_FILE', name='Run a module outside of Metasploit Framework')20$stderr.puts "Usage: solo.rb #{mod} [OPTIONS] [ACTION]"21$stderr.puts name22end2324def log_output(m)25message = m.params['message']2627sigil = case m.params['level']28when 'error', 'warning'29'!'30when 'good'31'+'32else33'*'34end3536$stderr.puts "[#{sigil}] #{message}"37end3839def process_report(m)40puts "[+] Found #{m.params['type']}: #{JSON.generate m.params['data']}"41end4243if !module_path || module_path[0] == '-'44usage45else46mod = Msf::Modules::External.new module_path47args, method = Msf::Modules::External::CLI.parse_options mod4849success = mod.exec(method: method, args: args) do |m|50begin51case m.method52when :message53log_output(m)54when :report55process_report(m)56when :reply57puts m.params['return']58end59rescue Interrupt => e60abort 'Exiting...'61rescue Exception => e62abort "Encountered an error: #{e.message}"63end64end6566abort 'Module exited abnormally' if !success67end686970