nexpose 0.0.91 → 0.0.92

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nexpose/creds.rb CHANGED
@@ -72,7 +72,7 @@ module Nexpose
72
72
  xml << %Q{ port="#{replace_entities(port)}"} if (port)
73
73
  xml << '>'
74
74
  xml << replace_entities(securityblob) if (isblob)
75
- xml << @headers.to_xml()
75
+ xml << @headers.to_xml() if @headers
76
76
  xml << '</adminCredentials>'
77
77
 
78
78
  xml
@@ -76,7 +76,7 @@ module Nexpose
76
76
  else
77
77
  false
78
78
  end
79
- end
79
+ end
80
80
  end
81
81
 
82
82
  # === Description
@@ -249,7 +249,11 @@ module Nexpose
249
249
  doc = Rex::MIME::Message.new data
250
250
  doc.parts.each do |part|
251
251
  if /.*base64.*/ =~ part.header.to_s
252
- return parse_xml(part.content.unpack("m*")[0])
252
+ if (@format == "text") or (@format == "pdf") or (@format == "csv")
253
+ return part.content.unpack("m*")[0]
254
+ else
255
+ return parse_xml(part.content.unpack("m*")[0])
256
+ end
253
257
  end
254
258
  end
255
259
  end
@@ -519,7 +523,7 @@ module Nexpose
519
523
  r = @connection.execute('<ReportTemplateListingRequest session-id="' + connection.session_id.to_s + '"/>')
520
524
  if (r.success)
521
525
  r.res.elements.each('ReportTemplateListingResponse/ReportTemplateSummary') do |r|
522
- @report_template_summaries.push(ReportTemplateSumary.new(r.attributes['id'], r.attributes['name']))
526
+ @report_template_summaries.push(ReportTemplateSummary.new(r.attributes['id'], r.attributes['name'], r.attributes['description']))
523
527
  end
524
528
  else
525
529
  @error = true
@@ -528,7 +532,35 @@ module Nexpose
528
532
 
529
533
  end
530
534
 
531
- end
535
+ end
536
+
537
+ class ReportListing
538
+
539
+ attr_reader :error_msg
540
+ attr_reader :error
541
+ attr_reader :request_xml
542
+ attr_reader :response_xml
543
+ attr_reader :connection
544
+ attr_reader :xml_tag_stack
545
+ attr_reader :report_summaries #; //Array (ReportSummary*)
546
+
547
+ def initialize(connection)
548
+
549
+ @error = nil
550
+ @connetion = connection
551
+ @report_summaries = []
552
+
553
+ r = @connetion.execute('<ReportListingRequest session-id="' + connection.session_id.to_s + '"/>')
554
+ if (r.success)
555
+ r.res.elements.each('ReportListingResponse/ReportConfigSummary') do |r|
556
+ @report_summaries.push(ReportSummary.new(r.attributes['template-id'], r.attributes['cfg-id'], r.attributes['status'], r.attributes['generated-on'], r.attributes['report-URI']))
557
+ end
558
+ else
559
+ @error = true
560
+ @error_msg = 'ReportListingRequest Parse Error'
561
+ end
562
+ end
563
+ end
532
564
 
533
565
 
534
566
  class ReportTemplateSummary
@@ -110,38 +110,117 @@ module Nexpose
110
110
  attr_accessor :sites
111
111
  attr_accessor :priority
112
112
 
113
- def initialize(connection, engine_id)
113
+ def initialize(connection, id = -1)
114
114
  @connection = connection
115
- @id = nil
115
+ @id = id
116
116
  @address = nil
117
117
  @name = nil
118
- @port = nil
119
- @scope = nil
120
- @priority = 'global'
118
+ @port = 40814
119
+ @scope = 'silo'
120
+ @priority = 'normal'
121
121
  @sites = []
122
122
 
123
- r = @connection.execute('<EngineConfigRequest session-id="' + @connection.session_id + '" engine-id="' + engine_id + '"/>', '1.2')
123
+ # If valid ID provided, retrieve data from server.
124
+ if (id > 0)
125
+ xml = '<EngineConfigRequest session-id="' + @connection.session_id + '"'
126
+ xml << %Q{ engine-id="#{id}"}
127
+ xml << ' />'
128
+ r = @connection.execute(xml, '1.2')
124
129
 
125
- if (r.success)
126
- r.res.elements.each('EngineConfigResponse/EngineConfig') do |v|
127
- @id = v.attributes['id']
128
- @address = v.attributes['address']
129
- @name = v.attributes['name']
130
- @port = v.attributes['port']
131
- @scope = v.attributes['scope']
132
- v.elements.each('Site') do |s|
133
- @sites << s.attributes['id']
134
- end
135
- end
136
- else
137
- @error = true
138
- @error_msg = 'EngineConfigRequest Parse Error'
139
- end
140
- end
130
+ if (r.success)
131
+ r.res.elements.each('EngineConfigResponse/EngineConfig') do |v|
132
+ @id = v.attributes['id']
133
+ @address = v.attributes['address']
134
+ @name = v.attributes['name']
135
+ @port = v.attributes['port']
136
+ @scope = v.attributes['scope']
137
+ v.elements.each('Site') do |s|
138
+ @sites << s.attributes['id']
139
+ end
140
+ end
141
+ else
142
+ @error = true
143
+ @error_msg = 'EngineConfigRequest Parse Error'
144
+ end
145
+ end
146
+ end
141
147
 
142
- def save
148
+ def to_xml
149
+ xml = '<EngineConfig'
150
+ xml << %Q{ id="#{id}"}
151
+ xml << %Q{ address="#{address}"}
152
+ xml << %Q{ name="#{name}"}
153
+ xml << %Q{ port="#{port}"}
154
+ xml << %Q{ scope="#{scope}"}
155
+ xml << %Q{ priority="#{priority}"} if (priority)
156
+ # TODO: xml << %Q{ sites="#{sites}"} if (sites)
157
+ xml << ' />'
158
+ xml
159
+ end
143
160
 
144
- end
145
- end
161
+ # Save this engine configuration
162
+ # Example usage:
163
+ # engine = EngineConfig.new(@nsc)
164
+ # engine.address = 'atlanta.company.com'
165
+ # engine.name = 'Atlanta Engine'
166
+ # engine.save()
167
+ def save
168
+ xml = '<EngineSaveRequest session-id="' + @connection.session_id + '">'
169
+ xml << to_xml
170
+ xml << '</EngineSaveRequest>'
171
+
172
+ r = @connection.execute(xml, '1.2')
173
+ unless (r.success)
174
+ @error = true
175
+ @error_msg = 'EngineSaveRequest Parse Error'
176
+ end
177
+ end
178
+ end
179
+
180
+ #-------------------------------------------------------------------------------------------------------------------
181
+ # Core objects for creating an engine pool
182
+ # Example usage:
183
+ # pool = EnginePool.new('East Coast Pool')
184
+ # pool.add('New York Engine')
185
+ # pool.add('Georgia Engine')
186
+ # id = pool.create(@nsc)
187
+ #-------------------------------------------------------------------------------------------------------------------
188
+ class EnginePool
189
+ attr_accessor :name
190
+ attr_accessor :scope
191
+ attr_accessor :engines
192
+
193
+ def initialize(name, scope = 'silo')
194
+ @name = name
195
+ @scope = scope
196
+ @engines = []
197
+ end
198
+
199
+ # Add an engine to the pool by name (not ID).
200
+ def add(engine)
201
+ engines << engine
202
+ end
203
+
204
+ # Create an engine pool from the existing configuration.
205
+ # Returns the engine ID assigned to the pool, if successful.
206
+ def create(connection)
207
+ xml = '<EnginePoolCreateRequest session-id="' + connection.session_id + '">'
208
+ xml << %Q{<EnginePool name="#{name}" scope="#{scope}">}
209
+ engines.each do |engine|
210
+ xml << %Q{<Engine name="#{engine}" />}
211
+ end
212
+ xml << '</EnginePool>'
213
+ xml << '</EnginePoolCreateRequest>'
146
214
 
147
- end
215
+ r = connection.execute(xml, '1.2')
216
+ if (r.success)
217
+ r.res.elements.each('EnginePoolCreateResponse') do |v|
218
+ return v.attributes['id']
219
+ end
220
+ else
221
+ @error = true
222
+ @error_msg = 'EnginePoolCreateResponse Parse Error'
223
+ end
224
+ end
225
+ end
226
+ end
data/lib/nexpose/site.rb CHANGED
@@ -582,7 +582,10 @@ module Nexpose
582
582
  @scan_summaries = Array.new()
583
583
 
584
584
  r = @connection.execute('<SiteScanHistoryRequest' + ' session-id="' + @connection.session_id + '" site-id="' + "#{@site_id}" + '"/>')
585
- status = r.success
585
+
586
+ if r and r.success
587
+ r
588
+ end
586
589
  end
587
590
  end
588
591
 
data/nexpose.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  APP_NAME = "nexpose"
4
- VERSION = "0.0.91"
4
+ VERSION = "0.0.92"
5
5
  REVISION = "12878"
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = APP_NAME
9
9
  s.version = VERSION
10
10
  s.homepage = "https://github.com/rapid7/nexpose-client"
11
- s.summary = "Ruby API for Rapid7 Nexpose"
12
- s.description = "This gem provides a Ruby API to the Nexpose vulnerability management product by Rapid7. This version is based on Metasploit SVN revision #{REVISION}"
11
+ s.summary = "Ruby API for Rapid7 NeXpose"
12
+ s.description = "This gem provides a Ruby API to the NeXpose vulnerability management product by Rapid7. This version is based on Metasploit SVN revision #{REVISION}"
13
13
  s.license = "BSD"
14
14
  s.authors = ["HD Moore", "Chris Lee"]
15
- s.email = ["hdm@metasploit.com", "christopher_lee@rapid7.com"]
15
+ s.email = ["hdm@metasploit.com", "christopher_lee@rapid7.com"]
16
16
  s.files = Dir['[A-Z]*'] + Dir['lib/**/*']
17
17
  s.require_paths = ["lib"]
18
18
  s.extra_rdoc_files = ["README.markdown"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexpose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.91
4
+ version: 0.0.92
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-08 00:00:00.000000000Z
13
+ date: 2012-05-02 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex
17
- requirement: &29000580 !ruby/object:Gem::Requirement
17
+ requirement: &30053556 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.0.32
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *29000580
25
+ version_requirements: *30053556
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rex
28
- requirement: &29000304 !ruby/object:Gem::Requirement
28
+ requirement: &30053280 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,8 +33,8 @@ dependencies:
33
33
  version: 1.0.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *29000304
37
- description: This gem provides a Ruby API to the Nexpose vulnerability management
36
+ version_requirements: *30053280
37
+ description: This gem provides a Ruby API to the NeXpose vulnerability management
38
38
  product by Rapid7. This version is based on Metasploit SVN revision 12878
39
39
  email:
40
40
  - hdm@metasploit.com
@@ -86,5 +86,5 @@ rubyforge_project:
86
86
  rubygems_version: 1.8.17
87
87
  signing_key:
88
88
  specification_version: 3
89
- summary: Ruby API for Rapid7 Nexpose
89
+ summary: Ruby API for Rapid7 NeXpose
90
90
  test_files: []