Module: Ronin::Nmap::Mixin

Defined in:
lib/ronin/nmap/mixin.rb

Overview

Provides helper methods for running nmap.

Instance Method Summary collapse

Instance Method Details

#nmap(*targets, sudo: nil, **kwargs) {|nmap| ... } ⇒ ::Nmap::XML

Runs nmap and parses the XML output.

Examples:

xml = Nmap.scan('192.168.1.*', syn_scan: true, ports: [80, 443])
# => #<Nmap::XML: ...>
xml.hosts
# => [#<Nmap::XML::Host: 192.168.1.1>, ...]

Parameters:

  • targets (Array<#to_s>)

    The targets to scan.

  • sudo (Hash{Symbol => Object}, Boolean, nil) (defaults to: nil)

    Controls whether the nmap command should be ran under sudo. If the sudo: keyword argument is not given, then nmap will automatically be ran under sudo if sync_scan, ack_scan, window_scan, maimon_scan, null_scan, fin_scan, xmas_scan, scan_flags, os_fingerprint, or traceroute are enabled.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for nmap.

Options Hash (sudo:):

  • :askpass (Boolean)

    Enables the --askpass sudo option.

  • :background (Boolean)

    Enables the --background sudo option

  • :bell (Boolean)

    Enables the --bell sudo option

  • :close_from (Integer)

    Enables the --close-from=... sudo option

  • :chdir (String)

    Enables the --chdir=... sudo option

  • :preserve_env (String)

    Enables the --preseve-env=... sudo option

  • :group (String, Boolean)

    Enables the --preseve-env=... sudo option

  • :set_home (Boolean)

    Enables the --set-home sudo option

  • :host (String)

    Enables the --host=... sudo option

  • :login (Boolean)

    Enables the --login sudo option

  • :remove_timestamp (Boolean)

    Enables the --remove-timestamp sudo option

  • :reset_timestamp (Boolean)

    Enables the --reset-timestamp sudo option

  • :non_interactive (Boolean)

    Enables the --non-interactive sudo option

  • :preserve_groups (Boolean)

    Enables the --preserve-groups sudo option

  • :prompt (String)

    Enables the --prompt=... sudo option

  • :chroot (String)

    Enables the --chroot=... sudo option

  • :role (String)

    Enables the --role=... sudo option

  • :stdin (Boolean)

    Enables the --stdin sudo option

  • :shell (Boolean)

    Enables the --shell sudo option

  • :type (String)

    Enables the --type=... sudo option

  • :command_timeout (Integer)

    Enables the --command-timeout=... sudo option

  • :other_user (String)

    Enables the --other-user=... sudo option

  • :user (String)

    Enables the --user=... sudo option

Yields:

  • (nmap)

    If a block is given, it will be passed the new nmap command object for additional configuration.

Yield Parameters:

  • nmap (::Nmap::Command)

    The nmap command object.

Returns:

  • (::Nmap::XML)

    The parsed nmap XML data.

See Also:



137
138
139
# File 'lib/ronin/nmap/mixin.rb', line 137

def nmap(*targets, sudo: nil, **kwargs,&block)
  Nmap.scan(*targets, sudo: sudo, **kwargs, &block)
end