nexpose 6.1.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +772 -0
- data/COPYING +27 -31
- data/Gemfile.lock +72 -30
- data/README.markdown +3 -1
- data/Rakefile +9 -0
- data/lib/nexpose.rb +1 -0
- data/lib/nexpose/ajax.rb +8 -6
- data/lib/nexpose/api_request.rb +27 -26
- data/lib/nexpose/connection.rb +28 -20
- data/lib/nexpose/credential.rb +16 -218
- data/lib/nexpose/credential_helper.rb +169 -0
- data/lib/nexpose/dag.rb +3 -3
- data/lib/nexpose/filter.rb +3 -1
- data/lib/nexpose/scan.rb +5 -1
- data/lib/nexpose/shared_credential.rb +13 -5
- data/lib/nexpose/site_credentials.rb +55 -9
- data/lib/nexpose/version.rb +1 -1
- metadata +32 -2
data/lib/nexpose/credential.rb
CHANGED
@@ -3,6 +3,7 @@ module Nexpose
|
|
3
3
|
# Contains the shared methods for the SiteCredential and SharedCredential Objects.
|
4
4
|
# See Nexpose::SiteCredential or Nexpose::SharedCredential for additional info.
|
5
5
|
class Credential < APIObject
|
6
|
+
include Nexpose::CredentialHelper
|
6
7
|
|
7
8
|
# Mapping of Common Ports.
|
8
9
|
DEFAULT_PORTS = { 'cvs' => 2401,
|
@@ -24,14 +25,13 @@ module Nexpose
|
|
24
25
|
'ssh-key' => 22,
|
25
26
|
'telnet' => 23,
|
26
27
|
'mysql' => 3306,
|
27
|
-
'db2' =>
|
28
|
-
|
28
|
+
'db2' => 50_000 }
|
29
29
|
|
30
30
|
# Credential scope
|
31
31
|
module Scope
|
32
|
-
ALL_SITES_ENABLED_DEFAULT
|
32
|
+
ALL_SITES_ENABLED_DEFAULT = 'A'
|
33
33
|
ALL_SITES_DISABLED_DEFAULT = 'G'
|
34
|
-
SITE_SPECIFIC
|
34
|
+
SITE_SPECIFIC = 'S'
|
35
35
|
end
|
36
36
|
|
37
37
|
# Credential Service/Type Options.
|
@@ -58,7 +58,6 @@ module Nexpose
|
|
58
58
|
DB2 = 'db2' # DB2
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
61
|
# Permission Elevation / Privilege Escalation Types.
|
63
62
|
module ElevationType
|
64
63
|
NONE = 'NONE'
|
@@ -66,227 +65,26 @@ module Nexpose
|
|
66
65
|
SUDOSU = 'SUDOSU'
|
67
66
|
SU = 'SU'
|
68
67
|
PBRUN = 'PBRUN'
|
68
|
+
ENABLE = 'PRIVILEGEDEXEC' # Cisco Enable/ Privileged Exec
|
69
69
|
end
|
70
70
|
|
71
|
-
#Authentication type for SNMP version 3
|
71
|
+
# Authentication type for SNMP version 3
|
72
72
|
module AuthenticationType
|
73
|
-
NOAUTH = 'noauth'
|
74
|
-
SHA
|
75
|
-
MD5
|
73
|
+
NOAUTH = 'noauth' # No authentication protocol
|
74
|
+
SHA = 'sha' # SHA authentication protocol
|
75
|
+
MD5 = 'md5' # MD5 authentication protocol
|
76
76
|
end
|
77
77
|
|
78
78
|
# PrivacyType for snmp version 3
|
79
79
|
module PrivacyType
|
80
|
-
NOPRIV
|
81
|
-
DES
|
82
|
-
AES128
|
83
|
-
AES192
|
84
|
-
AES192WITH3DESKEYEXTENSION = 'aes192with3deskeyextension'
|
85
|
-
AES256
|
86
|
-
AES265WITH3DESKEYEXTENSION = 'aes265with3deskeyextension'
|
87
|
-
end
|
88
|
-
# Test this credential against a target where the credentials should apply.
|
89
|
-
# Only works for a newly created credential. Loading an existing credential
|
90
|
-
# will likely fail.
|
91
|
-
#
|
92
|
-
# @param [Connection] nsc An active connection to the security console.
|
93
|
-
# @param [String] target Target host to check credentials against.
|
94
|
-
# @param [Fixnum] engine_id ID of the engine to use for testing credentials.
|
95
|
-
# Will default to the local engine if none is provided.
|
96
|
-
#
|
97
|
-
def test(nsc, target, engine_id = nil, siteid = -1)
|
98
|
-
unless engine_id
|
99
|
-
engine_id = nsc.engines.find { |e| e.name == 'Local scan engine' }.id
|
100
|
-
end
|
101
|
-
@port = Credential::DEFAULT_PORTS[@service] if @port.nil?
|
102
|
-
parameters = _to_param(target, engine_id, @port, siteid)
|
103
|
-
xml = AJAX.form_post(nsc, '/data/credential/shared/test', parameters)
|
104
|
-
result = REXML::XPath.first(REXML::Document.new(xml), 'TestAdminCredentialsResult')
|
105
|
-
result.attributes['success'].to_i == 1
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
def _to_param(target, engine_id, port, siteid)
|
110
|
-
{ engineid: engine_id,
|
111
|
-
sc_creds_dev: target,
|
112
|
-
sc_creds_svc: @service,
|
113
|
-
sc_creds_database: @database,
|
114
|
-
sc_creds_domain: @domain,
|
115
|
-
sc_creds_uname: @user_name,
|
116
|
-
sc_creds_password: @password,
|
117
|
-
sc_creds_pemkey: @pem_format_private_key,
|
118
|
-
sc_creds_port: port,
|
119
|
-
sc_creds_privilegeelevationusername: @permission_elevation_user,
|
120
|
-
sc_creds_privilegeelevationpassword: @permission_elevation_password,
|
121
|
-
sc_creds_privilegeelevationtype: @permission_elevation_type,
|
122
|
-
sc_creds_snmpv3authtype: @authentication_type,
|
123
|
-
sc_creds_snmpv3privtype: @privacy_type,
|
124
|
-
sc_creds_snmpv3privpassword: @privacy_password,
|
125
|
-
siteid: siteid }
|
126
|
-
end
|
127
|
-
|
128
|
-
# sets the Concurrent Versioning System (CVS) service
|
129
|
-
def set_cvs_service(username = nil, password = nil)
|
130
|
-
@user_name = username
|
131
|
-
@password = password
|
132
|
-
@service = Service::CVS
|
133
|
-
end
|
134
|
-
|
135
|
-
# sets the DB2 service
|
136
|
-
def set_db2_service(database = nil, username = nil, password = nil)
|
137
|
-
@database = database
|
138
|
-
@user_name = username
|
139
|
-
@password = password
|
140
|
-
@service = Service::DB2
|
141
|
-
end
|
142
|
-
|
143
|
-
# sets the File Transfer Protocol (FTP) service
|
144
|
-
def set_ftp_service(username = nil, password = nil)
|
145
|
-
@user_name = username
|
146
|
-
@password = password
|
147
|
-
@service = Service::FTP
|
148
|
-
end
|
149
|
-
|
150
|
-
# sets the IBM AS/400 service.
|
151
|
-
def set_as400_service(domain = nil, username = nil, password = nil)
|
152
|
-
@domain = domain
|
153
|
-
@user_name = username
|
154
|
-
@password = password
|
155
|
-
@service = Service::AS400
|
156
|
-
end
|
157
|
-
|
158
|
-
# sets the Lotus Notes/Domino service.
|
159
|
-
def set_notes_service(password = nil)
|
160
|
-
@notes_id_password = password
|
161
|
-
@service = Service::NOTES
|
162
|
-
end
|
163
|
-
|
164
|
-
# sets the Microsoft SQL Server service.
|
165
|
-
def set_tds_service(database = nil, domain = nil, username = nil, password = nil)
|
166
|
-
@database = database
|
167
|
-
@domain = domain
|
168
|
-
@use_windows_auth = domain.nil?
|
169
|
-
@user_name = username
|
170
|
-
@password = password
|
171
|
-
@service = Service::TDS
|
172
|
-
end
|
173
|
-
|
174
|
-
# sets the Microsoft Windows/Samba (SMB/CIFS) service.
|
175
|
-
def set_cifs_service(domain = nil, username = nil, password = nil)
|
176
|
-
@domain = domain
|
177
|
-
@user_name = username
|
178
|
-
@password = password
|
179
|
-
@service = Service::CIFS
|
180
|
-
end
|
181
|
-
|
182
|
-
# sets the Microsoft Windows/Samba LM/NTLM Hash (SMB/CIFS) service.
|
183
|
-
def set_cifshash_service(domain = nil, username = nil, password = nil)
|
184
|
-
@domain = domain
|
185
|
-
@user_name = username
|
186
|
-
@password = password
|
187
|
-
@service = Service::CIFSHASH
|
188
|
-
end
|
189
|
-
|
190
|
-
# sets the MySQL Server service.
|
191
|
-
def set_mysql_service(database = nil, username = nil, password = nil)
|
192
|
-
@database = database
|
193
|
-
@user_name = username
|
194
|
-
@password = password
|
195
|
-
@service = Service::MYSQL
|
80
|
+
NOPRIV = 'nopriv' # No privacy protocol
|
81
|
+
DES = 'des' # DES privacy protocol
|
82
|
+
AES128 = 'aes128' # AES128 privacy protocol
|
83
|
+
AES192 = 'aes192' # AES192 privacy protocol
|
84
|
+
AES192WITH3DESKEYEXTENSION = 'aes192with3deskeyextension' # AES192 with 3 DES key extension privacy protocol
|
85
|
+
AES256 = 'aes256' # AES256 privacy protocol
|
86
|
+
AES265WITH3DESKEYEXTENSION = 'aes265with3deskeyextension' # AES256 with 3 DES key extension privacy protocol
|
196
87
|
end
|
197
88
|
|
198
|
-
# sets the Oracle service.
|
199
|
-
def set_oracle_service(sid = nil, username = nil, password = nil)
|
200
|
-
@database = sid
|
201
|
-
@user_name = username
|
202
|
-
@password = password
|
203
|
-
@service = Service::ORACLE
|
204
|
-
end
|
205
|
-
|
206
|
-
# sets the Post Office Protocol (POP) service.
|
207
|
-
def set_pop_service(username = nil, password = nil)
|
208
|
-
@user_name = username
|
209
|
-
@password = password
|
210
|
-
@service = Service::POP
|
211
|
-
end
|
212
|
-
|
213
|
-
# sets the PostgreSQL service.
|
214
|
-
def set_postgresql_service(database = nil, username = nil, password = nil)
|
215
|
-
@database = database
|
216
|
-
@user_name = username
|
217
|
-
@password = password
|
218
|
-
@service = Service::POSTGRESQL
|
219
|
-
end
|
220
|
-
|
221
|
-
# sets the Remote Execution service.
|
222
|
-
def set_remote_execution_service(username = nil, password = nil)
|
223
|
-
@user_name = username
|
224
|
-
@password = password
|
225
|
-
@service = Service::REMOTE_EXECUTION
|
226
|
-
end
|
227
|
-
|
228
|
-
# sets the Secure Shell (SSH) service.
|
229
|
-
def set_ssh_service(username = nil, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)
|
230
|
-
@user_name = username
|
231
|
-
@password = password
|
232
|
-
@permission_elevation_type = elevation_type || ElevationType::NONE
|
233
|
-
@permission_elevation_user = elevation_user
|
234
|
-
@permission_elevation_password = elevation_password
|
235
|
-
@service = Service::SSH
|
236
|
-
end
|
237
|
-
|
238
|
-
# sets the Secure Shell (SSH) Public Key service.
|
239
|
-
def set_ssh_key_service(username, pemkey, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)
|
240
|
-
@user_name = username
|
241
|
-
@password = password
|
242
|
-
@pem_format_private_key = pemkey
|
243
|
-
@permission_elevation_type = elevation_type || ElevationType::NONE
|
244
|
-
@permission_elevation_user = elevation_user
|
245
|
-
@permission_elevation_password = elevation_password
|
246
|
-
@service = Service::SSH_KEY
|
247
|
-
end
|
248
|
-
|
249
|
-
# sets the Simple Network Management Protocol v1/v2c service.
|
250
|
-
def set_snmp_service(community_name = nil)
|
251
|
-
@community_name = community_name
|
252
|
-
@service = Service::SNMP
|
253
|
-
end
|
254
|
-
|
255
|
-
# sets the Simple Network Management Protocol v3 service.
|
256
|
-
def set_snmpv3_service(authentication_type = AuthenticationType::NOAUTH, username = nil, password = nil, privacy_type = PrivacyType::NOPRIV, privacy_password = nil)
|
257
|
-
@authentication_type = authentication_type
|
258
|
-
@user_name = username
|
259
|
-
@password = password
|
260
|
-
@privacy_type = privacy_type
|
261
|
-
@privacy_password = privacy_password
|
262
|
-
@service = Service::SNMPV3
|
263
|
-
end
|
264
|
-
|
265
|
-
# sets the Sybase SQL Server service.
|
266
|
-
def set_sybase_service(database = nil, domain = nil, username = nil, password = nil)
|
267
|
-
@database = database
|
268
|
-
@domain = domain
|
269
|
-
@use_windows_auth = domain.nil?
|
270
|
-
@user_name = username
|
271
|
-
@password = password
|
272
|
-
@service = Service::SYBASE
|
273
|
-
end
|
274
|
-
|
275
|
-
# sets the Telnet service.
|
276
|
-
def set_telnet_service(username = nil, password = nil)
|
277
|
-
@user_name = username
|
278
|
-
@password = password
|
279
|
-
@service = Service::TELNET
|
280
|
-
end
|
281
|
-
|
282
|
-
# sets the Web Site HTTP Authentication service.
|
283
|
-
def set_http_service(domain = nil, username = nil, password = nil)
|
284
|
-
@domain = domain
|
285
|
-
@user_name = username
|
286
|
-
@password = password
|
287
|
-
@service = Service::HTTP
|
288
|
-
end
|
289
89
|
end
|
290
|
-
|
291
|
-
|
292
90
|
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nexpose
|
4
|
+
module CredentialHelper
|
5
|
+
|
6
|
+
# sets the Concurrent Versioning System (CVS) service
|
7
|
+
def set_cvs_service(username = nil, password = nil)
|
8
|
+
self.user_name = username
|
9
|
+
self.password = password
|
10
|
+
self.service = Credential::Service::CVS
|
11
|
+
end
|
12
|
+
|
13
|
+
# sets the DB2 service
|
14
|
+
def set_db2_service(database = nil, username = nil, password = nil)
|
15
|
+
self.database = database
|
16
|
+
self.user_name = username
|
17
|
+
self.password = password
|
18
|
+
self.service = Credential::Service::DB2
|
19
|
+
end
|
20
|
+
|
21
|
+
# sets the File Transfer Protocol (FTP) service
|
22
|
+
def set_ftp_service(username = nil, password = nil)
|
23
|
+
self.user_name = username
|
24
|
+
self.password = password
|
25
|
+
self.service = Credential::Service::FTP
|
26
|
+
end
|
27
|
+
|
28
|
+
# sets the IBM AS/400 service.
|
29
|
+
def set_as400_service(domain = nil, username = nil, password = nil)
|
30
|
+
self.domain = domain
|
31
|
+
self.user_name = username
|
32
|
+
self.password = password
|
33
|
+
self.service = Credential::Service::AS400
|
34
|
+
end
|
35
|
+
|
36
|
+
# sets the Lotus Notes/Domino service.
|
37
|
+
def set_notes_service(password = nil)
|
38
|
+
self.notes_id_password = password
|
39
|
+
self.service = Credential::Service::NOTES
|
40
|
+
end
|
41
|
+
|
42
|
+
# sets the Microsoft SQL Server service.
|
43
|
+
def set_tds_service(database = nil, domain = nil, username = nil, password = nil)
|
44
|
+
self.database = database
|
45
|
+
self.domain = domain
|
46
|
+
self.use_windows_auth = domain.nil?
|
47
|
+
self.user_name = username
|
48
|
+
self.password = password
|
49
|
+
self.service = Credential::Service::TDS
|
50
|
+
end
|
51
|
+
|
52
|
+
# sets the Microsoft Windows/Samba (SMB/CIFS) service.
|
53
|
+
def set_cifs_service(domain = nil, username = nil, password = nil)
|
54
|
+
self.domain = domain
|
55
|
+
self.user_name = username
|
56
|
+
self.password = password
|
57
|
+
self.service = Credential::Service::CIFS
|
58
|
+
end
|
59
|
+
|
60
|
+
# sets the Microsoft Windows/Samba LM/NTLM Hash (SMB/CIFS) service.
|
61
|
+
def set_cifshash_service(domain = nil, username = nil, password = nil)
|
62
|
+
self.domain = domain
|
63
|
+
self.user_name = username
|
64
|
+
self.password = password
|
65
|
+
self.service = Credential::Service::CIFSHASH
|
66
|
+
end
|
67
|
+
|
68
|
+
# sets the MySQL Server service.
|
69
|
+
def set_mysql_service(database = nil, username = nil, password = nil)
|
70
|
+
self.database = database
|
71
|
+
self.user_name = username
|
72
|
+
self.password = password
|
73
|
+
self.service = Credential::Service::MYSQL
|
74
|
+
end
|
75
|
+
|
76
|
+
# sets the Oracle service.
|
77
|
+
def set_oracle_service(sid = nil, username = nil, password = nil)
|
78
|
+
self.database = sid
|
79
|
+
self.user_name = username
|
80
|
+
self.password = password
|
81
|
+
self.service = Credential::Service::ORACLE
|
82
|
+
end
|
83
|
+
|
84
|
+
# sets the Post Office Protocol (POP) service.
|
85
|
+
def set_pop_service(username = nil, password = nil)
|
86
|
+
self.user_name = username
|
87
|
+
self.password = password
|
88
|
+
self.service = Credential::Service::POP
|
89
|
+
end
|
90
|
+
|
91
|
+
# sets the PostgreSQL service.
|
92
|
+
def set_postgresql_service(database = nil, username = nil, password = nil)
|
93
|
+
self.database = database
|
94
|
+
self.user_name = username
|
95
|
+
self.password = password
|
96
|
+
self.service = Credential::Service::POSTGRESQL
|
97
|
+
end
|
98
|
+
|
99
|
+
# sets the Remote Execution service.
|
100
|
+
def set_remote_execution_service(username = nil, password = nil)
|
101
|
+
self.user_name = username
|
102
|
+
self.password = password
|
103
|
+
self.service = Credential::Service::REMOTE_EXECUTION
|
104
|
+
end
|
105
|
+
|
106
|
+
# sets the Secure Shell (SSH) service.
|
107
|
+
def set_ssh_service(username = nil, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)
|
108
|
+
self.user_name = username
|
109
|
+
self.password = password
|
110
|
+
self.permission_elevation_type = elevation_type || Credential::ElevationType::NONE
|
111
|
+
self.permission_elevation_user = elevation_user
|
112
|
+
self.permission_elevation_password = elevation_password
|
113
|
+
self.service = Credential::Service::SSH
|
114
|
+
end
|
115
|
+
|
116
|
+
# sets the Secure Shell (SSH) Public Key service.
|
117
|
+
def set_ssh_key_service(username, pemkey, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)
|
118
|
+
self.user_name = username
|
119
|
+
self.password = password
|
120
|
+
self.pem_format_private_key = pemkey
|
121
|
+
self.permission_elevation_type = elevation_type || Credential::ElevationType::NONE
|
122
|
+
self.permission_elevation_user = elevation_user
|
123
|
+
self.permission_elevation_password = elevation_password
|
124
|
+
self.service = Credential::Service::SSH_KEY
|
125
|
+
end
|
126
|
+
|
127
|
+
# sets the Simple Network Management Protocol v1/v2c service.
|
128
|
+
def set_snmp_service(community_name = nil)
|
129
|
+
self.community_name = community_name
|
130
|
+
self.service = Credential::Service::SNMP
|
131
|
+
end
|
132
|
+
|
133
|
+
# sets the Simple Network Management Protocol v3 service.
|
134
|
+
def set_snmpv3_service(authentication_type = Credential::AuthenticationType::NOAUTH, username = nil, password = nil, privacy_type = Credential::PrivacyType::NOPRIV, privacy_password = nil)
|
135
|
+
self.authentication_type = authentication_type
|
136
|
+
self.user_name = username
|
137
|
+
self.password = password
|
138
|
+
self.privacy_type = privacy_type
|
139
|
+
self.privacy_password = privacy_password
|
140
|
+
self.service = Credential::Service::SNMPV3
|
141
|
+
end
|
142
|
+
|
143
|
+
# sets the Sybase SQL Server service.
|
144
|
+
def set_sybase_service(database = nil, domain = nil, username = nil, password = nil)
|
145
|
+
self.database = database
|
146
|
+
self.domain = domain
|
147
|
+
self.use_windows_auth = domain.nil?
|
148
|
+
self.user_name = username
|
149
|
+
self.password = password
|
150
|
+
self.service = Credential::Service::SYBASE
|
151
|
+
end
|
152
|
+
|
153
|
+
# sets the Telnet service.
|
154
|
+
def set_telnet_service(username = nil, password = nil)
|
155
|
+
self.user_name = username
|
156
|
+
self.password = password
|
157
|
+
self.service = Credential::Service::TELNET
|
158
|
+
end
|
159
|
+
|
160
|
+
# sets the Web Site HTTP Authentication service.
|
161
|
+
def set_http_service(domain = nil, username = nil, password = nil)
|
162
|
+
self.domain = domain
|
163
|
+
self.user_name = username
|
164
|
+
self.password = password
|
165
|
+
self.service = Credential::Service::HTTP
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
data/lib/nexpose/dag.rb
CHANGED
@@ -31,7 +31,7 @@ module Nexpose
|
|
31
31
|
# load includes admin users, but save will fail if they are included.
|
32
32
|
admins = nsc.users.select { |u| u.is_admin }.map { |u| u.id }
|
33
33
|
@users.reject! { |id| admins.member? id }
|
34
|
-
params = @id ? { 'entityid' => @id, 'mode' => 'edit' } : { 'entityid' => false, 'mode' => false }
|
34
|
+
params = @id ? { 'entityid' => @id, 'mode' => 'edit' } : { 'entityid' => false, 'mode' => false }
|
35
35
|
uri = AJAX.parameterize_uri('/data/assetGroup/saveAssetGroup', params)
|
36
36
|
data = JSON.parse(AJAX.post(nsc, uri, _to_entity_details, AJAX::CONTENT_TYPE::JSON))
|
37
37
|
data['response'] == 'success.'
|
@@ -47,7 +47,7 @@ module Nexpose
|
|
47
47
|
json = JSON.parse(AJAX.get(nsc, "/data/assetGroup/loadAssetGroup?entityid=#{id}"))
|
48
48
|
raise APIError.new(json, json['message']) if json['response'] =~ /failure/
|
49
49
|
raise ArgumentError.new('Not a dynamic asset group.') unless json['dynamic']
|
50
|
-
dag = new(json['name'], Criteria.parse(json['searchCriteria']), json['
|
50
|
+
dag = new(json['name'], Criteria.parse(json['searchCriteria']), json['description'])
|
51
51
|
dag.id = id
|
52
52
|
dag.users = json['users']
|
53
53
|
dag
|
@@ -56,7 +56,7 @@ module Nexpose
|
|
56
56
|
def _to_entity_details
|
57
57
|
obj = { 'searchCriteria' => @criteria.to_h,
|
58
58
|
'name' => @name,
|
59
|
-
'
|
59
|
+
'description' => @description.nil? ? '' : @description,
|
60
60
|
'dynamic' => true,
|
61
61
|
'users' => @users }
|
62
62
|
JSON.generate(obj)
|