Module: Peplum::Nmap::Payload

Extended by:
Payload
Included in:
Payload
Defined in:
lib/peplum/nmap/payload.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  'output_normal' => '/dev/null',
  'quiet'         => true
}
PING_REPORT =
"#{Dir.tmpdir}/nmap-ping-#{Process.pid}.xml"
SCAN_REPORT =
"#{Dir.tmpdir}/nmap-scan-#{Process.pid}.xml"

Instance Method Summary collapse

Instance Method Details

#merge(data) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/peplum/nmap/payload.rb', line 41

def merge( data )
  report = { 'hosts' => {} }
  data.each do |d|
    report['hosts'].merge! d['hosts']
  end
  report
end

#run(targets, options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/peplum/nmap/payload.rb', line 23

def run( targets, options )
  # Do it this way so we'll be able to have progress reports per scanned host.
  merge( targets.map do |target|
    _run options.merge( targets: target, output_xml: SCAN_REPORT )

    report = report_from_xml( SCAN_REPORT )
    next if !report.include?('hosts')

    Nmap::Application.master.info.update report
    report
  end.compact )
end

#split(targets, chunks) ⇒ Object



36
37
38
39
# File 'lib/peplum/nmap/payload.rb', line 36

def split( targets, chunks )
  @hosts ||= self.live_hosts( targets )
  @hosts.chunk( chunks ).reject(&:empty?)
end