peplum-nmap 0.1.0 → 0.2.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: b8b8cbc832f6aba1427bc571e95d2dcf1bdcf1cca46373f1ea291bb43923586f
4
- data.tar.gz: 06a2cbcae6e9d5bb77d4502eb4f29e82dd6425ec473e70a38fd39a2d9f8d8c5c
3
+ metadata.gz: 77102d2b6c314e3b3f3585bb3d892338b81080087289b11631e2295cf4711499
4
+ data.tar.gz: cf41927ba26efe42963c4064522c3e68735f5deb3163e6067dbb863b5470daa3
5
5
  SHA512:
6
- metadata.gz: e5b9cabeeeda80a9f419ecfbdf0248edd4e43d90940aa099b023b0d510c04fd6fa568073704a24a4dc187d6ec4d0d5ba7929da5f939ef0ee20dd46efe8bb16be
7
- data.tar.gz: 3fec8a89cf625873b304f3d487e6be807d3e33a18294552a41ee8a1107bbf79d6d62619a4488214de082154507bfe44231ae5b28f87cdc724d5e4226a342ed4b
6
+ metadata.gz: ad0e5f023991b6b8c95ae46621fbb4ce55f64dabc1a6509abc6b7767571facdff926077b8e23213d5f362e38dec82f926cd97f9fc5d1a5bcb65cdacdbfd8fce8
7
+ data.tar.gz: 866b15d443a8a0b7bb33a57548fb460bff9fec8bf3b4120aee08e27730e62caf24041bcf58c464f327557a5c3d1bbd3c293a8d70114ff18996fed3d788a0b23b
data/examples/rest.rb CHANGED
@@ -28,7 +28,7 @@ request :post, 'instances', {
28
28
  objects: ['192.168.1.*'],
29
29
  max_workers: 5
30
30
  },
31
- native: {
31
+ payload: {
32
32
  connect_scan: true,
33
33
  service_scan: true,
34
34
  default_script: true
@@ -39,6 +39,9 @@ request :post, 'instances', {
39
39
  instance_id = response_data['id']
40
40
 
41
41
  while sleep( 1 )
42
+ request :get, "instances/#{instance_id}/info/progress"
43
+ ap response_data
44
+
42
45
  # Continue looping while instance status is 'busy'.
43
46
  request :get, "instances/#{instance_id}"
44
47
  break if !response_data['busy']
data/examples/rpc.rb CHANGED
@@ -16,7 +16,7 @@ nmap.run(
16
16
  objects: ['192.168.1.*'],
17
17
  max_workers: 5
18
18
  },
19
- native: {
19
+ payload: {
20
20
  connect_scan: true,
21
21
  service_scan: true,
22
22
  default_script: true
@@ -24,7 +24,10 @@ nmap.run(
24
24
  )
25
25
 
26
26
  # Waiting to complete.
27
- sleep 1 while nmap.running?
27
+ while nmap.running?
28
+ ap nmap.info.progress
29
+ sleep 1
30
+ end
28
31
 
29
32
  # Hooray!
30
33
  puts JSON.pretty_generate( nmap.generate_report.data )
@@ -5,7 +5,7 @@ require 'tmpdir'
5
5
  module Peplum
6
6
  class Nmap
7
7
 
8
- module Native
8
+ module Payload
9
9
 
10
10
  DEFAULT_OPTIONS = {
11
11
  'output_normal' => '/dev/null',
@@ -21,8 +21,16 @@ module Native
21
21
  end
22
22
 
23
23
  def run( targets, options )
24
- _run options.merge( targets: targets, output_xml: SCAN_REPORT )
25
- report_from_xml( SCAN_REPORT )
24
+ # Do it this way so we'll be able to have progress reports per scanned host.
25
+ merge( targets.map do |target|
26
+ _run options.merge( targets: target, output_xml: SCAN_REPORT )
27
+
28
+ report = report_from_xml( SCAN_REPORT )
29
+ next if !report.include?('hosts')
30
+
31
+ Nmap::Application.master.info.update report
32
+ report
33
+ end.compact )
26
34
  end
27
35
 
28
36
  def group( targets, chunks )
@@ -45,7 +53,12 @@ module Native
45
53
  ping: true,
46
54
  output_xml: PING_REPORT
47
55
 
48
- hosts_from_xml( PING_REPORT )
56
+ hosts = hosts_from_xml( PING_REPORT )
57
+
58
+ # Seed the progress data with the live hosts
59
+ hosts.each { |h| Services::Info.progress_data['hosts'][h] ||= {} }
60
+
61
+ hosts
49
62
  end
50
63
 
51
64
  def set_default_options( nmap )
@@ -0,0 +1,26 @@
1
+ module Peplum
2
+ class Nmap
3
+ module Services
4
+
5
+ class Info
6
+
7
+ class <<self
8
+ def progress_data
9
+ @progress_data ||= { 'hosts' => {} }
10
+ end
11
+ end
12
+
13
+ def progress
14
+ self.class.progress_data
15
+ end
16
+
17
+ def update( data )
18
+ self.class.progress_data['hosts'].merge! Payload.merge( [self.class.progress_data, data] )['hosts']
19
+ nil
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module Peplum
2
+ class Nmap
3
+ module Services
4
+ module RESTProxy
5
+ def self.registered( app )
6
+
7
+ app.get '/progress' do
8
+ instance_for( params[:instance] ) do |instance|
9
+ json instance.info.progress
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Peplum
4
4
  class Nmap
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
data/lib/peplum/nmap.rb CHANGED
@@ -6,13 +6,20 @@ module Peplum
6
6
  class Nmap
7
7
 
8
8
  require_relative "nmap/version"
9
- require_relative "nmap/native"
9
+ require_relative "nmap/payload"
10
10
 
11
11
  class Error < Peplum::Error; end
12
12
 
13
13
  class Application < Peplum::Application
14
- def native_app
15
- Native
14
+
15
+ require_relative "nmap/services/info"
16
+ instance_service_for :info, Services::Info
17
+
18
+ require_relative "nmap/services/rest_proxy"
19
+ rest_service_for :info, Services::RESTProxy
20
+
21
+ def payload
22
+ Payload
16
23
  end
17
24
  end
18
25
 
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.1.0
4
+ version: 0.2.1
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-23 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: peplum
@@ -52,7 +52,9 @@ files:
52
52
  - examples/rest/helpers.rb
53
53
  - examples/rpc.rb
54
54
  - lib/peplum/nmap.rb
55
- - lib/peplum/nmap/native.rb
55
+ - lib/peplum/nmap/payload.rb
56
+ - lib/peplum/nmap/services/info.rb
57
+ - lib/peplum/nmap/services/rest_proxy.rb
56
58
  - lib/peplum/nmap/version.rb
57
59
  - peplum-nmap.gemspec
58
60
  homepage: http://ecsypno.com/