Class: Nexpose::Credential
- Inherits:
-
Object
- Object
- Nexpose::Credential
- Defined in:
- lib/nexpose/credential.rb
Overview
Contains the shared methods for the SiteCredential and SharedCredential Objects. See Nexpose::SiteCredential or Nexpose::SharedCredential for additional info.
Direct Known Subclasses
Defined Under Namespace
Modules: ElevationType, Service
Constant Summary collapse
- DEFAULT_PORTS =
Mapping of Common Ports.
{ 'cvs' => 2401, 'ftp' => 21, 'http' => 80, 'as400' => 449, 'notes' => 1352, 'tds' => 1433, 'sybase' => 5000, 'cifs' => 445, 'cifshash' => 445, 'oracle' => 1521, 'pop' => 110, 'postgresql' => 5432, 'remote execution' => 512, 'snmp' => 161, 'snmpv3' => 161, 'ssh' => 22, 'ssh-key' => 22, 'telnet' => 23, 'mysql' => 3306, 'db2' => 50000 }
Instance Method Summary collapse
- #_to_param(target, engine_id, port, siteid) ⇒ Object
-
#test(nsc, target, engine_id = nil, siteid = -1)) ⇒ Object
Test this credential against a target where the credentials should apply.
Instance Method Details
#_to_param(target, engine_id, port, siteid) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/nexpose/credential.rb', line 86 def _to_param(target, engine_id, port, siteid) { engineid: engine_id, sc_creds_dev: target, sc_creds_svc: @service, sc_creds_database: @database, sc_creds_domain: @domain, sc_creds_uname: @username, sc_creds_password: @password, sc_creds_pemkey: @pem_key, sc_creds_port: port, sc_creds_privilegeelevationusername: @privilege_username, sc_creds_privilegeelevationpassword: @privilege_password, sc_creds_privilegeelevationtype: @privilege_type, sc_creds_snmpv3authtype: @auth_type, sc_creds_snmpv3privtype: @privacy_type, sc_creds_snmpv3privpassword: @privacy_password, siteid: siteid } end |
#test(nsc, target, engine_id = nil, siteid = -1)) ⇒ Object
Test this credential against a target where the credentials should apply. Only works for a newly created credential. Loading an existing credential will likely fail.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/nexpose/credential.rb', line 74 def test(nsc, target, engine_id = nil, siteid = -1) unless engine_id engine_id = nsc.engines.find { |e| e.name == 'Local scan engine' }.id end @port = Credential::DEFAULT_PORTS[@service] if @port.nil? parameters = _to_param(target, engine_id, @port, siteid) xml = AJAX.form_post(nsc, '/ajax/test_admin_credentials.txml', parameters) result = REXML::XPath.first(REXML::Document.new(xml), 'TestAdminCredentialsResult') result.attributes['success'].to_i == 1 end |