Class: Ronin::Exploits::CLI::ExploitCommand Private

Inherits:
Command
  • Object
show all
Includes:
ExploitMethods
Defined in:
lib/ronin/exploits/cli/exploit_command.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base class for all commands which load or run exploits.

Direct Known Subclasses

Commands::Run, Commands::Show

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exploitExploit? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The initialized exploit object.

Returns:



55
56
57
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 55

def exploit
  @exploit
end

#exploit_classClass<Exploit>? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The loaded exploit class.

Returns:



50
51
52
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 50

def exploit_class
  @exploit_class
end

Instance Method Details

#initialize_exploit(**kwargs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the exploit and sets #exploit.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Exploit#initialize.



98
99
100
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 98

def initialize_exploit(**kwargs)
  @exploit = super(@exploit_class,**kwargs)
end

#load_exploit(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the exploit and sets #exploit_class.

Parameters:

  • id (String)

    The exploit name to load.



78
79
80
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 78

def load_exploit(id)
  @exploit_class = super(id)
end

#load_exploit_from(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the exploit from the given file and sets #exploit_class.

Parameters:

  • file (String)

    The file to load the exploit from.



88
89
90
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 88

def load_exploit_from(file)
  @exploit_class = super(file)
end

#run(name = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the exploit.

Parameters:

  • name (String, nil) (defaults to: nil)

    The optional exploit name to load.



63
64
65
66
67
68
69
70
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 63

def run(name=nil)
  if    name           then load_exploit(name)
  elsif options[:file] then load_exploit_from(options[:file])
  else
    print_error "must specify --file or a NAME"
    exit(-1)
  end
end

#validate_exploitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validates the exploit.

Raises:

  • (Ronin::Core::Params::RequiredParam)

    One of the required params was not set.

  • (ValidationError)

    Another exploit validation error occurred.



111
112
113
# File 'lib/ronin/exploits/cli/exploit_command.rb', line 111

def validate_exploit
  super(@exploit)
end