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.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/metasploit/exploit_run_description.rb', line 23

def initialize(options)
  if File.file?('config/exploit.yml')
    options = YAML.load_file('config/exploit.yml')
  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']
end

Instance Attribute Details

#connection_urlObject

Returns the value of attribute connection_url.



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

def connection_url
  @connection_url
end

#device_ip_to_scanObject

Returns the value of attribute device_ip_to_scan.



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

def device_ip_to_scan
  @device_ip_to_scan
end

#module_filterObject

Returns the value of attribute module_filter.



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

def module_filter
  @module_filter
end

#nexpose_console_nameObject

Returns the value of attribute nexpose_console_name.



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

def nexpose_console_name
  @nexpose_console_name
end

#portObject

Returns the value of attribute port.



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

def port
  @port
end

#report_typeObject

Returns the value of attribute report_type.



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

def report_type
  @report_type
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

#use_os_filterObject

Returns the value of attribute use_os_filter.



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

def use_os_filter
  @use_os_filter
end

#use_sslObject

Returns the value of attribute use_ssl.



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

def use_ssl
  @use_ssl
end

#whitelist_hostsObject

Returns the value of attribute whitelist_hosts.



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

def whitelist_hosts
  @whitelist_hosts
end

#workspace_nameObject

Returns the value of attribute workspace_name.



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

def workspace_name
  @workspace_name
end

Instance Method Details

#get_audit_optionsObject



64
65
66
67
68
69
70
71
# File 'lib/metasploit/exploit_run_description.rb', line 64

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



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/metasploit/exploit_run_description.rb', line 73

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

#get_optionsObject



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

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



86
87
88
89
90
91
92
93
94
95
# File 'lib/metasploit/exploit_run_description.rb', line 86

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



145
146
147
# File 'lib/metasploit/exploit_run_description.rb', line 145

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

#to_bool(str) ⇒ Object



149
150
151
# File 'lib/metasploit/exploit_run_description.rb', line 149

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

#verifyObject

Raises:

  • (StandardError)


41
42
43
44
45
46
# File 'lib/metasploit/exploit_run_description.rb', line 41

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