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_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_generate(*args) ⇒ Object

Generates a NOP sled.



42
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 42

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.dehex(val)
when "-s", "-c"  # 'c' is deprecated; remove later
saveregs = val.split(/,\s?/)
        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.



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

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

#nameObject

Returns the name of the command dispatcher.



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

def name
  "Nop"
end