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

Inherits:
Object
  • Object
show all
Includes:
ModuleCommandDispatcher
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

Class Method Summary collapse

Instance Method Summary collapse

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 Msf::Ui::Console::CommandDispatcher

#active_module, #active_module=, #active_session, #active_session=, #build_range_array, #docs_dir, #framework, #initialize, #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, #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, #update_prompt

Class Method Details

.choose_payload(mod) ⇒ Object

This is the same functionality as Exploit::choose_payload, so call it


90
91
92
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 90

def self.choose_payload(mod)
  Msf::Ui::Console::CommandDispatcher::Exploit.choose_payload(mod)
end

Instance Method Details

#cmd_exploit_tabs(str, words) ⇒ Object


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 53

def cmd_exploit_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                                               ]
  }
  tab_complete_generic(fmt, str, words)
end

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


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

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

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


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

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_to_handler(*_args) ⇒ Object


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/msf/ui/console/command_dispatcher/evasion.rb', line 69

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)
  handler.exploit_simple(handler_opts)
  job_id = handler.job_id

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

#commandsObject


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

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


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

def name
  'Evasion'
end