peplum-nmap 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 909d1bf87e2c6e01c356fdd5052b04c65ab7aa0146793f879351117c717c163f
4
- data.tar.gz: d859d987045778ad52e30253c345ac5a7e7dfd45a4e540a5a3b04d184284703c
3
+ metadata.gz: f22db0b582b78dd84d8581db7bc36a706f3a5a329413f21c668e0dca7a7956bc
4
+ data.tar.gz: ba7609f7daaed784432fa341bd3fe2579bf3cc83f5797a78ad659a2cf1258def
5
5
  SHA512:
6
- metadata.gz: 4a87fb1b4e7b775e6ed9039238f023754c6c9ade3252f56955d1a34081c8991f239f016983e7f3206ad8209e2f23b5cee5e58c5a1e381baa47928b0ae4448203
7
- data.tar.gz: 50f0c401b91396fe690b9368e21b3cd97198e01d7b27aaf8a15218b32ca0f3e5144fe78d59009a0b5f99708aa5b5a3e61f4e1e50c8b5cb27e739b841568f66a0
6
+ metadata.gz: 6ff6ed52c578a1b8de3eae2af817b30eafe8ac288899cd3e7998d5fafe695386e8991f7278202eaa0b848ad0f81cb2e652955073fc0969df81e95eb95ccabcdd
7
+ data.tar.gz: 2290ff495e066f2a5a473b0c2e7fc9b653c4748470c60e3078059490b22641a59ac3bb99c227580afa12bb291c00a079b49b531e34ebedcb8028dd11f12bab1a
@@ -6,6 +6,7 @@ module Peplum
6
6
  class Nmap
7
7
 
8
8
  module Payload
9
+ include Peplum::Application::Payload
9
10
 
10
11
  DEFAULT_OPTIONS = {
11
12
  'output_normal' => '/dev/null',
@@ -22,15 +23,15 @@ module Payload
22
23
 
23
24
  def run( targets, options )
24
25
  # Do it this way so we'll be able to have progress reports per scanned host.
25
- merge( targets.map do |target|
26
+ targets.map do |target|
26
27
  _run options.merge( targets: target, output_xml: SCAN_REPORT )
27
28
 
28
29
  report = report_from_xml( SCAN_REPORT )
29
- next if !report.include?('hosts')
30
+ next if report.empty?
30
31
 
31
32
  Nmap::Application.master.info.update report
32
33
  report
33
- end.compact )
34
+ end.compact
34
35
  end
35
36
 
36
37
  def split( targets, chunks )
@@ -38,14 +39,6 @@ module Payload
38
39
  @hosts.chunk( chunks ).reject(&:empty?)
39
40
  end
40
41
 
41
- def merge( data )
42
- report = { 'hosts' => {} }
43
- data.each do |d|
44
- report['hosts'].merge! d['hosts']
45
- end
46
- report
47
- end
48
-
49
42
  private
50
43
 
51
44
  def live_hosts( targets )
@@ -56,7 +49,7 @@ module Payload
56
49
  hosts = hosts_from_xml( PING_REPORT )
57
50
 
58
51
  # Seed the progress data with the live hosts
59
- hosts.each { |h| Services::Info.progress_data['hosts'][h] ||= {} }
52
+ hosts.each { |h| Services::Info.progress_data[h] ||= {} }
60
53
 
61
54
  hosts
62
55
  end
@@ -93,12 +86,11 @@ module Payload
93
86
  report_data = {}
94
87
  ::Nmap::XML.open( xml ) do |xml|
95
88
  xml.each_host do |host|
96
- report_data['hosts'] ||= {}
97
- report_data['hosts'][host.ip] = host_to_hash( host )
89
+ report_data[host.ip] = host_to_hash( host )
98
90
 
99
- report_data['hosts'][host.ip]['ports'] = {}
91
+ report_data[host.ip]['ports'] = {}
100
92
  host.each_port do |port|
101
- report_data['hosts'][host.ip]['ports'][port.number] = port_to_hash( port )
93
+ report_data[host.ip]['ports'][port.number] = port_to_hash( port )
102
94
  end
103
95
  end
104
96
  end
@@ -6,7 +6,7 @@ class Info
6
6
 
7
7
  class <<self
8
8
  def progress_data
9
- @progress_data ||= { 'hosts' => {} }
9
+ @progress_data ||= {}
10
10
  end
11
11
  end
12
12
 
@@ -15,7 +15,7 @@ class Info
15
15
  end
16
16
 
17
17
  def update( data )
18
- self.class.progress_data['hosts'].merge! Payload.merge( [self.class.progress_data, data] )['hosts']
18
+ self.class.progress_data.merge! data
19
19
  nil
20
20
  end
21
21
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Peplum
4
4
  class Nmap
5
- VERSION = "0.2.2"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peplum-nmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos