Class: ExploitRunDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/metasploit/exploit_run_description.rb

Constant Summary collapse

@@port_value =
''
@@uri_value =
''
@@use_ssl_value =
''
@@device_ip_to_scan_value =
''
@@use_os_filter_value =
''

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ExploitRunDescription

Returns a new instance of ExploitRunDescription.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/metasploit/exploit_run_description.rb', line 26

def initialize(options)
  if File.file?('config/exploit.yml')
    options = YAML.load_file('config/exploit.yml')
  elsif options.instance_of? Array
    options = CommandLineArgumentParser.parse(options)
  end

  self.connection_url = options['connection_url']
  @@port_value = options['port']
  @@uri_value = options['uri']
  @@use_ssl_value = options['use_ssl']
  self.token = options['token']
  self.workspace_name = options['workspace_name']
  self.nexpose_console_name = options['nexpose_console_name']
  @@device_ip_to_scan_value = options['device_ip_to_scan']
  self.use_os_filter = options['use_os_filter']
  self.module_filter = options['module_filter']
  self.report_type = options['report_type']
  self.whitelist_hosts = options['whitelist_hosts']
  self.exploit_speed = options['exploit_speed'] || 5
  self.limit_sessions = options['limit_sessions'].nil? ? true : options['limit_sessions']
end

Instance Attribute Details

#connection_urlObject

Returns the value of attribute connection_url.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def connection_url
  @connection_url
end

#device_ip_to_scanObject

Returns the value of attribute device_ip_to_scan.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def device_ip_to_scan
  @device_ip_to_scan
end

#exploit_speedObject

Returns the value of attribute exploit_speed.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def exploit_speed
  @exploit_speed
end

#limit_sessionsObject

Returns the value of attribute limit_sessions.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def limit_sessions
  @limit_sessions
end

#module_filterObject

Returns the value of attribute module_filter.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def module_filter
  @module_filter
end

#nexpose_console_nameObject

Returns the value of attribute nexpose_console_name.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def nexpose_console_name
  @nexpose_console_name
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def port
  @port
end

#report_typeObject

Returns the value of attribute report_type.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def report_type
  @report_type
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def token
  @token
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def uri
  @uri
end

#use_os_filterObject

Returns the value of attribute use_os_filter.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def use_os_filter
  @use_os_filter
end

#use_sslObject

Returns the value of attribute use_ssl.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def use_ssl
  @use_ssl
end

#whitelist_hostsObject

Returns the value of attribute whitelist_hosts.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def whitelist_hosts
  @whitelist_hosts
end

#workspace_nameObject

Returns the value of attribute workspace_name.



5
6
7
# File 'lib/metasploit/exploit_run_description.rb', line 5

def workspace_name
  @workspace_name
end

Instance Method Details

#get_audit_optionsObject



72
73
74
75
76
77
78
79
# File 'lib/metasploit/exploit_run_description.rb', line 72

def get_audit_options
  { "workspace" => self.workspace_name,
    "DS_URLS" => self.device_ip_to_scan,
    "DS_MAX_REQUESTS" => 1000,
    "DS_MAX_MINUTES" => 3,
    "DS_MAX_THREADS" => 5,
    "DS_MAX_INSTANCES" => 3}
end

#get_exploit_optionsObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/metasploit/exploit_run_description.rb', line 81

def get_exploit_options
  { "workspace" => self.workspace_name,
    "DS_WHITELIST_HOSTS" => self.whitelist_hosts,
    "DS_MinimumRank" => "great",
    "DS_EXPLOIT_SPEED" => self.exploit_speed,
    "DS_EXPLOIT_TIMEOUT" => 2,
    "DS_LimitSessions" => self.limit_sessions,
    "DS_MATCH_VULNS" => true,
    "DS_MATCH_PORTS" => true,
    "DS_FilterByOS" => self.use_os_filter,
    "DS_ModuleFilter" => self.module_filter}
end

#get_optionsObject



56
57
58
59
60
61
62
63
64
# File 'lib/metasploit/exploit_run_description.rb', line 56

def get_options
  {:host => self.connection_url,
   :port => self.port,
   :token => self.token,
   :uri => self.uri,
   :ssl => self.use_ssl,
   :ssl_version => 'TLS1'
  }
end

#get_report_optionsObject



94
95
96
97
98
99
100
101
102
103
# File 'lib/metasploit/exploit_run_description.rb', line 94

def get_report_options
  {
      'workspace' => self.workspace_name,
      'name' => self.workspace_name,
      'report_type' => self.report_type,
      'created_by' => self.workspace_name,
      'file_formats' => [:pdf],
      'DS_WHITELIST_HOSTS' => self.device_ip_to_scan
  }
end

#get_value(value_to_check, default) ⇒ Object



153
154
155
# File 'lib/metasploit/exploit_run_description.rb', line 153

def get_value(value_to_check, default)
  (value_to_check.nil? || value_to_check.empty?) ? default : value_to_check
end

#to_bool(str) ⇒ Object



157
158
159
# File 'lib/metasploit/exploit_run_description.rb', line 157

def to_bool(str)
  str == true || str == 'true'
end

#verifyObject

Raises:

  • (StandardError)


49
50
51
52
53
54
# File 'lib/metasploit/exploit_run_description.rb', line 49

def verify
  raise StandardError, CONSTANTS::REQUIRED_TOKEN_MESSAGE if token.nil? || token.empty?
  raise StandardError, CONSTANTS::REQUIRED_CONNECTION_URL_MESSAGE if connection_url.nil? || connection_url.empty?
  raise StandardError, CONSTANTS::REQUIRED_DEVICE_IP_TO_SCAN_MESSAGE if device_ip_to_scan.nil? || device_ip_to_scan.empty?
  raise StandardError, CONSTANTS::REQUIRED_WORKSPACE_MESSAGE if workspace_name.nil? || workspace_name.empty?
end