Sha256: c3b0ab7f56e0dd162a98f2b0b33750726e58e4d2e6e2f4f6b7f79a555f894fbd

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

require 'nmap/task'

require 'rprogram/program'

module Nmap
  class Program < RProgram::Program

    name_program 'nmap'

    #
    # Finds the `nmap` program and performs a scan.
    #
    # @param [Hash{Symbol => Object}] options
    #   Additional options for nmap.
    #
    # @yield [task]
    #   If a block is given, it will be passed a task object
    #   used to specify options for nmap.
    #
    # @yieldparam [Task] task
    #   The nmap task object.
    #
    # @return [Boolean]
    #   Specifies whether the command exited normally.
    #
    # @example Specifying Nmap options via a Hash.
    #   Nmap::Program.scan(
    #     :targets => '192.168.1.1',
    #     :ports => [22,80,443],
    #     :verbose => true
    #   )
    #
    # @example Specifying Nmap options via a {Task} object.
    #   Nmap::Program.scan do |nmap|
    #     nmap.targets = '192.168.1.1'
    #     nmap.ports = [22,80,443]
    #     nmap.verbose = true
    #   end
    #
    def self.scan(options={},&block)
      self.find.scan(options,&block)
    end

    #
    # Performs a scan.
    #
    # @param [Hash{Symbol => Object}] options
    #   Additional options for nmap.
    #
    # @yield [task]
    #   If a block is given, it will be passed a task object
    #   used to specify options for nmap.
    #
    # @yieldparam [Task] task
    #   The nmap task object.
    #
    # @return [Boolean]
    #   Specifies whether the command exited normally.
    #
    def scan(options={},&block)
      run_task(Task.new(options,&block))
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-nmap-0.4.1 lib/nmap/program.rb
ruby-nmap-0.4.0 lib/nmap/program.rb
ruby-nmap-0.3.0 lib/nmap/program.rb
ruby-nmap-0.2.0 lib/nmap/program.rb