Module: Ronin::Exploits::CLI::ExploitMethods Private

Included in:
ExploitCommand
Defined in:
lib/ronin/exploits/cli/exploit_methods.rb

Overview

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

Mixin which adds methods for loading and running exploit classes.

Instance Method Summary collapse

Instance Method Details

#initialize_exploit(exploit_class, **kwargs) ⇒ Exploit

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 class.

Parameters:

  • exploit_class (Class<Exploit>)

    The encoder class.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Exploit#initialize.

Returns:

  • (Exploit)

    The initialized exploit object.



85
86
87
88
89
90
91
92
93
94
# File 'lib/ronin/exploits/cli/exploit_methods.rb', line 85

def initialize_exploit(exploit_class,**kwargs)
  exploit_class.new(**kwargs)
rescue Core::Params::ParamError => error
  print_error(error.message)
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while initializing exploit #{exploit_class.id}")
  exit(-1)
end

#load_exploit(name) ⇒ Class<Exploit>

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 a exploit class.

Parameters:

  • name (String)

    The exploit name to load.

Returns:

  • (Class<Exploit>)

    The loaded exploit class.



42
43
44
45
46
47
48
49
50
51
# File 'lib/ronin/exploits/cli/exploit_methods.rb', line 42

def load_exploit(name)
  Exploits.load_class(name)
rescue Exploits::ClassNotFound => error
  print_error(error.message)
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while loading exploit #{name}")
  exit(-1)
end

#load_exploit_from(file) ⇒ Class<Exploit>

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 a given file.

Parameters:

  • file (String)

    The file to load the exploit class from.

Returns:

  • (Class<Exploit>)

    The loaded exploit class.



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

def load_exploit_from(file)
  Exploits.load_class_from_file(file)
rescue Exploits::ClassNotFound => error
  print_error(error.message)
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while loading exploit from file #{file}")
  exit(-1)
end

#validate_exploit(exploit) ⇒ 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.

Validates the loaded exploit.

Parameters:

  • exploit (Exploit)

    The exploit to validate.

Raises:

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

    One of the required params was not set.

  • (ValidationError)

    Another exploit validation error occurred.



108
109
110
111
112
113
114
115
116
117
# File 'lib/ronin/exploits/cli/exploit_methods.rb', line 108

def validate_exploit(exploit)
  exploit.perform_validate
rescue Core::Params::ParamError, ValidationError => error
  print_error("failed to validate the exploit #{exploit.class_id}: #{error.message}")
  exit(1)
rescue => error
  print_exception(error)
  print_error("an unhandled exception occurred while validating the exploit #{exploit.class_id}")
  exit(-1)
end