require 'msf/core/modules/external/bridge'
require 'msf/core/module/external'

class MetasploitModule < Msf::Exploit::Remote
  Rank = <%= meta[:rank] %>

  include Msf::Module::External
  include Msf::Exploit::CmdStager

  def initialize(info = {})
    super(update_info(info,
      <%= common_metadata meta, default_options: { 'WfsDelay' => meta[:wfsdelay] }  %>
      'References'  =>
        [
          <%= meta[:references] %>
        ],
      'DisclosureDate' => <%= meta[:date] %>,
      'Privileged'     => <%= meta[:privileged] %>,
      'Platform'       => [<%= meta[:platform] %>],
      'Arch'           => [<%= meta[:arch] %>],
      'Targets'        =>
        [
          <%= meta[:targets] %>
        ],
      'DefaultTarget'  => 0,
      ))

      register_options([
        <%= meta[:options] %>
      ])
  end

  <%= common_check meta %>

  def execute_command(cmd, opts)
    execute_module(<%= meta[:path] %>, args: datastore.merge(command: cmd))
  end

  def exploit
    print_status("Exploiting...")
    execute_cmdstager({:flavor  => :<%= meta[:command_stager_flavor] %>})
  end
end
