Class: Msf::Ui::Console::CommandDispatcher::Evasion

Inherits:
Object
  • Object
show all
Includes:
ModuleCommandDispatcher, ModuleOptionTabCompletion
Defined in:
lib/msf/ui/console/command_dispatcher/evasion.rb

Instance Attribute Summary

Attributes included from Msf::Ui::Console::CommandDispatcher

#driver

Attributes included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from ModuleOptionTabCompletion

#option_values_actions, #option_values_dispatch, #option_values_encoders, #option_values_nops, #option_values_payloads, #option_values_sessions, #option_values_target_addrs, #option_values_target_ports, #option_values_targets, #tab_complete_datastore_names, #tab_complete_module_datastore_names, #tab_complete_option, #tab_complete_option_names, #tab_complete_option_values, #tab_complete_source_interface

Methods included from ModuleCommandDispatcher

#check_multiple, #check_progress, #check_show_progress, #check_simple, #cmd_check, #cmd_check_help, #cmd_reload, #cmd_reload_help, #mod, #mod=, #reload, #report_vuln

Methods included from ModuleArgumentParsing

#append_datastore_option, #parse_check_opts, #parse_exploit_opts, #parse_opts, #parse_run_opts, #print_module_run_or_check_usage, #quote_whitespaced_value, #resembles_datastore_assignment?, #resembles_rhost_value?

Methods included from Msf::Ui::Console::CommandDispatcher

#active_module, #active_module=, #active_session, #active_session=, #build_range_array, #docs_dir, #framework, #initialize, #load_config, #log_error, #remove_lines

Methods included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, included, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt

Instance Method Details

#cmd_rerun(*args) ⇒ Object Also known as: cmd_rexploit



46
47
48
49
50
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 46

def cmd_rerun(*args)
  if reload(true)
    cmd_run(*args)
  end
end

#cmd_run(*args) ⇒ Object Also known as: cmd_exploit



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 25

def cmd_run(*args)
  opts = {
    'Encoder'    => mod.datastore['ENCODER'],
    'Payload'    => mod.datastore['PAYLOAD'],
    'Nop'        => mod.datastore['NOP'],
    'LocalInput' => driver.input,
    'LocalOutput' => driver.output
  }

  begin
    mod.run_simple(opts)
  rescue ::Interrupt
    print_error('Evasion interrupted by the console user')
  rescue ::Exception => e
    print_error("Evasion failed: #{e.class} #{e}")
    elog('Evasion Failed', error: e)
  end
end

#cmd_run_tabs(str, words) ⇒ Object Also known as: cmd_exploit_tabs

Tab completion for the run command



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 57

def cmd_run_tabs(str, words)
  fmt = {
      '-e' => [ framework.encoders.map { |refname, mod| refname } ],
      '-f' => [ nil                                               ],
      '-h' => [ nil                                               ],
      '-j' => [ nil                                               ],
      '-J' => [ nil                                               ],
      '-n' => [ framework.nops.map { |refname, mod| refname }     ],
      '-o' => [ true                                              ],
      '-p' => [ framework.payloads.map { |refname, mod| refname } ],
      '-t' => [ true                                              ],
      '-z' => [ nil                                               ]
  }
  flags = tab_complete_generic(fmt, str, words)
  options = tab_complete_option(active_module, str, words)
  flags + options
end

#cmd_to_handler(*_args) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 80

def cmd_to_handler(*_args)
  handler = framework.modules.create('exploit/multi/handler')

  handler_opts = {
    'Payload'     => mod.datastore['PAYLOAD'],
    'LocalInput'  => driver.input,
    'LocalOutput' => driver.output,
    'RunAsJob'    => true,
    'Options'     => {
      'ExitOnSession' => false,
    }
  }

  handler.share_datastore(mod.datastore)

  replicant_handler = nil
  handler.exploit_simple(handler_opts) do |yielded_replicant_handler|
    replicant_handler = yielded_replicant_handler
  end

  if replicant_handler.nil?
    print_error('Failed to run module')
    return
  end

  if replicant_handler.error.nil?
    job_id = handler.job_id

    print_status "Payload Handler Started as Job #{job_id}"
  end
end

#commandsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 10

def commands
  super.update({
    'run'        => 'Launches the evasion module',
    'rerun'      => 'Reloads and launches the evasion module',
    'exploit'    => 'This is an alias for the run command',
    'rexploit'   => 'This is an alias for the rerun command',
    'reload'     => 'Reloads the auxiliary module',
    'to_handler' => 'Creates a handler with the specified payload'
  }).merge(mod ? mod.evasion_commands : {})
end

#nameObject



21
22
23
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 21

def name
  'Evasion'
end