Class: Ronin::Recon::Net::PortScan

Inherits:
Worker
  • Object
show all
Defined in:
lib/ronin/recon/builtin/net/port_scan.rb

Overview

A recon worker that performs a nmap port scan.

Instance Method Summary collapse

Methods inherited from Worker

accepts, concurrency, #initialize, intensity, outputs, register, run

Constructor Details

This class inherits a constructor from Ronin::Recon::Worker

Instance Method Details

#process(ip) {|new_value| ... } ⇒ Object

Performs an nmap port scan on the given IP value.

Parameters:

Yields:

  • (new_value)

    The discovered open ports will be yielded.

Yield Parameters:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ronin/recon/builtin/net/port_scan.rb', line 60

def process(ip)
  xml = Nmap.scan(ip.address, verbose:      true,
                              service_scan: true,
                              ports:        params[:ports])

  address = ip.address
  host    = ip.host || xml.host.to_s

  xml.host.open_ports.each do |open_port|
    number   = open_port.number
    protocol = open_port.protocol
    service  = open_port.service

    yield OpenPort.new(
      address,number, host:     host,
                      protocol: protocol,
                      service:  service && service.name,
                      ssl:      service && service.ssl?
    )
  end
end