Class: Msf::Ui::Console::CommandDispatcher::Nop

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

Overview

NOP module command dispatcher.

Constant Summary collapse

@@generate_opts =
Rex::Parser::Arguments.new(
"-b" => [ true,  "The list of characters to avoid: '\\x00\\xff'"  ],
"-h" => [ false, "Help banner."                                   ],
"-s" => [ true,  "The comma separated list of registers to save." ],
"-t" => [ true,  "The output type: ruby, perl, c, or raw."        ])

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 ModuleCommandDispatcher

#check_multiple, #check_progress, #check_show_progress, #check_simple, #cmd_check, #cmd_pry, #cmd_pry_help, #cmd_reload, #cmd_reload_help, #mod, #mod=, #reload

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

#active_module, #active_module=, #active_session, #active_session=, #defanged?, #framework, #initialize, #log_error

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

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #help_to_s, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_filenames, #update_prompt

Instance Method Details

#cmd_generate(*args) ⇒ Object

Generates a NOP sled.


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/msf/ui/console/command_dispatcher/nop.rb', line 43

def cmd_generate(*args)

  # No arguments?  Tell them how to use it.
  if (args.length == 0)
    args << "-h"
  end

  # Parse the arguments
  badchars = nil
  saveregs = nil
  type     = "ruby"
  length   = 200

  @@generate_opts.parse(args) { |opt, idx, val|
    case opt
      when nil
        length = val.to_i
      when '-b'
        badchars = Rex::Text.hex_to_raw(val)
      when "-c"
        saveregs = val.split(/,\s?/)
      when '-t'
        type = val
      when '-h'
        print(
          "Usage: generate [options] length\n\n" +
          "Generates a NOP sled of a given length.\n" +
          @@generate_opts.usage)
        return false
    end
  }

  # Generate the sled
  begin
    sled = mod.generate_simple(
      length,
      'BadChars'      => badchars,
      'SaveRegisters' => saveregs,
      'Format'        => type)
  rescue
    log_error("Sled generation failed: #{$!}.")
    return false
  end

  # Display generated sled
  print(sled)

  return true
end

#commandsObject

Returns the hash of supported commands.


27
28
29
30
31
# File 'lib/msf/ui/console/command_dispatcher/nop.rb', line 27

def commands
  super.update({
    "generate" => "Generates a NOP sled",
  })
end

#nameObject

Returns the name of the command dispatcher.


36
37
38
# File 'lib/msf/ui/console/command_dispatcher/nop.rb', line 36

def name
  "Nop"
end