peplum-nmap 0.2.1 → 0.3.0

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: 77102d2b6c314e3b3f3585bb3d892338b81080087289b11631e2295cf4711499
4
- data.tar.gz: cf41927ba26efe42963c4064522c3e68735f5deb3163e6067dbb863b5470daa3
3
+ metadata.gz: d908da9a53e5a64f52446ad732503d62744dfa2a20632d28b0e3b2273cc2dc18
4
+ data.tar.gz: a816397bc1c7685af4159eeaf32b2604e0dd25bea19ae33589ba18f08ee9c607
5
5
  SHA512:
6
- metadata.gz: ad0e5f023991b6b8c95ae46621fbb4ce55f64dabc1a6509abc6b7767571facdff926077b8e23213d5f362e38dec82f926cd97f9fc5d1a5bcb65cdacdbfd8fce8
7
- data.tar.gz: 866b15d443a8a0b7bb33a57548fb460bff9fec8bf3b4120aee08e27730e62caf24041bcf58c464f327557a5c3d1bbd3c293a8d70114ff18996fed3d788a0b23b
6
+ metadata.gz: c6faf1368cb4627eb22b992bd19023f6318d4a24fa5ebf56095de003b36bda6fc54b092dfb45e9740e06bbf69cc549a60724131bfbaf9eddd02ec2d637025139
7
+ data.tar.gz: 9023be58238b489c87403d2c542badb755e61db8b5c4a64032fcfd90b5710287d5eb040eea4781e745c94498feb91c0d1a6d05b7b97dab96f87253d32129e900
@@ -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,30 +23,22 @@ 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
- def group( targets, chunks )
37
+ def split( targets, chunks )
37
38
  @hosts ||= self.live_hosts( targets )
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! Payload.merge( [self.class.progress_data, 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.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peplum-nmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: peplum