ruby-nmap 0.10.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.document +1 -0
  3. data/.editorconfig +11 -0
  4. data/.github/workflows/ruby.yml +31 -0
  5. data/ChangeLog.md +118 -71
  6. data/Gemfile +11 -5
  7. data/LICENSE.txt +1 -1
  8. data/README.md +88 -50
  9. data/Rakefile +5 -0
  10. data/UPGRADING.md +47 -0
  11. data/gemspec.yml +5 -5
  12. data/lib/nmap/command.rb +765 -0
  13. data/lib/nmap/version.rb +1 -1
  14. data/lib/nmap/xml/address.rb +38 -0
  15. data/lib/nmap/xml/cpe/url.rb +80 -0
  16. data/lib/nmap/xml/cpe.rb +47 -0
  17. data/lib/nmap/xml/hop.rb +22 -0
  18. data/lib/nmap/xml/host.rb +546 -0
  19. data/lib/nmap/xml/host_script.rb +26 -0
  20. data/lib/nmap/xml/hostname.rb +44 -0
  21. data/lib/nmap/xml/ip_id_sequence.rb +26 -0
  22. data/lib/nmap/xml/os.rb +131 -0
  23. data/lib/nmap/xml/os_class.rb +86 -0
  24. data/lib/nmap/xml/os_match.rb +22 -0
  25. data/lib/nmap/xml/port.rb +114 -0
  26. data/lib/nmap/xml/postscript.rb +26 -0
  27. data/lib/nmap/xml/prescript.rb +26 -0
  28. data/lib/nmap/xml/run_stat.rb +22 -0
  29. data/lib/nmap/xml/scan.rb +38 -0
  30. data/lib/nmap/xml/scan_task.rb +55 -0
  31. data/lib/nmap/xml/scanner.rb +22 -0
  32. data/lib/nmap/xml/script.rb +110 -0
  33. data/lib/nmap/xml/scripts.rb +33 -0
  34. data/lib/nmap/xml/sequence.rb +52 -0
  35. data/lib/nmap/xml/service.rb +172 -0
  36. data/lib/nmap/xml/status.rb +22 -0
  37. data/lib/nmap/xml/tcp_sequence.rb +48 -0
  38. data/lib/nmap/xml/tcp_ts_sequence.rb +26 -0
  39. data/lib/nmap/xml/traceroute.rb +73 -0
  40. data/lib/nmap/xml/uptime.rb +22 -0
  41. data/lib/nmap/xml.rb +31 -44
  42. data/spec/command_spec.rb +726 -0
  43. data/spec/fixtures/down_host_scan.xml +16 -0
  44. data/spec/{address_spec.rb → xml/address_spec.rb} +2 -2
  45. data/spec/{cpe → xml/cpe}/url_spec.rb +1 -1
  46. data/spec/{cpe_examples.rb → xml/cpe_examples.rb} +1 -1
  47. data/spec/{hop_spec.rb → xml/hop_spec.rb} +2 -2
  48. data/spec/{host_script_spec.rb → xml/host_script_spec.rb} +2 -2
  49. data/spec/{host_spec.rb → xml/host_spec.rb} +8 -8
  50. data/spec/{hostname_spec.rb → xml/hostname_spec.rb} +2 -2
  51. data/spec/{ip_id_sequence_spec.rb → xml/ip_id_sequence_spec.rb} +3 -3
  52. data/spec/{os_class_spec.rb → xml/os_class_spec.rb} +3 -3
  53. data/spec/{os_match_spec.rb → xml/os_match_spec.rb} +2 -2
  54. data/spec/{os_spec.rb → xml/os_spec.rb} +3 -3
  55. data/spec/{port_spec.rb → xml/port_spec.rb} +4 -5
  56. data/spec/{postscript_spec.rb → xml/postscript_spec.rb} +2 -2
  57. data/spec/{prescript_spec.rb → xml/prescript_spec.rb} +2 -2
  58. data/spec/{run_stat_spec.rb → xml/run_stat_spec.rb} +2 -2
  59. data/spec/{scan_spec.rb → xml/scan_spec.rb} +2 -2
  60. data/spec/{scan_task_spec.rb → xml/scan_task_spec.rb} +6 -6
  61. data/spec/{scanner_spec.rb → xml/scanner_spec.rb} +3 -3
  62. data/spec/xml/script_spec.rb +137 -0
  63. data/spec/xml/scripts_examples.rb +19 -0
  64. data/spec/{sequence_examples.rb → xml/sequence_examples.rb} +1 -0
  65. data/spec/{service_spec.rb → xml/service_spec.rb} +31 -5
  66. data/spec/{status_spec.rb → xml/status_spec.rb} +2 -2
  67. data/spec/{tcp_sequence_spec.rb → xml/tcp_sequence_spec.rb} +3 -3
  68. data/spec/{tcp_ts_sequence_spec.rb → xml/tcp_ts_sequence_spec.rb} +3 -3
  69. data/spec/{traceroute_spec.rb → xml/traceroute_spec.rb} +3 -3
  70. data/spec/{uptime_spec.rb → xml/uptime_spec.rb} +2 -2
  71. data/spec/xml_spec.rb +73 -44
  72. metadata +72 -66
  73. data/.travis.yml +0 -16
  74. data/lib/nmap/address.rb +0 -34
  75. data/lib/nmap/cpe/url.rb +0 -78
  76. data/lib/nmap/cpe.rb +0 -45
  77. data/lib/nmap/hop.rb +0 -20
  78. data/lib/nmap/host.rb +0 -587
  79. data/lib/nmap/host_script.rb +0 -18
  80. data/lib/nmap/hostname.rb +0 -42
  81. data/lib/nmap/ip_id_sequence.rb +0 -24
  82. data/lib/nmap/os.rb +0 -127
  83. data/lib/nmap/os_class.rb +0 -82
  84. data/lib/nmap/os_match.rb +0 -18
  85. data/lib/nmap/port.rb +0 -110
  86. data/lib/nmap/postscript.rb +0 -16
  87. data/lib/nmap/prescript.rb +0 -16
  88. data/lib/nmap/program.rb +0 -102
  89. data/lib/nmap/run_stat.rb +0 -20
  90. data/lib/nmap/scan.rb +0 -34
  91. data/lib/nmap/scan_task.rb +0 -53
  92. data/lib/nmap/scanner.rb +0 -18
  93. data/lib/nmap/scripts.rb +0 -71
  94. data/lib/nmap/sequence.rb +0 -50
  95. data/lib/nmap/service.rb +0 -170
  96. data/lib/nmap/status.rb +0 -18
  97. data/lib/nmap/task.rb +0 -387
  98. data/lib/nmap/tcp_sequence.rb +0 -46
  99. data/lib/nmap/tcp_ts_sequence.rb +0 -22
  100. data/lib/nmap/traceroute.rb +0 -71
  101. data/lib/nmap/uptime.rb +0 -20
  102. data/spec/scripts_examples.rb +0 -35
  103. data/spec/task_spec.rb +0 -150
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aad3443fe83a6bdd00408ad9c95f74249bd0d4e84a67d86ab2f9e3d301b1b949
4
- data.tar.gz: 3062ec23f7150260cd1be1bb4d82cf96bf149f6ed2471126aea86808ac0ff506
3
+ metadata.gz: c140058ce1941bb9671a06f6c35b32c702479601d00a9c21906fae39eb18cbf3
4
+ data.tar.gz: d94fbbffd46099d543aa8f27c0577fa8c387ff45d267911d8b47e5b5348f8500
5
5
  SHA512:
6
- metadata.gz: e125594be07aea783106ecc9342b7936016cb34bee18f0ead7a22f8eecb2c78bd2ccdbfd1d05d54cb9c17868fa43d542b1bd262d9340e0c8cc3129c72756ee7a
7
- data.tar.gz: 6aa87e42de1eaa60c84020e19142364d126c667a76ed5a906178a78fb4ec85bd997619cb21ab3bbadb903519c29b56571a183c372bfb94b43d3be1534078ac70
6
+ metadata.gz: 98bcdb056f50dc8640ef5b4c3e3eaf1daacc2055328f0fd1c995faec543abf81d2fac5da1290e91ec88a91ea8f9bdbbc9fa03b16c9f02709ed65078c9ceeea82
7
+ data.tar.gz: 444e4918a0debc3686c346456b38e7e9a2a12573144a83c01519c28253ecdee8ab331c9e5cc7d74dee61a224eb59aea0729140d42ae1c59f8a391449ed395ae3
data/.document CHANGED
@@ -1,3 +1,4 @@
1
1
  -
2
2
  ChangeLog.md
3
3
  LICENSE.txt
4
+ UPGRADING.md
data/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+ tab_width = 8
7
+ trim_trailing_whitespace = true
8
+
9
+ [{Gemfile,Rakefile,*.rb,*.gemspec,*.yml}]
10
+ indent_style = space
11
+ indent_size = 2
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - '2.7'
13
+ - '3.0'
14
+ - '3.1'
15
+ - jruby
16
+ - truffleruby
17
+ name: Ruby ${{ matrix.ruby }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install libxml2-dev and libxslt1-dev
25
+ run: |
26
+ sudo apt update -y && \
27
+ sudo apt install -y --no-install-recommends --no-install-suggests libxml2-dev libxslt1-dev
28
+ - name: Install dependencies
29
+ run: bundle install --jobs 4 --retry 3
30
+ - name: Run tests
31
+ run: bundle exec rake test
data/ChangeLog.md CHANGED
@@ -1,18 +1,61 @@
1
+ ### 1.0.0 / 2022-11-11
2
+
3
+ * Switched from [rprogram] to [command_mapper].
4
+ * Replaced `Nmap::Program` and `Nmap::Task` with {Nmap::Command}.
5
+ * Moved all XML classes under {Nmap::XML}.
6
+ * See [UPGRADING] for more details on how to upgrade from 0.10.0 to 1.0.0.
7
+
8
+ #### Nmap::Command
9
+
10
+ * Added support for the `--unique` option as `nmap.unique`.
11
+ * Added support for the `--resolve-all` option as `nmap.resolve_all`.
12
+ * Added support for the `--noninteractive` option as `nmap.non_interactive`.
13
+ * Added support for the `--proxies` option as `nmap.proxies`.
14
+ * Added support for the `--data` option as `nmap.data`.
15
+ * Added support for the `--data-string` option as `nmap.data_string`.
16
+ * Added support for the `--script-help` option as `nmap.script_help`.
17
+ * Added support for the `--script-args-file` option as `nmap.script_args_file`.
18
+ * Added support for the `--script-timeout` option as `nmap.script_timeout`.
19
+ * Added support for the `--initial-rtt-timeout` option as
20
+ `nmap.initial_rtt_timeout`.
21
+ * Added support for the `-vv` option as `nmap.extra_verbose`.
22
+ * Allow passing Integer values to `verbose:` or `nmap.verbose=` for
23
+ `-v`**level**.
24
+ * Greatly improved the validation of input values.
25
+ * Removed `#script_params` and `#script_params=` aliases for `#script_args` and
26
+ `#script_args=`.
27
+
28
+ #### Nmap::XML
29
+
30
+ * Removed the deprecated `Nmap::XML.load` method in favor of {Nmap::XML.parse}.
31
+ * Removed the `Nmap::XML#prescripts` alias to `Nmap::XML#prescript`.
32
+ * Removed the `Nmap::XML#postscripts` alias to `Nmap::XML#postscript`.
33
+ * Removed `Nmap::XML::Host#tcpsequence` in favor of
34
+ {Nmap::XML::Host#tcp_sequence}.
35
+ * Removed `Nmap::XML::Host#ipidsequence` in favor of
36
+ {Nmap::XML::Host#ip_id_sequence}.
37
+ * Removed `Nmap::XML::Host#tcptssequence` in favor of
38
+ {Nmap::XML::Host#tcp_ts_sequence}.
39
+ * Removed `Nmap::XML#inspect` method.
40
+ * Added {Nmap::XML::Script}.
41
+ * Removed `Nmap::XML::Scripts#script_data`.
42
+ * Changed {Nmap::XML::Scripts#scripts} to return {Nmap::XML::Script} objects.
43
+
1
44
  ### 0.10.0 / 2020-03-17
2
45
 
3
46
  * Added `Nmap::Task#exclude_ports` for the `--exclude-ports` option.
4
- * Added {Nmap::Status#reason_ttl}.
5
- * Added {Nmap::Port#reason_ttl}.
6
- * Added {Nmap::XML#task}.
7
- * Alias {Nmap::ScanTask#extra_info} to {Nmap::ScanTask#extrainfo}.
47
+ * Added `Nmap::Status#reason_ttl`.
48
+ * Added `Nmap::Port#reason_ttl`.
49
+ * Added `Nmap::XML#task`.
50
+ * Alias `Nmap::ScanTask#extra_info` to `Nmap::ScanTask#extrainfo`.
8
51
 
9
52
  ### 0.9.3 / 2018-05-01
10
53
 
11
54
  * Added missing `Nmap::Task#defeat_icmp_ratelimit` for the
12
55
  `--defeat-icmp-ratelimit` option.
13
56
  * Added missing `Nmap::Task#nsock_engine` for the `--nsock-engine` option.
14
- * Added the {Nmap::XML#prescripts} alias.
15
- * Added the {Nmap::XML#postscripts} alias.
57
+ * Added the `Nmap::XML#prescripts` alias.
58
+ * Added the `Nmap::XML#postscripts` alias.
16
59
  * Allow `Task#sctp_init_ping` to accept a port Range object.
17
60
  * Fixed a typo in the `Task#defeat_rst_ratelimit` name.
18
61
  * Fixed the option formatting of `Nmap::Task#syn_discovery`.
@@ -23,81 +66,81 @@
23
66
 
24
67
  ### 0.9.2 / 2017-01-13
25
68
 
26
- * Fix file descriptor leak in {Nmap::XML#initialize} by using
69
+ * Fix file descriptor leak in `Nmap::XML#initialize` by using
27
70
  `File.open(path) { |file| ... }` instead of `File.new(path)`, which keeps the
28
71
  file descriptor open until GC collects the `File` instance.
29
72
 
30
73
  ### 0.9.1 / 2016-07-18
31
74
 
32
- * Fixed {Nmap::Host#ipv6} when there are no `ipv6` type addresses.
33
- * Fixed {Nmap::OS#fingerprint} when there is no `osfingerprint` element.
75
+ * Fixed `Nmap::Host#ipv6` when there are no `ipv6` type addresses.
76
+ * Fixed `Nmap::OS#fingerprint` when there is no `osfingerprint` element.
34
77
 
35
78
  ### 0.9.0 / 2016-07-14
36
79
 
37
- * Added {Nmap::Address#vendor}.
38
- * Added {Nmap::Service#to_s}.
39
- * Added {Nmap::HostScript}.
40
- * Added {Nmap::Prescript}.
41
- * Added {Nmap::Postscript}.
42
- * Added {Nmap::XML#prescript}.
43
- * Added {Nmap::XML#postscript}.
80
+ * Added `Nmap::Address#vendor`.
81
+ * Added `Nmap::Service#to_s`.
82
+ * Added `Nmap::HostScript`.
83
+ * Added `Nmap::Prescript`.
84
+ * Added `Nmap::Postscript`.
85
+ * Added `Nmap::XML#prescript`.
86
+ * Added `Nmap::XML#postscript`.
44
87
  * Added `Nmap::Task#quiet` (aka `-v0`).
45
88
  * `#script_data` methods can now parse arbitrarily nested Arrays/Hashes.
46
- * Fixed {Nmap::CPE#each_cpe} to only match child `cpe` elements, not all
89
+ * Fixed `Nmap::CPE#each_cpe` to only match child `cpe` elements, not all
47
90
  `cpe` elements within the document.
48
- * Changed {Nmap::Service#to_s} to output product/version only if both are
91
+ * Changed `Nmap::Service#to_s` to output product/version only if both are
49
92
  present.
50
93
  * Changed `Nmap::Task#skip_discovery` to use `-Pn` instead of `-PN`, which was
51
94
  deprecated in nmap >= 7.00.
52
95
 
53
96
  ### 0.8.0 / 2014-04-16
54
97
 
55
- * Added {Nmap::XML#each_down_host}.
56
- * Added {Nmap::XML#down_hosts}.
57
- * Added {Nmap::XML#host}.
58
- * Added {Nmap::XML#up_host}.
59
- * Added {Nmap::XML#down_host}.
60
- * Added {Nmap::Host#hostname}.
61
- * Added {Nmap::Hostname#user?}.
62
- * Added {Nmap::Hostname#ptr?}.
63
- * Added {Nmap::Program.sudo_scan}.
64
- * Added {Nmap::Program#sudo_scan}.
65
- * Renamed {Nmap::XML.load} to {Nmap::XML.parse}.
98
+ * Added `Nmap::XML#each_down_host`.
99
+ * Added `Nmap::XML#down_hosts`.
100
+ * Added `Nmap::XML#host`.
101
+ * Added `Nmap::XML#up_host`.
102
+ * Added `Nmap::XML#down_host`.
103
+ * Added `Nmap::Host#hostname`.
104
+ * Added `Nmap::Hostname#user?`.
105
+ * Added `Nmap::Hostname#ptr?`.
106
+ * Added `Nmap::Program.sudo_scan`.
107
+ * Added `Nmap::Program#sudo_scan`.
108
+ * Renamed `Nmap::XML.load` to `Nmap::XML.parse`.
66
109
  * Fixed a typo in the `--privileged` flag (@BrentonEarl)
67
110
  * Allow multiple values in the `--script` flag.
68
- * Alias {Nmap::Task#script_params} to `script_args`.
111
+ * Alias `Nmap::Task#script_params` to `script_args`.
69
112
 
70
113
  ### 0.7.0 / 2014-05-09
71
114
 
72
- * Added {Nmap::CPE}.
73
- * Added {Nmap::CPE::URL}.
74
- * Added {Nmap::Hop}.
75
- * Added {Nmap::Hostname}.
76
- * Added {Nmap::Traceroute}.
77
- * Added {Nmap::Host#traceroute}.
78
- * Added {Nmap::Host#uptime}. (@roodee)
79
- * Added {Nmap::Service#ssl?}.
80
- * Added {Nmap::Service#protocol}.
81
- * Added {Nmap::Service#extra_info}.
82
- * Added {Nmap::Service#os_type}.
83
- * Added {Nmap::Service#device_type}.
84
- * Added {Nmap::Service#fingerprint}. (@roodee)
85
- * Added {Nmap::Uptime}. (@roodee)
86
- * Added {Nmap::RunStat}. (@roodee)
87
- * Added {Nmap::XML.load}. (@vzctl)
88
- * Added {Nmap::XML.open}.
89
- * Added {Nmap::XML#each_run_stat}.
90
- * Added {Nmap::XML#run_stats}.
91
- * Added {Nmap::XML#each_task}.
92
- * Fixed xpath bug in {Nmap::OS#each_class} (@roodee).
115
+ * Added `Nmap::CPE`.
116
+ * Added `Nmap::CPE::URL`.
117
+ * Added `Nmap::Hop`.
118
+ * Added `Nmap::Hostname`.
119
+ * Added `Nmap::Traceroute`.
120
+ * Added `Nmap::Host#traceroute`.
121
+ * Added `Nmap::Host#uptime`. (@roodee)
122
+ * Added `Nmap::Service#ssl?`.
123
+ * Added `Nmap::Service#protocol`.
124
+ * Added `Nmap::Service#extra_info`.
125
+ * Added `Nmap::Service#os_type`.
126
+ * Added `Nmap::Service#device_type`.
127
+ * Added `Nmap::Service#fingerprint`. (@roodee)
128
+ * Added `Nmap::Uptime`. (@roodee)
129
+ * Added `Nmap::RunStat`. (@roodee)
130
+ * Added `Nmap::XML.load`. (@vzctl)
131
+ * Added `Nmap::XML.open`.
132
+ * Added `Nmap::XML#each_run_stat`.
133
+ * Added `Nmap::XML#run_stats`.
134
+ * Added `Nmap::XML#each_task`.
135
+ * Fixed xpath bug in `Nmap::OS#each_class` (@roodee).
93
136
 
94
137
  ### 0.6.0 / 2012-11-07
95
138
 
96
- * Added {Nmap::Service}.
97
- * Renamed `Nmap::IpidSequence` to {Nmap::IpIdSequence}.
98
- * Renamed {Nmap::Host#ipidsequence} to {Nmap::Host#ip_id_sequence}.
99
- * Renamed {Nmap::Host#tcpsequence} to {Nmap::Host#tcp_sequence}.
100
- * Renamed {Nmap::Host#tcptssequence} to {Nmap::Host#tcp_ts_sequence}.
139
+ * Added `Nmap::Service`.
140
+ * Renamed `Nmap::IpidSequence` to `Nmap::IpIdSequence`.
141
+ * Renamed `Nmap::Host#ipidsequence` to `Nmap::Host#ip_id_sequence`.
142
+ * Renamed `Nmap::Host#tcpsequence` to `Nmap::Host#tcp_sequence`.
143
+ * Renamed `Nmap::Host#tcptssequence` to `Nmap::Host#tcp_ts_sequence`.
101
144
 
102
145
  ### 0.5.1 / 2012-05-27
103
146
 
@@ -108,20 +151,20 @@
108
151
 
109
152
  * Require nokogiri ~> 1.3.
110
153
  * Require rprogram ~> 0.3.
111
- * `ip_scan` in {Nmap::Task} should map to `-sO` (thanks corvus).
154
+ * `ip_scan` in `Nmap::Task` should map to `-sO` (thanks corvus).
112
155
 
113
156
  ### 0.4.1 / 2010-11-23
114
157
 
115
- * Fixed a bug in {Nmap::XML#each} where it was calling `each_up_hosts`,
116
- and not {Nmap::XML#each_up_host}.
117
- * {Nmap::OS#each_class}, {Nmap::OS#each_match}, {Nmap::XML#each_host} and
118
- {Nmap::XML#each_up_host} now return an Enumerator object if no block
158
+ * Fixed a bug in `Nmap::XML#each` where it was calling `each_up_hosts`,
159
+ and not `Nmap::XML#each_up_host`.
160
+ * `Nmap::OS#each_class`, `Nmap::OS#each_match`, `Nmap::XML#each_host` and
161
+ `Nmap::XML#each_up_host` now return an Enumerator object if no block
119
162
  is given.
120
163
  * Use `yield` instead of `block.call` for a slight performance improvement.
121
164
 
122
165
  ### 0.4.0 / 2010-11-17
123
166
 
124
- * Added new options to {Nmap::Task} based on nmap 5.21:
167
+ * Added new options to `Nmap::Task` based on nmap 5.21:
125
168
  * `-PY` - `nmap.sctp_init_ping`
126
169
  * `-PR` - `nmap.arp_ping`
127
170
  * `-sY` - `nmap.sctp_init_scan`
@@ -145,27 +188,27 @@
145
188
 
146
189
  ### 0.3.0 / 2010-11-08
147
190
 
148
- * Added {Nmap::Host#scripts}.
149
- * Added {Nmap::Scripts#scripts Nmap::Port#scripts}.
191
+ * Added `Nmap::Host#scripts`.
192
+ * Added `Nmap::Port#scripts`.
150
193
 
151
194
  ### 0.2.0 / 2010-10-29
152
195
 
153
196
  * Require nokogiri >= 1.3.0.
154
197
  * Require rprogram ~> 0.2.0.
155
- * Added {Nmap::XML#tasks}.
156
- * Added {Nmap::Scanner#start_time}.
157
- * Added {Nmap::ScanTask#duration}.
158
- * Added {Nmap::Host#start_time}.
159
- * Added {Nmap::Host#end_time}.
198
+ * Added `Nmap::XML#tasks`.
199
+ * Added `Nmap::Scanner#start_time`.
200
+ * Added `Nmap::ScanTask#duration`.
201
+ * Added `Nmap::Host#start_time`.
202
+ * Added `Nmap::Host#end_time`.
160
203
  * Allow `Nmap::Tasks#ports=` to accept port ranges.
161
- * Omit the `-p` option if no ports are given to {Nmap::Task}.
204
+ * Omit the `-p` option if no ports are given to `Nmap::Task`.
162
205
  * Have the `Nmap::Host#each_*` methods return an `Enumerator` object if no
163
206
  block is given.
164
207
 
165
208
  ### 0.1.1 / 2010-01-02
166
209
 
167
210
  * Require RProgram >= 0.1.8.
168
- * Adds `sudo` and `sudo=` instance methods to {Nmap::Task}.
211
+ * Adds `sudo` and `sudo=` instance methods to `Nmap::Task`.
169
212
 
170
213
  ### 0.1.0 / 2009-11-13
171
214
 
@@ -173,3 +216,7 @@
173
216
  * Provides a Ruby interface for running Nmap.
174
217
  * Provides a Parser for enumerating Nmap XML scan files.
175
218
 
219
+ [rprogram]: https://github.com/postmodern/rprogram#readme
220
+ [command_mapper]: https://github.com/postmodern/command_mapper.rb#readme
221
+
222
+ [UPGRADING]: https://github.com/postmodern/ruby-nmap/blob/main/UPGRADING.md
data/Gemfile CHANGED
@@ -2,13 +2,19 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ # gem 'command_mapper', '~> 0.3', github: 'postmodern/command_mapper.rb',
6
+ # branch: '0.3.0'
7
+
5
8
  group :development do
6
9
  gem 'rake'
7
- gem 'rubygems-tasks', '~> 0.2'
8
- gem 'rspec', '~> 3.0'
10
+ gem 'rubygems-tasks', '~> 0.2'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'simplecov', '~> 0.20'
9
13
 
10
- gem 'json'
11
- gem 'simplecov', '~> 0.7'
12
14
  gem 'kramdown'
13
- gem 'yard', '~> 0.9'
15
+ gem 'redcarpet', platform: :mri
16
+ gem 'yard', '~> 0.9'
17
+ gem 'yard-spellcheck', require: false
18
+
19
+ gem 'dead_end', require: false
14
20
  end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2020 Postmodern
1
+ Copyright (c) 2009-2022 Postmodern
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,102 +1,140 @@
1
1
  # ruby-nmap
2
2
 
3
- * [Source](https://github.com/sophsec/ruby-nmap/)
4
- * [Issues](https://github.com/sophsec/ruby-nmap/issues)
3
+ [![CI](https://github.com/postmodern/ruby-nmap/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/ruby-nmap/actions/workflows/ruby.yml)
4
+ [![Code Climate](https://codeclimate.com/github/postmodern/ruby-nmap.svg)](https://codeclimate.com/github/postmodern/ruby-nmap)
5
+ [![Gem Version](https://badge.fury.io/rb/ruby-nmap.svg)](https://badge.fury.io/rb/ruby-nmap)
6
+
7
+ * [Source](https://github.com/postmodern/ruby-nmap/)
8
+ * [Issues](https://github.com/postmodern/ruby-nmap/issues)
5
9
  * [Documentation](http://rubydoc.info/gems/ruby-nmap/frames)
6
- * [Email](mailto:postmodern.mod3 at gmail.com)
7
- * [![Build Status](https://travis-ci.org/sophsec/ruby-nmap.svg)](https://travis-ci.org/sophsec/ruby-nmap)
8
10
 
9
11
  ## Description
10
12
 
11
- A Ruby interface to [nmap], the exploration tool and security / port scanner.
13
+ A Ruby API to [nmap], the exploration tool and security / port scanner.
14
+ Allows automating nmap and parsing nmap XML files.
12
15
 
13
16
  ## Features
14
17
 
15
- * Provides a Ruby interface for running nmap.
18
+ * Provides a Ruby API for automating nmap.
16
19
  * Provides a Parser for enumerating nmap XML scan files.
20
+ * Supports the full [Nmap XML DTD][nmap-dtd].
17
21
 
18
22
  ## Examples
19
23
 
20
24
  Run Nmap from Ruby:
21
25
 
22
- require 'nmap/program'
23
-
24
- Nmap::Program.scan do |nmap|
25
- nmap.syn_scan = true
26
- nmap.service_scan = true
27
- nmap.os_fingerprint = true
28
- nmap.xml = 'scan.xml'
29
- nmap.verbose = true
30
-
31
- nmap.ports = [20,21,22,23,25,80,110,443,512,522,8080,1080]
32
- nmap.targets = '192.168.1.*'
33
- end
26
+ ```ruby
27
+ require 'nmap/command'
28
+
29
+ Nmap::Command.run do |nmap|
30
+ nmap.connect_scan = true
31
+ nmap.service_scan = true
32
+ nmap.output_xml = 'scan.xml'
33
+ nmap.verbose = true
34
+
35
+ nmap.ports = [20, 21, 22, 23, 25, 80, 110, 443, 512, 522, 8080, 1080]
36
+ nmap.targets = '192.168.1.*'
37
+ end
38
+ ```
34
39
 
35
40
  Run `sudo nmap` from Ruby:
36
41
 
37
- require 'nmap/program'
42
+ ```ruby
43
+ require 'nmap/command'
38
44
 
39
- Nmap::Program.sudo_scan do |nmap|
40
- nmap.syn_scan = true
41
- # ...
42
- end
45
+ Nmap::Command.sudo do |nmap|
46
+ nmap.syn_scan = true
47
+ nmap.os_fingerprint = true
48
+ nmap.service_scan = true
49
+ nmap.output_xml = 'scan.xml'
50
+ nmap.verbose = true
51
+
52
+ nmap.ports = [20, 21, 22, 23, 25, 80, 110, 443, 512, 522, 8080, 1080]
53
+ nmap.targets = '192.168.1.*'
54
+ end
55
+ ```
43
56
 
44
57
  Parse Nmap XML scan files:
45
58
 
46
- require 'nmap/xml'
59
+ ```ruby
60
+ require 'nmap/xml'
47
61
 
48
- Nmap::XML.new('scan.xml') do |xml|
49
- xml.each_host do |host|
50
- puts "[#{host.ip}]"
51
-
52
- host.each_port do |port|
53
- puts " #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"
54
- end
55
- end
62
+ Nmap::XML.open('scan.xml') do |xml|
63
+ xml.each_host do |host|
64
+ puts "[#{host.ip}]"
65
+
66
+ host.each_port do |port|
67
+ puts " #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"
56
68
  end
69
+ end
70
+ end
71
+ ```
57
72
 
58
73
  Print NSE script output from an XML scan file:
59
74
 
60
- require 'nmap/xml'
75
+ ```ruby
76
+ require 'nmap/xml'
61
77
 
62
- Nmap::XML.new('nse.xml') do |xml|
63
- xml.each_host do |host|
64
- puts "[#{host.ip}]"
78
+ Nmap::XML.open('nse.xml') do |xml|
79
+ xml.each_host do |host|
80
+ puts "[#{host.ip}]"
65
81
 
66
- host.scripts.each do |name,output|
67
- output.each_line { |line| puts " #{line}" }
68
- end
82
+ host.scripts.each do |name,output|
83
+ output.each_line { |line| puts " #{line}" }
84
+ end
69
85
 
70
- host.each_port do |port|
71
- puts " [#{port.number}/#{port.protocol}]"
86
+ host.each_port do |port|
87
+ puts " [#{port.number}/#{port.protocol}]"
72
88
 
73
- port.scripts.each do |name,output|
74
- puts " [#{name}]"
89
+ port.scripts.each do |id,script|
90
+ puts " [#{id}]"
75
91
 
76
- output.each_line { |line| puts " #{line}" }
77
- end
78
- end
92
+ script.output.each_line { |line| puts " #{line}" }
79
93
  end
80
94
  end
95
+ end
96
+ end
97
+ ```
81
98
 
82
99
  ## Requirements
83
100
 
84
101
  * [ruby] >= 2.0.0
85
102
  * [nmap] >= 5.00
86
103
  * [nokogiri] ~> 1.3
87
- * [rprogram] ~> 0.3
104
+ * [command_mapper] ~> 0.3
88
105
 
89
106
  ## Install
90
107
 
91
- $ gem install ruby-nmap
108
+ * Debian / Ubuntu:
109
+
110
+ ```shell
111
+ $ sudo apt install nmap
112
+ ```
113
+
114
+ * Fedora / RedHat:
115
+
116
+ ```shell
117
+ $ sudo dnf install nmap
118
+ ```
119
+
120
+ * Homebrew:
121
+
122
+ ```shell
123
+ $ brew install nmap
124
+ ```
125
+
126
+ ```shell
127
+ $ gem install ruby-nmap
128
+ ```
92
129
 
93
130
  ## License
94
131
 
95
- Copyright (c) 2009-2020 Postmodern
132
+ Copyright (c) 2009-2022 Postmodern
96
133
 
97
134
  See {file:LICENSE.txt} for license information.
98
135
 
99
136
  [nmap]: http://www.insecure.org/
100
137
  [ruby]: https://www.ruby-lang.org/
101
138
  [nokogiri]: http://nokogiri.rubyforge.org/
102
- [rprogram]: https://github.com/postmodern/rprogram#readme
139
+ [command_mapper]: https://github.com/postmodern/command_mapper.rb#readme
140
+ [nmap-dtd]: https://nmap.org/book/nmap-dtd.html
data/Rakefile CHANGED
@@ -32,3 +32,8 @@ file 'spec/fixtures/scan.xml' do |t|
32
32
  puts ">>> Scanning scanme.nmap.org ..."
33
33
  sh "sudo nmap -v -sS -sU -A -O --script ssh2-enum-algos,ssh-hostkey -oX #{t.name} scanme.nmap.org"
34
34
  end
35
+
36
+ file 'spec/fixtures/down_host_scan.xml' do |t|
37
+ puts ">>> Scanning 225.0.0.1 ..."
38
+ sh "sudo nmap -v -sS -oX #{t.name} 225.0.0.1"
39
+ end
data/UPGRADING.md ADDED
@@ -0,0 +1,47 @@
1
+ # Migration Guide
2
+
3
+ ## 0.10.0 -> 1.0.0
4
+
5
+ ### `Nmap::Program`/`Namp::Task` -> `Nmap::Command`
6
+
7
+ * Replace all method calls to `Nmap::Program.scan` with `Nmap::Command.run`.
8
+ * Replace all method calls to `Nmap::Program.sudo_scan` with `Nmap::Command.sudo`.
9
+ * Rename all instances of `raw_ip` with `send_ip`.
10
+ * Rename all instances of `raw_ethernet` to `send_eth`.
11
+ * Rename all instances of `disable_stylesheet` to `no_stylesheet`.
12
+ * Rename all instances of `nmap_stylesheet` to `webxml`.
13
+ * Rename all instances of `append` to `append_output`.
14
+ * Rename all instances of `save` to `output_normal`.
15
+ * Rename all instances of `grepable` to `output_grepable`.
16
+ * Rename all instances of `skiddie` to `output_skiddie`.
17
+ * Rename all instances of `xml` to `output_xml`.
18
+ * Rename all instances of `script_params` to `script_args`.
19
+ * Remove any instances of the `:interactive` option or `nmap.interactive`, as
20
+ the `--interactive` option is no longer supported by nmap.
21
+
22
+ ### `Nmap::XML`
23
+
24
+ * `Nmap::XML.new` now only accepts a parsed `Nokogiri::XML::Document` object.
25
+ Use `Nmap::XML.open` or `Nmap::XML.parse` if you wish to parse XML files or
26
+ strings.
27
+ * Replace any method calls to `Nmap::XML.load` with {Nmap::XML.parse}.
28
+ * Rename any method calls to `` to `tcp_sequence`.
29
+ * Rename any method calls to `tcpsequence` to `tcp_sequence`.
30
+ * Rename any method calls to `ipidsequence` to `ip_id_sequence`.
31
+ * Rename any method calls to `tcptssequence` to `tcp_ts_sequence`.
32
+ * Rename any method calls to `prescripts` to `prescript`.
33
+ * Rename any method calls to `postscripts` to `postscript`.
34
+ * The [scripts][Nmap::XML::Scripts#scripts] method now returns an Array of
35
+ [Nmap::XML::Script] objects, instead of raw script output Strings.
36
+ In order to access the raw script output Strings, call the
37
+ [output][Nmap::XML::Script#output] method on each returned [Nmap::XML::Script]
38
+ objects instead.
39
+ * The `script_data` method has been removed.
40
+ In order to get the script's structured data, call
41
+ the [data][Nmap::XML::Script#data] method on each returned [Nmap::XML::Script]
42
+ objects instead.
43
+ * Rename any method calls to `extrainfo` to `extra_info`.
44
+
45
+ [Nmap::XML::Scripts#scripts]: https://rubydoc.info/gems/ruby-nmap/Nmap/XML/Scripts.html#scripts-instance_method
46
+ [Nmap::XML::Script]: https://rubydoc.info/gems/ruby-nmap/Nmap/XML/Script.html
47
+ [Nmap::XML::Script#output]: https://rubydoc.info/gems/ruby-nmap/Nmap/XML/Script.html#output-instance_method
data/gemspec.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  name: ruby-nmap
2
- summary: A Ruby interface to Nmap.
2
+ summary: A Ruby API to nmap.
3
3
  description:
4
- A Ruby interface to Nmap, the exploration tool and security / port
5
- scanner.
4
+ A Ruby API to nmap, the exploration tool and security / port
5
+ scanner. Allows automating nmap and parsing nmap XML files.
6
6
 
7
7
  license: MIT
8
8
  authors: Postmodern
9
9
  email: postmodern.mod3@gmail.com
10
- homepage: https://github.com/sophsec/ruby-nmap#readme
10
+ homepage: https://github.com/postmodern/ruby-nmap#readme
11
11
  has_yard: true
12
12
 
13
13
  required_ruby_version: ">= 2.0.0"
@@ -16,7 +16,7 @@ requirements: nmap >= 5.00
16
16
 
17
17
  dependencies:
18
18
  nokogiri: ~> 1.3
19
- rprogram: ~> 0.3
19
+ command_mapper: ~> 0.3
20
20
 
21
21
  development_dependencies:
22
22
  bundler: ~> 2.0