ronin-nmap 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.github/workflows/ruby.yml +47 -0
  4. data/.gitignore +14 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +15 -0
  7. data/.ruby-version +1 -0
  8. data/.yardopts +1 -0
  9. data/COPYING.txt +165 -0
  10. data/ChangeLog.md +10 -0
  11. data/Gemfile +42 -0
  12. data/README.md +238 -0
  13. data/Rakefile +43 -0
  14. data/bin/ronin-nmap +32 -0
  15. data/data/completions/ronin-nmap +79 -0
  16. data/data/templates/script.rb.erb +58 -0
  17. data/gemspec.yml +42 -0
  18. data/lib/ronin/nmap/cli/command.rb +40 -0
  19. data/lib/ronin/nmap/cli/commands/completion.rb +61 -0
  20. data/lib/ronin/nmap/cli/commands/convert.rb +108 -0
  21. data/lib/ronin/nmap/cli/commands/dump.rb +293 -0
  22. data/lib/ronin/nmap/cli/commands/grep.rb +378 -0
  23. data/lib/ronin/nmap/cli/commands/import.rb +79 -0
  24. data/lib/ronin/nmap/cli/commands/new.rb +226 -0
  25. data/lib/ronin/nmap/cli/commands/print.rb +133 -0
  26. data/lib/ronin/nmap/cli/commands/scan.rb +233 -0
  27. data/lib/ronin/nmap/cli/filtering_options.rb +355 -0
  28. data/lib/ronin/nmap/cli/importable.rb +68 -0
  29. data/lib/ronin/nmap/cli/port_list.rb +102 -0
  30. data/lib/ronin/nmap/cli.rb +50 -0
  31. data/lib/ronin/nmap/converter.rb +114 -0
  32. data/lib/ronin/nmap/converters/csv.rb +162 -0
  33. data/lib/ronin/nmap/converters/json.rb +562 -0
  34. data/lib/ronin/nmap/converters.rb +54 -0
  35. data/lib/ronin/nmap/exceptions.rb +47 -0
  36. data/lib/ronin/nmap/importer.rb +369 -0
  37. data/lib/ronin/nmap/root.rb +28 -0
  38. data/lib/ronin/nmap/version.rb +26 -0
  39. data/lib/ronin/nmap.rb +223 -0
  40. data/man/ronin-nmap-completion.1 +76 -0
  41. data/man/ronin-nmap-completion.1.md +78 -0
  42. data/man/ronin-nmap-convert.1 +33 -0
  43. data/man/ronin-nmap-convert.1.md +36 -0
  44. data/man/ronin-nmap-dump.1 +141 -0
  45. data/man/ronin-nmap-dump.1.md +119 -0
  46. data/man/ronin-nmap-grep.1 +33 -0
  47. data/man/ronin-nmap-grep.1.md +36 -0
  48. data/man/ronin-nmap-import.1 +52 -0
  49. data/man/ronin-nmap-import.1.md +57 -0
  50. data/man/ronin-nmap-new.1 +81 -0
  51. data/man/ronin-nmap-new.1.md +73 -0
  52. data/man/ronin-nmap-print.1 +61 -0
  53. data/man/ronin-nmap-print.1.md +63 -0
  54. data/man/ronin-nmap-scan.1 +86 -0
  55. data/man/ronin-nmap-scan.1.md +84 -0
  56. data/man/ronin-nmap.1 +58 -0
  57. data/man/ronin-nmap.1.md +57 -0
  58. data/ronin-nmap.gemspec +62 -0
  59. data/scripts/setup +161 -0
  60. metadata +168 -0
data/lib/ronin/nmap.rb ADDED
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-nmap - A Ruby library for automating nmap and importing nmap scans.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-nmap is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-nmap is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-nmap. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/nmap/exceptions'
22
+ require 'ronin/nmap/importer'
23
+ require 'ronin/core/home'
24
+ require 'nmap/command'
25
+ require 'nmap/xml'
26
+
27
+ require 'tempfile'
28
+ require 'fileutils'
29
+
30
+ module Ronin
31
+ #
32
+ # Namespace for the `ronin-nmap` library.
33
+ #
34
+ module Nmap
35
+ # The `~/.cache/ronin-nmap` cache directory.
36
+ #
37
+ # @api private
38
+ CACHE_DIR = Core::Home.cache_dir('ronin-nmap')
39
+
40
+ #
41
+ # Runs `nmap` and parses the XML output.
42
+ #
43
+ # @param [Array<#to_s>] targets
44
+ # The targets to scan.
45
+ #
46
+ # @param [Hash{Symbol => Object}, Boolean, nil] sudo
47
+ # Controls whether the `nmap` command should be ran under `sudo`.
48
+ # If the `sudo:` keyword argument is not given, then `nmap` will
49
+ # automatically be ran under `sudo` if `sync_scan`, `ack_scan`,
50
+ # `window_scan`, `maimon_scan`, `null_scan`, `fin_scan`, `xmas_scan`,
51
+ # `scan_flags`, `os_fingerprint`, or `traceroute` are enabled.
52
+ #
53
+ # @option sudo [Boolean] :askpass
54
+ # Enables the `--askpass` `sudo` option.
55
+ #
56
+ # @option sudo [Boolean] :background
57
+ # Enables the `--background` `sudo` option
58
+ #
59
+ # @option sudo [Boolean] :bell
60
+ # Enables the `--bell` `sudo` option
61
+ #
62
+ # @option sudo [Integer] :close_from
63
+ # Enables the `--close-from=...` `sudo` option
64
+ #
65
+ # @option sudo [String] :chdir
66
+ # Enables the `--chdir=...` `sudo` option
67
+ #
68
+ # @option sudo [String] :preserve_env
69
+ # Enables the `--preseve-env=...` `sudo` option
70
+ #
71
+ # @option sudo [String, Boolean] :group
72
+ # Enables the `--preseve-env=...` `sudo` option
73
+ #
74
+ # @option sudo [Boolean] :set_home
75
+ # Enables the `--set-home` `sudo` option
76
+ #
77
+ # @option sudo [String] :host
78
+ # Enables the `--host=...` `sudo` option
79
+ #
80
+ # @option sudo [Boolean] :login
81
+ # Enables the `--login` `sudo` option
82
+ #
83
+ # @option sudo [Boolean] :remove_timestamp
84
+ # Enables the `--remove-timestamp` `sudo` option
85
+ #
86
+ # @option sudo [Boolean] :reset_timestamp
87
+ # Enables the `--reset-timestamp` `sudo` option
88
+ #
89
+ # @option sudo [Boolean] :non_interactive
90
+ # Enables the `--non-interactive` `sudo` option
91
+ #
92
+ # @option sudo [Boolean] :preserve_groups
93
+ # Enables the `--preserve-groups` `sudo` option
94
+ #
95
+ # @option sudo [String] :prompt
96
+ # Enables the `--prompt=...` `sudo` option
97
+ #
98
+ # @option sudo [String] :chroot
99
+ # Enables the `--chroot=...` `sudo` option
100
+ #
101
+ # @option sudo [String] :role
102
+ # Enables the `--role=...` `sudo` option
103
+ #
104
+ # @option sudo [Boolean] :stdin
105
+ # Enables the `--stdin` `sudo` option
106
+ #
107
+ # @option sudo [Boolean] :shell
108
+ # Enables the `--shell` `sudo` option
109
+ #
110
+ # @option sudo [String] :type
111
+ # Enables the `--type=...` `sudo` option
112
+ #
113
+ # @option sudo [Integer] :command_timeout
114
+ # Enables the `--command-timeout=...` `sudo` option
115
+ #
116
+ # @option sudo [String] :other_user
117
+ # Enables the `--other-user=...` `sudo` option
118
+ #
119
+ # @option sudo [String] :user
120
+ # Enables the `--user=...` `sudo` option
121
+ #
122
+ # @param [Hash{Symbol => Object}] kwargs
123
+ # Additional keyword arguments for `nmap`.
124
+ #
125
+ # @yield [nmap]
126
+ # If a block is given, it will be passed the new `nmap` command object
127
+ # for additional configuration.
128
+ #
129
+ # @yieldparam [::Nmap::Command] nmap
130
+ # The `nmap` command object.
131
+ #
132
+ # @return [::Nmap::XML]
133
+ # If the `nmap` command was successful, the parsed nmap XML data will be
134
+ # returned.
135
+ #
136
+ # @raise [NotInstalled]
137
+ # The `nmap` command was not installed.
138
+ #
139
+ # @raise [ScanFailed]
140
+ # The `nmap` scan failed.
141
+ #
142
+ # @example
143
+ # xml = Nmap.scan('192.168.1.*', syn_scan: true, ports: [80, 443])
144
+ # # => #<Nmap::XML: ...>
145
+ # xml.up_hosts
146
+ # # => [#<Nmap::XML::Host: 192.168.1.1>, ...]
147
+ #
148
+ # @example with a block:
149
+ # xml = Nmap.scan do |nmap|
150
+ # nmap.syn_scan = true
151
+ # nmap.ports = [80, 443]
152
+ # nmap.targets = '192.168.1.*'
153
+ # end
154
+ # # => #<Nmap::XML: ...>
155
+ #
156
+ # @see https://rubydoc.info/gems/ruby-nmap/Nmap/Command
157
+ # @see https://rubydoc.info/gems/ruby-nmap/Nmap/XML
158
+ #
159
+ # @api public
160
+ #
161
+ def self.scan(*targets, sudo: nil, **kwargs,&block)
162
+ nmap = ::Nmap::Command.new(**kwargs,&block)
163
+
164
+ nmap.targets ||= targets
165
+
166
+ unless nmap.output_xml
167
+ FileUtils.mkdir_p(CACHE_DIR)
168
+ tempfile = Tempfile.new(['nmap','.xml'], CACHE_DIR)
169
+
170
+ nmap.output_xml = tempfile.path
171
+ end
172
+
173
+ sudo ||= nmap.syn_scan ||
174
+ nmap.ack_scan ||
175
+ nmap.window_scan ||
176
+ nmap.maimon_scan ||
177
+ nmap.null_scan ||
178
+ nmap.fin_scan ||
179
+ nmap.xmas_scan ||
180
+ nmap.scan_flags ||
181
+ nmap.ip_scan ||
182
+ nmap.os_fingerprint ||
183
+ nmap.traceroute
184
+
185
+ # run the nmap command
186
+ status = case sudo
187
+ when Hash then nmap.sudo_command(**sudo)
188
+ when true then nmap.sudo_command
189
+ when false, nil then nmap.run_command
190
+ else
191
+ raise(ArgumentError,"sudo keyword must be a Hash, true, false, or nil")
192
+ end
193
+
194
+ # if the command was successful, return the parsed XML, otherwise raises
195
+ # an exception.
196
+ case status
197
+ when nil
198
+ raise(NotInstalled,"the nmap command is not installed")
199
+ when false
200
+ raise(ScanFailed,"nmap scan failed: #{nmap.command_argv.join(' ')}")
201
+ else
202
+ ::Nmap::XML.open(nmap.output_xml)
203
+ end
204
+ end
205
+
206
+ #
207
+ # Parses a nmap XML file.
208
+ #
209
+ # @param [String] path
210
+ # The path to the nmap XML file.
211
+ #
212
+ # @return [::Nmap::XML]
213
+ # The parsed nmap XML file.
214
+ #
215
+ # @see https://rubydoc.info/gems/ruby-nmap/Nmap/XML
216
+ #
217
+ # @api public
218
+ #
219
+ def self.parse(path)
220
+ ::Nmap::XML.open(path)
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,76 @@
1
+ .\" Generated by kramdown-man 1.0.1
2
+ .\" https://github.com/postmodern/kramdown-man#readme
3
+ .TH ronin-nmap-completion 1 "2024-01-01" Ronin Nmap "User Manuals"
4
+ .SH NAME
5
+ .PP
6
+ ronin\-nmap\-completion \- Manages shell completion rules for \fBronin\-nmap\fR
7
+ .SH SYNOPSIS
8
+ .PP
9
+ \fBronin\-nmap completion\fR \[lB]\fIoptions\fP\[rB]
10
+ .SH DESCRIPTION
11
+ .PP
12
+ The \fBronin\-nmap completion\fR command can print, install, or uninstall shell
13
+ completion rules for the \fBronin\-nmap\fR command\.
14
+ .PP
15
+ Supports installing completion rules for Bash or Zsh shells\.
16
+ Completion rules for the Fish shell is currently not supported\.
17
+ .SS ZSH SUPPORT
18
+ .PP
19
+ Zsh users will have to add the following lines to their \fB\[ti]\[sl]\.zshrc\fR file in
20
+ order to enable Zsh\[cq]s Bash completion compatibility layer:
21
+ .PP
22
+ .RS 4
23
+ .EX
24
+ autoload \-Uz \[pl]X compinit && compinit
25
+ autoload \-Uz \[pl]X bashcompinit && bashcompinit
26
+ .EE
27
+ .RE
28
+ .SH OPTIONS
29
+ .TP
30
+ \fB\-\-print\fR
31
+ Prints the shell completion file\.
32
+ .TP
33
+ \fB\-\-install\fR
34
+ Installs the shell completion file\.
35
+ .TP
36
+ \fB\-\-uninstall\fR
37
+ Uninstalls the shell completion file\.
38
+ .TP
39
+ \fB\-h\fR, \fB\-\-help\fR
40
+ Prints help information\.
41
+ .SH ENVIRONMENT
42
+ .TP
43
+ \fIPREFIX\fP
44
+ Specifies the root prefix for the file system\.
45
+ .TP
46
+ \fIHOME\fP
47
+ Specifies the home directory of the user\. Ronin will search for the
48
+ \fB\[ti]\[sl]\.cache\[sl]ronin\-nmap\fR cache directory within the home directory\.
49
+ .TP
50
+ \fIXDG\[ru]DATA\[ru]HOME\fP
51
+ Specifies the data directory to use\. Defaults to \fB\[Do]HOME\[sl]\.local\[sl]share\fR\.
52
+ .SH FILES
53
+ .TP
54
+ \fB\[ti]\[sl]\.local\[sl]share\[sl]bash\-completion\[sl]completions\[sl]\fR
55
+ The user\-local installation directory for Bash completion files\.
56
+ .TP
57
+ \fB\[sl]usr\[sl]local\[sl]share\[sl]bash\-completion\[sl]completions\[sl]\fR
58
+ The system\-wide installation directory for Bash completions files\.
59
+ .TP
60
+ \fB\[sl]usr\[sl]local\[sl]share\[sl]zsh\[sl]site\-functions\[sl]\fR
61
+ The installation directory for Zsh completion files\.
62
+ .SH EXAMPLES
63
+ .TP
64
+ \fBronin\-nmap completion \-\-print\fR
65
+ Prints the shell completion rules instead of installing them\.
66
+ .TP
67
+ \fBronin\-nmap completion \-\-install\fR
68
+ Installs the shell completion rules for \fBronin\-nmap\fR\.
69
+ .TP
70
+ \fBronin\-nmap completion \-\-uninstall\fR
71
+ Uninstalls the shell completion rules for \fBronin\-nmap\fR\.
72
+ .SH AUTHOR
73
+ .PP
74
+ Postmodern
75
+ .MT postmodern\.mod3\[at]gmail\.com
76
+ .ME
@@ -0,0 +1,78 @@
1
+ # ronin-nmap-completion 1 "2024-01-01" Ronin Nmap "User Manuals"
2
+
3
+ ## NAME
4
+
5
+ ronin-nmap-completion - Manages shell completion rules for `ronin-nmap`
6
+
7
+ ## SYNOPSIS
8
+
9
+ `ronin-nmap completion` [*options*]
10
+
11
+ ## DESCRIPTION
12
+
13
+ The `ronin-nmap completion` command can print, install, or uninstall shell
14
+ completion rules for the `ronin-nmap` command.
15
+
16
+ Supports installing completion rules for Bash or Zsh shells.
17
+ Completion rules for the Fish shell is currently not supported.
18
+
19
+ ### ZSH SUPPORT
20
+
21
+ Zsh users will have to add the following lines to their `~/.zshrc` file in
22
+ order to enable Zsh's Bash completion compatibility layer:
23
+
24
+ autoload -Uz +X compinit && compinit
25
+ autoload -Uz +X bashcompinit && bashcompinit
26
+
27
+ ## OPTIONS
28
+
29
+ `--print`
30
+ : Prints the shell completion file.
31
+
32
+ `--install`
33
+ : Installs the shell completion file.
34
+
35
+ `--uninstall`
36
+ : Uninstalls the shell completion file.
37
+
38
+ `-h`, `--help`
39
+ : Prints help information.
40
+
41
+ ## ENVIRONMENT
42
+
43
+ *PREFIX*
44
+ : Specifies the root prefix for the file system.
45
+
46
+ *HOME*
47
+ : Specifies the home directory of the user. Ronin will search for the
48
+ `~/.cache/ronin-nmap` cache directory within the home directory.
49
+
50
+ *XDG_DATA_HOME*
51
+ : Specifies the data directory to use. Defaults to `$HOME/.local/share`.
52
+
53
+ ## FILES
54
+
55
+ `~/.local/share/bash-completion/completions/`
56
+ : The user-local installation directory for Bash completion files.
57
+
58
+ `/usr/local/share/bash-completion/completions/`
59
+ : The system-wide installation directory for Bash completions files.
60
+
61
+ `/usr/local/share/zsh/site-functions/`
62
+ : The installation directory for Zsh completion files.
63
+
64
+ ## EXAMPLES
65
+
66
+ `ronin-nmap completion --print`
67
+ : Prints the shell completion rules instead of installing them.
68
+
69
+ `ronin-nmap completion --install`
70
+ : Installs the shell completion rules for `ronin-nmap`.
71
+
72
+ `ronin-nmap completion --uninstall`
73
+ : Uninstalls the shell completion rules for `ronin-nmap`.
74
+
75
+ ## AUTHOR
76
+
77
+ Postmodern <postmodern.mod3@gmail.com>
78
+
@@ -0,0 +1,33 @@
1
+ .\" Generated by kramdown-man 1.0.1
2
+ .\" https://github.com/postmodern/kramdown-man#readme
3
+ .TH ronin-nmap-convert 1 "2023-03-01" Ronin Nmap "User Manuals"
4
+ .SH NAME
5
+ .PP
6
+ ronin\-nmap\-convert \- Converts an nmap XML file to JSON or CSV
7
+ .SH SYNOPSIS
8
+ .PP
9
+ \fBronin\-nmap convert\fR \[lB]\fB\-\-format\fR \fBjson\fR\[or]\fBcsv\fR\[rB] \fIXML\[ru]FILE\fP \[lB]\fIOUTPUT\[ru]FILE\fP\[rB]
10
+ .SH DESCRIPTION
11
+ .PP
12
+ Converts an nmap XML file to JSON or CSV\.
13
+ .SH ARGUMENTS
14
+ .TP
15
+ \fIXML\[ru]FILE\fP
16
+ The nmap XML file to import\.
17
+ .TP
18
+ \fIOUTPUT\[ru]FILE\fP
19
+ The optional output file to write to\.
20
+ .SH OPTIONS
21
+ .TP
22
+ \fB\-F\fR, \fB\-\-format\fR \fBjson\fR\[or]\fBcsv\fR
23
+ Sets the output conversion format to JSON or CSV\. If the option is not given,
24
+ the output conversion format Will be inferred from the \fIOUTPUT\[ru]FILE\fP file
25
+ extension\.
26
+ .TP
27
+ \fB\-h\fR, \fB\-\-help\fR
28
+ Print help information
29
+ .SH AUTHOR
30
+ .PP
31
+ Postmodern
32
+ .MT postmodern\.mod3\[at]gmail\.com
33
+ .ME
@@ -0,0 +1,36 @@
1
+ # ronin-nmap-convert 1 "2023-03-01" Ronin Nmap "User Manuals"
2
+
3
+ ## NAME
4
+
5
+ ronin-nmap-convert - Converts an nmap XML file to JSON or CSV
6
+
7
+ ## SYNOPSIS
8
+
9
+ `ronin-nmap convert` [`--format` `json`\|`csv`] *XML_FILE* [*OUTPUT_FILE*]
10
+
11
+ ## DESCRIPTION
12
+
13
+ Converts an nmap XML file to JSON or CSV.
14
+
15
+ ## ARGUMENTS
16
+
17
+ *XML_FILE*
18
+ : The nmap XML file to import.
19
+
20
+ *OUTPUT_FILE*
21
+ : The optional output file to write to.
22
+
23
+ ## OPTIONS
24
+
25
+ `-F`, `--format` `json`|`csv`
26
+ : Sets the output conversion format to JSON or CSV. If the option is not given,
27
+ the output conversion format Will be inferred from the *OUTPUT_FILE* file
28
+ extension.
29
+
30
+ `-h`, `--help`
31
+ : Print help information
32
+
33
+ ## AUTHOR
34
+
35
+ Postmodern <postmodern.mod3@gmail.com>
36
+
@@ -0,0 +1,141 @@
1
+ .\" Generated by kramdown-man 1.0.1
2
+ .\" https://github.com/postmodern/kramdown-man#readme
3
+ .TH ronin-nmap-dump 1 "2023-03-01" Ronin Nmap "User Manuals"
4
+ .SH NAME
5
+ .PP
6
+ ronin\-nmap\-dump \- Dumps the scanned ports from nmap XML file(s)\.
7
+ .SH SYNOPSIS
8
+ .PP
9
+ \fBronin\-nmap dump\fR \[lB]options\[rB] \fIXML\[ru]FILE\fP \[lB]\.\.\.\[rB]
10
+ .SH DESCRIPTION
11
+ .PP
12
+ Dumps the scanned ports from nmap XML files into a variety of formats\. The
13
+ output formats include:
14
+ .RS
15
+ .IP \(bu 2
16
+ IP
17
+ .IP \(bu 2
18
+ Hostname
19
+ .IP \(bu 2
20
+ \fBIP:PORT\fR
21
+ .IP \(bu 2
22
+ \fBHOST:PORT\fR
23
+ .IP \(bu 2
24
+ URI
25
+ .RE
26
+ .PP
27
+ The command also supports filtering the nmap targets by IP, IP range, domain,
28
+ OS, port, service, or NSE script\.
29
+ .SH ARGUMENTS
30
+ .TP
31
+ \fIXML\[ru]FILE\fP
32
+ The nmap XML file to import\.
33
+ .SH OPTIONS
34
+ .TP
35
+ \fB\-\-print\-ips\fR
36
+ Only print the IP addresses of the targets (ex: \fB192\.168\.1\.1\fR)\.
37
+ .TP
38
+ \fB\-\-print\-hosts\fR
39
+ Only print the hostnames of the targets (ex: \fBexample\.com\fR)\.
40
+ .TP
41
+ \fB\-\-print\-ip\-ports\fR
42
+ Print IP address and port pairs for each target (ex: \fB192\.168\.1\.1:443\fR)\.
43
+ This is the default behavior\.
44
+ .TP
45
+ \fB\-\-print\-host\-ports\fR
46
+ Print hostname and port pairs for each target (ex: \fBexample\.com:443\fR)\.
47
+ .TP
48
+ \`\-\-print\-uris
49
+ Print URIs for each target that has either \fBhttp\fR or \fBhttps\fR services
50
+ (ex: \fBhttps:\[sl]\[sl]example\.com\fR or \fBhttp:\[sl]\[sl]example\.com:8080\fR)\.
51
+ .TP
52
+ \fB\-\-ip\fR \fIIP\fP
53
+ Filters the targets by a specific IP address\.
54
+ .TP
55
+ \fB\-\-ip\-range\fR \fICIDR\fP
56
+ Filter the targets by a CIDR IP range (ex: \fB192\.168\.1\.0\[sl]24\fR)\.
57
+ .TP
58
+ \fB\-\-domain\fR \fIDOMAIN\fP
59
+ Filters the targets by a domain (ex: \fBexample\.com\fR)\.
60
+ .TP
61
+ \fB\-\-with\-os\fR \fIOS\fP
62
+ Filters the targets by Operating System (ex: \fBLinux\fR, \fBWindows\fR, etc)\.
63
+ .TP
64
+ \fB\-\-with\-ports\fR \[lC]\fIPORT\fP \[or] \fIPORT1\fP\fB\-\fR\fIPORT2\fP\[rC]\fB,\fR\.\.\.
65
+ Filter targets that have open ports in the port list\.
66
+ The port list is a comma separated list of port numbers (\fB443\fR) or port
67
+ ranges (\fB8000\-9000\fR)\.
68
+ .TP
69
+ \fB\-\-with\-service\fR \fISERVICE\fP\[lB]\fB,\fR\.\.\.\[rB]
70
+ Filters targets who are running one of the specified services\.
71
+ .TP
72
+ \fB\-\-with\-script\fR \fISCRIPT\fP\[lB]\fB,\fR\.\.\.\[rB]
73
+ Filters targets that have the NSE script name(s)\.
74
+ .TP
75
+ \fB\-\-with\-script\-output\fR \fISTRING\fP
76
+ Filters targets that have NSE script output contain the string\.
77
+ .TP
78
+ \fB\-\-with\-script\-regex\fR \fB\[sl]\fR\fIREGEX\fP\fB\[sl]\fR
79
+ Filters targets that have NSE script output that matches the regular
80
+ expression\.
81
+ .TP
82
+ \fB\-p\fR, \fB\-\-ports\fR \[lC]\fIPORT\fP \[or] \fIPORT1\-PORT2\fP\[rC],\.\.\.
83
+ Filter \fBIP:PORT\fR or \fBHOST:PORT\fR pairs who\[cq]s ports are in the gvien port list\.
84
+ The port list is a comma separated list of port numbers (\fB443\fR) or port
85
+ ranges (\fB8000\-9000\fR)\.
86
+ .TP
87
+ \fB\-\-services\fR \fISERVICE\fP\[lB]\fB,\fR\.\.\.\[rB]
88
+ Filters \fBIP:PORT\fR or \fBHOST:PORT\fR pairs who\[cq]s ports are running one of the
89
+ specifiied services\.
90
+ .TP
91
+ \fB\-h\fR, \fB\-\-help\fR
92
+ Print help information
93
+ .SH EXAMPLES
94
+ .PP
95
+ Print \fBIP:PORT\fR pairs from the nmap XML file:
96
+ .PP
97
+ .RS 4
98
+ .EX
99
+ \[Do] ronin\-nmap dump \-\-print\-ip\-ports scan\.xml
100
+ .EE
101
+ .RE
102
+ .PP
103
+ Print \fBIP:PORT\fR pairs with ports 22, 80, or 443, from the nmap XML file:
104
+ .PP
105
+ .RS 4
106
+ .EX
107
+ \[Do] ronin\-nmap dump \-\-print\-ip\-ports \-\-ports 22,80,443 scan\.xml
108
+ .EE
109
+ .RE
110
+ .PP
111
+ Print \fBHOST:PORT\fR pairs from the nmap XML file:
112
+ .PP
113
+ .RS 4
114
+ .EX
115
+ \[Do] ronin\-nmap dump \-\-print\-host\-ports scan\.xml
116
+ .EE
117
+ .RE
118
+ .PP
119
+ Print target hostnames from the nmap XML file:
120
+ .PP
121
+ .RS 4
122
+ .EX
123
+ \[Do] ronin\-nmap dump \-\-print\-hosts \-\-with\-port 22 scan\.xml
124
+ .EE
125
+ .RE
126
+ .PP
127
+ Print URIs from the nmap XML file:
128
+ .PP
129
+ .RS 4
130
+ .EX
131
+ \[Do] ronin\-nmap dump \-\-print\-uris scan\.xml
132
+ .EE
133
+ .RE
134
+ .SH AUTHOR
135
+ .PP
136
+ Postmodern
137
+ .MT postmodern\.mod3\[at]gmail\.com
138
+ .ME
139
+ .SH SEE ALSO
140
+ .PP
141
+ .BR ronin\-nmap\-print (1)
@@ -0,0 +1,119 @@
1
+ # ronin-nmap-dump 1 "2023-03-01" Ronin Nmap "User Manuals"
2
+
3
+ ## NAME
4
+
5
+ ronin-nmap-dump - Dumps the scanned ports from nmap XML file(s).
6
+
7
+ ## SYNOPSIS
8
+
9
+ `ronin-nmap dump` [options] *XML_FILE* [...]
10
+
11
+ ## DESCRIPTION
12
+
13
+ Dumps the scanned ports from nmap XML files into a variety of formats. The
14
+ output formats include:
15
+
16
+ * IP
17
+ * Hostname
18
+ * `IP:PORT`
19
+ * `HOST:PORT`
20
+ * URI
21
+
22
+ The command also supports filtering the nmap targets by IP, IP range, domain,
23
+ OS, port, service, or NSE script.
24
+
25
+ ## ARGUMENTS
26
+
27
+ *XML_FILE*
28
+ : The nmap XML file to import.
29
+
30
+ ## OPTIONS
31
+
32
+ `--print-ips`
33
+ : Only print the IP addresses of the targets (ex: `192.168.1.1`).
34
+
35
+ `--print-hosts`
36
+ : Only print the hostnames of the targets (ex: `example.com`).
37
+
38
+ `--print-ip-ports`
39
+ : Print IP address and port pairs for each target (ex: `192.168.1.1:443`).
40
+ This is the default behavior.
41
+
42
+ `--print-host-ports`
43
+ : Print hostname and port pairs for each target (ex: `example.com:443`).
44
+
45
+ `--print-uris
46
+ : Print URIs for each target that has either `http` or `https` services
47
+ (ex: `https://example.com` or `http://example.com:8080`).
48
+
49
+ `--ip` *IP*
50
+ : Filters the targets by a specific IP address.
51
+
52
+ `--ip-range` *CIDR*
53
+ : Filter the targets by a CIDR IP range (ex: `192.168.1.0/24`).
54
+
55
+ `--domain` *DOMAIN*
56
+ : Filters the targets by a domain (ex: `example.com`).
57
+
58
+ `--with-os` *OS*
59
+ : Filters the targets by Operating System (ex: `Linux`, `Windows`, etc).
60
+
61
+ `--with-ports` {*PORT* \| *PORT1*`-`*PORT2*}`,`...
62
+ : Filter targets that have open ports in the port list.
63
+ The port list is a comma separated list of port numbers (`443`) or port
64
+ ranges (`8000-9000`).
65
+
66
+ `--with-service` *SERVICE*[`,`...]
67
+ : Filters targets who are running one of the specified services.
68
+
69
+ `--with-script` *SCRIPT*[`,`...]
70
+ : Filters targets that have the NSE script name(s).
71
+
72
+ `--with-script-output` *STRING*
73
+ : Filters targets that have NSE script output contain the string.
74
+
75
+ `--with-script-regex` `/`*REGEX*`/`
76
+ : Filters targets that have NSE script output that matches the regular
77
+ expression.
78
+
79
+ `-p`, `--ports` {*PORT* | *PORT1-PORT2*},...
80
+ : Filter `IP:PORT` or `HOST:PORT` pairs who's ports are in the gvien port list.
81
+ The port list is a comma separated list of port numbers (`443`) or port
82
+ ranges (`8000-9000`).
83
+
84
+ `--services` *SERVICE*[`,`...]
85
+ : Filters `IP:PORT` or `HOST:PORT` pairs who's ports are running one of the
86
+ specifiied services.
87
+
88
+ `-h`, `--help`
89
+ : Print help information
90
+
91
+ ## EXAMPLES
92
+
93
+ Print `IP:PORT` pairs from the nmap XML file:
94
+
95
+ $ ronin-nmap dump --print-ip-ports scan.xml
96
+
97
+ Print `IP:PORT` pairs with ports 22, 80, or 443, from the nmap XML file:
98
+
99
+ $ ronin-nmap dump --print-ip-ports --ports 22,80,443 scan.xml
100
+
101
+ Print `HOST:PORT` pairs from the nmap XML file:
102
+
103
+ $ ronin-nmap dump --print-host-ports scan.xml
104
+
105
+ Print target hostnames from the nmap XML file:
106
+
107
+ $ ronin-nmap dump --print-hosts --with-port 22 scan.xml
108
+
109
+ Print URIs from the nmap XML file:
110
+
111
+ $ ronin-nmap dump --print-uris scan.xml
112
+
113
+ ## AUTHOR
114
+
115
+ Postmodern <postmodern.mod3@gmail.com>
116
+
117
+ ## SEE ALSO
118
+
119
+ [ronin-nmap-print](ronin-nmap-print.1.md)