Module: Ronin::Nmap
- Defined in:
- lib/ronin/nmap.rb,
lib/ronin/nmap/cli.rb,
lib/ronin/nmap/root.rb,
lib/ronin/nmap/mixin.rb,
lib/ronin/nmap/version.rb,
lib/ronin/nmap/importer.rb,
lib/ronin/nmap/converter.rb,
lib/ronin/nmap/converters.rb,
lib/ronin/nmap/exceptions.rb,
lib/ronin/nmap/cli/command.rb,
lib/ronin/nmap/cli/port_list.rb,
lib/ronin/nmap/cli/importable.rb,
lib/ronin/nmap/converters/csv.rb,
lib/ronin/nmap/converters/json.rb,
lib/ronin/nmap/cli/commands/new.rb,
lib/ronin/nmap/cli/commands/dump.rb,
lib/ronin/nmap/cli/commands/grep.rb,
lib/ronin/nmap/cli/commands/scan.rb,
lib/ronin/nmap/cli/commands/print.rb,
lib/ronin/nmap/cli/commands/import.rb,
lib/ronin/nmap/cli/commands/convert.rb,
lib/ronin/nmap/cli/filtering_options.rb,
lib/ronin/nmap/cli/commands/completion.rb
Overview
Namespace for the ronin-nmap
library.
Defined Under Namespace
Modules: Converter, Converters, Importer, Mixin Classes: CLI, Exception, NotInstalled, ScanFailed
Constant Summary collapse
- CACHE_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The
~/.cache/ronin-nmap
cache directory. Core::Home.cache_dir('ronin-nmap')
- ROOT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Path to
ronin-nmap
root directory. File.(File.join(__dir__,'..','..','..'))
- VERSION =
ronin-nmap version
'0.1.0'
Class Method Summary collapse
-
.parse(path) ⇒ ::Nmap::XML
Parses a nmap XML file.
-
.scan(*targets, sudo: nil, **kwargs) {|nmap| ... } ⇒ ::Nmap::XML
Runs
nmap
and parses the XML output.
Class Method Details
.parse(path) ⇒ ::Nmap::XML
Parses a nmap XML file.
219 220 221 |
# File 'lib/ronin/nmap.rb', line 219 def self.parse(path) ::Nmap::XML.open(path) end |
.scan(*targets, sudo: nil, **kwargs) {|nmap| ... } ⇒ ::Nmap::XML
Runs nmap
and parses the XML output.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ronin/nmap.rb', line 161 def self.scan(*targets, sudo: nil, **kwargs,&block) nmap = ::Nmap::Command.new(**kwargs,&block) nmap.targets ||= targets unless nmap.output_xml FileUtils.mkdir_p(CACHE_DIR) tempfile = Tempfile.new(['nmap','.xml'], CACHE_DIR) nmap.output_xml = tempfile.path end sudo ||= nmap.syn_scan || nmap.ack_scan || nmap.window_scan || nmap.maimon_scan || nmap.null_scan || nmap.fin_scan || nmap.xmas_scan || nmap.scan_flags || nmap.ip_scan || nmap.os_fingerprint || nmap.traceroute # run the nmap command status = case sudo when Hash then nmap.sudo_command(**sudo) when true then nmap.sudo_command when false, nil then nmap.run_command else raise(ArgumentError,"sudo keyword must be a Hash, true, false, or nil") end # if the command was successful, return the parsed XML, otherwise raises # an exception. case status when nil raise(NotInstalled,"the nmap command is not installed") when false raise(ScanFailed,"nmap scan failed: #{nmap.command_argv.join(' ')}") else ::Nmap::XML.open(nmap.output_xml) end end |