ruby-nmap 0.10.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +122 -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 +12 -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
data/lib/nmap/sequence.rb DELETED
@@ -1,50 +0,0 @@
1
- module Nmap
2
- #
3
- # Base class for all Sequence classes.
4
- #
5
- # @since 0.5.0
6
- #
7
- class Sequence
8
-
9
- #
10
- # Creates a new sequence object.
11
- #
12
- # @param [Nokogiri::XML::Node] node
13
- # The node that contains the sequence information.
14
- #
15
- # @since 0.5.0
16
- #
17
- def initialize(node)
18
- @node = node
19
- end
20
-
21
- #
22
- # The description of the sequence.
23
- #
24
- # @return [String]
25
- # The sequence class from nmap.
26
- #
27
- # @since 0.5.0
28
- #
29
- def description
30
- @description ||= @node['class']
31
- end
32
-
33
- #
34
- # The values within the sequence.
35
- #
36
- # @return [Array<Numeric>]
37
- # A sample of sequence numbers taken by nmap.
38
- #
39
- # @since 0.5.0
40
- #
41
- def values
42
- @values ||= if @node['values']
43
- @node['values'].split(',').map { |value| value.to_i(16) }
44
- else
45
- []
46
- end
47
- end
48
-
49
- end
50
- end
data/lib/nmap/service.rb DELETED
@@ -1,170 +0,0 @@
1
- require 'nmap/cpe'
2
-
3
- module Nmap
4
- #
5
- # Wraps a `service` XML element.
6
- #
7
- # @since 0.6.0
8
- #
9
- class Service
10
-
11
- include CPE
12
-
13
- #
14
- # Creates a new OS object.
15
- #
16
- # @param [Nokogiri::XML::Node] node
17
- # The node that contains the OS guessing information.
18
- #
19
- def initialize(node)
20
- @node = node
21
- end
22
-
23
- #
24
- # The name of the service.
25
- #
26
- # @return [String]
27
- # The service name.
28
- #
29
- def name
30
- @name ||= @node.get_attribute('name')
31
- end
32
-
33
- #
34
- # Determines if the service requires SSL.
35
- #
36
- # @return [Boolean]
37
- # Checks whether the `tunnel` XML attribute is `ssl`.
38
- #
39
- # @since 0.7.0
40
- #
41
- def ssl?
42
- (@ssl ||= @node['tunnel']) == 'ssl'
43
- end
44
-
45
- #
46
- # The application protocol used by the service.
47
- #
48
- # @return [String]
49
- # The `proto` XML attribute.
50
- #
51
- # @since 0.7.0
52
- #
53
- def protocol
54
- @protocol ||= @node['proto']
55
- end
56
-
57
- #
58
- # The product of the service.
59
- #
60
- # @return [String]
61
- # The product name.
62
- #
63
- def product
64
- @product ||= @node.get_attribute('product')
65
- end
66
-
67
- #
68
- # The version of the service.
69
- #
70
- # @return [String]
71
- # The service version.
72
- #
73
- def version
74
- @version ||= @node.get_attribute('version')
75
- end
76
-
77
- #
78
- # The extra information from the service scan.
79
- #
80
- # @return [String]
81
- # The `extrainfo` XML attribute.
82
- #
83
- # @since 0.7.0
84
- #
85
- def extra_info
86
- @extra_info ||= @node['extrainfo']
87
- end
88
-
89
- #
90
- # The hostname reported by the service.
91
- #
92
- # @return [String]
93
- # The reported hostname.
94
- #
95
- def hostname
96
- @hostname ||= @node.get_attribute('hostname')
97
- end
98
-
99
- #
100
- # The reported OS type.
101
- #
102
- # @return [String]
103
- # The `ostype` XML attribute.
104
- #
105
- # @since 0.7.0
106
- #
107
- def os_type
108
- @os_type ||= @node['ostype']
109
- end
110
-
111
- #
112
- # The reported device type.
113
- #
114
- # @return [String]
115
- # The `devicetype` XML attribute.
116
- #
117
- # @since 0.7.0
118
- #
119
- def device_type
120
- @device_type ||= @node['devicetype']
121
- end
122
-
123
- #
124
- # The fingerprint method used to identify the service.
125
- #
126
- # @return [Symbol]
127
- # The fingerprint method.
128
- #
129
- def fingerprint_method
130
- @fingerprint_method ||= @node.get_attribute('method').to_sym
131
- end
132
-
133
- #
134
- # The actual fingerprint
135
- #
136
- # @return [String]
137
- # The fingerprint
138
- #
139
- # @since 0.7.0
140
- #
141
- def fingerprint
142
- @fingerprint ||= @node.get_attribute('servicefp')
143
- end
144
-
145
- #
146
- # The confidence score of the service fingerprinting.
147
- #
148
- # @return [Integer]
149
- # The confidence score.
150
- #
151
- def confidence
152
- @confidence ||= @node.get_attribute('conf').to_i
153
- end
154
-
155
- #
156
- # Converts the service to a String.
157
- #
158
- # @return [String]
159
- # String containing {#product} and {#version}, or {#name}.
160
- #
161
- def to_s
162
- if (product && version)
163
- "#{product} #{version}"
164
- else
165
- name
166
- end
167
- end
168
-
169
- end
170
- end
data/lib/nmap/status.rb DELETED
@@ -1,18 +0,0 @@
1
- module Nmap
2
- #
3
- # Represents the Status of a {Host}.
4
- #
5
- class Status < Struct.new(:state, :reason, :reason_ttl)
6
-
7
- #
8
- # Converts the status to a String.
9
- #
10
- # @return [String]
11
- # The state.
12
- #
13
- def to_s
14
- self.state.to_s
15
- end
16
-
17
- end
18
- end
data/lib/nmap/task.rb DELETED
@@ -1,387 +0,0 @@
1
- require 'rprogram/task'
2
-
3
- module Nmap
4
- #
5
- # ## Nmap options:
6
- #
7
- # ### Target Specifications:
8
- #
9
- # * `-iL` - `nmap.target_file`
10
- # * `-iR` - `nmap.random_targets`
11
- # * `--exclude` - `nmap.exclude`
12
- # * `--excludefile` - `nmap.exclude_file`
13
- #
14
- # ### Host Discovery:
15
- #
16
- # * `-sL` - `nmap.list`
17
- # * `-sn` - `nmap.ping`
18
- # * `-Pn` - `nmap.skip_discovery`
19
- # * `-PS` - `nmap.syn_discovery`
20
- # * `-PA` - `nmap.ack_discovery`
21
- # * `-PU` - `nmap.udp_discovery`
22
- # * '-PY' - `nmap.sctp_init_ping`
23
- # * `-PE` - `nmap.icmp_echo_discovery`
24
- # * `-PP` - `nmap.icmp_timestamp_discovery`
25
- # * `-PM` - `nmap.icmp_netmask_discovery`
26
- # * `-PO` - `nmap.ip_ping`
27
- # * `-PR` - `nmap.arp_ping`
28
- # * `--traceroute` - `nmap.traceroute`
29
- # * `-n` - `nmap.disable_dns`
30
- # * `-R` - `nmap.enable_dns`
31
- # * `--systems-dns` - `nmap.systems_dns`
32
- # * `--dns-servers` - `nmap.dns_servers`
33
- #
34
- # ### Port Scanning Techniques:
35
- #
36
- # * `-sS` - `nmap.syn_scan`
37
- # * `-sT` - `nmap.connect_scan`
38
- # * `-sU` - `nmap.udp_scan`
39
- # * `-sY` - `nmap.sctp_init_scan`
40
- # * `-sN` - `nmap.null_scan`
41
- # * `-sF` - `nmap.fin_scan`
42
- # * `-sX` - `nmap.xmas_scan`
43
- # * `-sA` - `nmap.ack_scan`
44
- # * `-sW` - `nmap.window_scan`
45
- # * `-sM` - `nmap.maimon_scan`
46
- # * `--scanflags` - `nmap.tcp_scan_flags`
47
- # * `-sZ` - `nmap.sctp_cookie_echo_scan`
48
- # * `-sI` - `nmap.idle_scan`
49
- # * `-sO` - `nmap.ip_scan`
50
- # * `-b` - `nmap.ftp_bounce_scan`
51
- #
52
- # ### Port Specification and Scan Order:
53
- #
54
- # * `-p` - `nmap.ports`
55
- # * `--exclude-ports` - `nmap.exclude_ports`
56
- # * `-F` - `nmap.fast`
57
- # * `-r` - `nmap.consecutively`
58
- # * `--top-ports` - `nmap.top_ports`
59
- # * `--port-ratio` - `nmap.port_ratio`
60
- #
61
- # ### Service/Version Detection:
62
- #
63
- # * `-sV` - `nmap.service_scan`
64
- # * `--allports` - `nmap.all_ports`
65
- # * `--version-intensity` - `nmap.version_intensity`
66
- # * `--version-light` - `nmap.version_light`
67
- # * `--version-all` - `nmap.version_all`
68
- # * `--version-trace` - `nmap.version_trace`
69
- # * `-sR` - `nmap.rpc_scan`
70
- #
71
- # ### Script Scan:
72
- #
73
- # * `-sC` - `nmap.default_script`
74
- # * `--script` - `nmap.script`
75
- # * `--script-args` - `nmap.script_params`
76
- # * `--script-trace` - `nmap.script_trace`
77
- # * `--script-updatedb` - `nmap.update_scriptdb`
78
- #
79
- # ### OS Detection:
80
- #
81
- # * `-O` - `nmap.os_fingerprint`
82
- # * `--osscan-limit` - `nmap.limit_os_scan`
83
- # * `--osscan-guess` - `nmap.max_os_scan`
84
- #
85
- # ### Timing and Performance:
86
- #
87
- # * `--min-hostgroup` - `nmap.min_host_group`
88
- # * `--max-hostgroup` - `nmap.max_host_group`
89
- # * `--min-parallelism` - `nmap.min_parallelism`
90
- # * `--max-parallelism` - `nmap.max_parallelism`
91
- # * `--min-rtt-timeout` - `nmap.min_rtt_timeout`
92
- # * `--max-rtt-timeout` - `nmap.max_rtt_timeout`
93
- # * `--max-retries` - `nmap.max_retries`
94
- # * `--host-timeout` - `nmap.host_timeout`
95
- # * `--scan-delay` - `nmap.scan_delay`
96
- # * `--max-scan-delay` - `nmap.max_scan_delay`
97
- # * `--min-rate` - `nmap.min_rate`
98
- # * `--max-rate` - `nmap.max_rate`
99
- # * `--defeat-rst-ratelimit` - `nmap.defeat_rst_ratelimit`
100
- # * `--defeat-icmp-ratelimit` - `nmap.defeat_icmp_ratelimit`
101
- # * `--nsock-engine` - `nmap.nsock_engine`
102
- # * `-T` - `nmap.timing_template`
103
- # * `-T0` - `nmap.paranoid_timing`
104
- # * `-T1` - `nmap.sneaky_timing`
105
- # * `-T2` - `nmap.polite_timing`
106
- # * `-T3` - `nmap.normal_timing`
107
- # * `-T4` - `nmap.aggressive_timing`
108
- # * `-T5` - `nmap.insane_timing`
109
- #
110
- # ### Firewall/IDS Evasion and Spoofing:
111
- #
112
- # * `-f` - `nmap.packet_fragments`
113
- # * `--mtu` - `nmap.mtu`
114
- # * `-D` - `nmap.decoys`
115
- # * `-S` - `nmap.spoof`
116
- # * `-e` - `nmap.interface`
117
- # * `-g` - `nmap.source_port`
118
- # * `--data-length` - `nmap.data_length`
119
- # * `--ip-options` - `nmap.ip_options`
120
- # * `--ttl` - `nmap.ttl`
121
- # * `--randomize-hosts` - `nmap.randomize_hosts`
122
- # * `--spoof-mac` - `nmap.spoof_mac`
123
- # * `--badsum` - `nmap.bad_checksum`
124
- # * `--adler32` - `nmap.sctp_adler32`
125
- #
126
- # ### Output:
127
- #
128
- # * `-oN` - `nmap.save`
129
- # * `-oX` - `nmap.xml`
130
- # * `-oS` - `nmap.skiddie`
131
- # * `-oG` - `nmap.grepable`
132
- # * `-oA` - `nmap.output_all`
133
- #
134
- # ### Verbosity and Debugging:
135
- #
136
- # * `-v` - `nmap.verbose`
137
- # * `-v0` - `nmap.quiet`
138
- # * `-d` - `nmap.debug`
139
- # * `--reason` - `nmap.show_reason`
140
- # * `--stats-every` - `nmap.stats_every`
141
- # * `--packet-trace` - `nmap.show_packets`
142
- # * `--open` - `nmap.show_open_ports`
143
- # * `--iflist` - `nmap.show_interfaces`
144
- # * `--log-errors` - `nmap.show_log_errors`
145
- #
146
- # ### Miscellaneous Output:
147
- #
148
- # * `--append-output` - `nmap.append`
149
- # * `--resume` - `nmap.resume`
150
- # * `--stylesheet` - `nmap.stylesheet`
151
- # * `--webxml` - `nmap.nmap_stylesheet`
152
- # * `--no-stylesheet` - `nmap.disable_stylesheet`
153
- #
154
- # ### Misc:
155
- #
156
- # * `-6` - `nmap.ipv6`
157
- # * `-A` - `nmap.all`
158
- # * `--datadir` - `nmap.nmap_datadir`
159
- # * `--servicedb` - `nmap.servicedb`
160
- # * `--versiondb` - `nmap.versiondb`
161
- # * `--send-eth` - `nmap.raw_ethernet`
162
- # * `--send-ip` - `nmap.raw_ip`
163
- # * `--privileged` - `nmap.privileged`
164
- # * `--unprivileged` - `nmap.unprivileged`
165
- # * `--release-memory` - `nmap.release_memory`
166
- # * `--interactive` - `nmap.interactive`
167
- # * `-V` - `nmap.version`
168
- # * `-h` - `nmap.help`
169
- #
170
- # * `target specification` - `nmap.targets`
171
- #
172
- # @see http://nmap.org/book/man.html
173
- #
174
- class Task < RProgram::Task
175
-
176
- # TARGET SPECIFICATIONS:
177
- short_option :flag => '-iL', :name => :target_file
178
- short_option :flag => '-iR', :name => :random_targets
179
- long_option :flag => '--exclude', :name => :exclude, :separator => ','
180
- long_option :flag => '--excludefile', :name => :exclude_file
181
-
182
- # HOST DISCOVERY:
183
- short_option :flag => '-sL', :name => :list
184
- short_option :flag => '-sn', :name => :ping
185
- short_option :flag => '-Pn', :name => :skip_discovery
186
- short_option :flag => '-PS', :name => :syn_discovery do |opt,value|
187
- ["#{opt.flag}#{format_port_list(value)}"]
188
- end
189
- short_option :flag => '-PA', :name => :ack_discovery do |opt,value|
190
- ["#{opt.flag}#{format_port_list(value)}"]
191
- end
192
- short_option :flag => '-PU', :name => :udp_discovery do |opt,value|
193
- ["#{opt.flag}#{format_port_list(value)}"]
194
- end
195
- short_option :flag => '-PY', :name => :sctp_init_ping do |opt,value|
196
- ["#{opt.flag}#{format_port_list(value)}"]
197
- end
198
- short_option :flag => '-PE', :name => :icmp_echo_discovery
199
- short_option :flag => '-PP', :name => :icmp_timestamp_discovery
200
- short_option :flag => '-PM', :name => :icmp_netmask_discovery
201
- short_option :flag => '-PO', :name => :ip_ping do |opt,value|
202
- ["#{opt.flag}#{format_protocol_list(value)}"]
203
- end
204
- short_option :flag => '-PR', :name => :arp_ping
205
- long_option :flag => '--traceroute', :name => :traceroute
206
- short_option :flag => '-n', :name => :disable_dns
207
- short_option :flag => '-R', :name => :enable_dns
208
- long_option :flag => '--dns-servers', :separator => ','
209
- long_option :flag => '--system-dns'
210
-
211
- # PORT SCANNING TECHNIQUES:
212
- short_option :flag => '-sS', :name => :syn_scan
213
- short_option :flag => '-sT', :name => :connect_scan
214
- short_option :flag => '-sU', :name => :udp_scan
215
- short_option :flag => '-sY', :name => :sctp_init_scan
216
- short_option :flag => '-sN', :name => :null_scan
217
- short_option :flag => '-sF', :name => :fin_scan
218
- short_option :flag => '-sX', :name => :xmas_scan
219
- short_option :flag => '-sA', :name => :ack_scan
220
- short_option :flag => '-sW', :name => :window_scan
221
- short_option :flag => '-sM', :name => :maimon_scan
222
- long_option :flag => '--scanflags', :name => :tcp_scan_flags
223
- short_option :flag => '-sZ', :name => :sctp_cookie_echo_scan
224
- short_option :flag => '-sI', :name => :idle_scan
225
- short_option :flag => '-sO', :name => :ip_scan
226
- short_option :flag => '-b', :name => :ftp_bounce_scan
227
-
228
- # PORT SPECIFICATION AND SCAN ORDER:
229
- short_option :flag => '-p', :name => :ports do |opt,value|
230
- unless value.empty?
231
- [opt.flag, format_port_list(value)]
232
- end
233
- end
234
- long_option :flag => '--exclude-ports' do |opt,value|
235
- unless value.empty?
236
- [opt.flag, format_ports(value)]
237
- end
238
- end
239
- short_option :flag => '-F', :name => :fast
240
- short_option :flag => '-r', :name => :consecutively
241
- long_option :flag => '--top-ports'
242
- long_option :flag => '--port-ratio'
243
-
244
- # SERVICE/VERSION DETECTION:
245
- short_option :flag => '-sV', :name => :service_scan
246
- long_option :flag => '--allports', :name => :all_ports
247
- long_option :flag => '--version-intensity'
248
- long_option :flag => '--version-light'
249
- long_option :flag => '--version-all'
250
- long_option :flag => '--version-trace'
251
- short_option :flag => '-sR', :name => :rpc_scan
252
-
253
- # SCRIPT SCAN:
254
- short_option :flag => '-sC', :name => :default_script
255
- long_option :flag => '--script', :separator => ','
256
- long_option :flag => '--script-args', :separator => ','
257
- alias script_params script_args
258
- alias script_params= script_args=
259
- long_option :flag => '--script-trace'
260
- long_option :flag => '--script-updatedb', :name => :update_scriptdb
261
-
262
- # OS DETECTION:
263
- short_option :flag => '-O', :name => :os_fingerprint
264
- long_option :flag => '--osscan-limit', :name => :limit_os_scan
265
- long_option :flag => '--osscan-guess', :name => :max_os_scan
266
- long_option :flag => '--max-os-tries', :name => :max_os_tries
267
-
268
- # TIMING AND PERFORMANCE:
269
- long_option :flag => '--min-hostgroup', :name => :min_host_group
270
- long_option :flag => '--max-hostgroup', :name => :max_host_group
271
- long_option :flag => '--min-parallelism'
272
- long_option :flag => '--max-parallelism'
273
- long_option :flag => '--min-rtt-timeout'
274
- long_option :flag => '--max-rtt-timeout'
275
- long_option :flag => '--max-retries'
276
- long_option :flag => '--host-timeout'
277
- long_option :flag => '--scan-delay'
278
- long_option :flag => '--max-scan-delay'
279
- long_option :flag => '--min-rate'
280
- long_option :flag => '--max-rate'
281
- long_option :flag => '--defeat-rst-ratelimit'
282
- long_option :flag => '--defeat-icmp-ratelimit'
283
- long_option :flag => '--nsock-engine'
284
- short_option :flag => '-T', :name => :timing_template
285
- short_option :flag => '-T0', :name => :paranoid_timing
286
- short_option :flag => '-T1', :name => :sneaky_timing
287
- short_option :flag => '-T2', :name => :polite_timing
288
- short_option :flag => '-T3', :name => :normal_timing
289
- short_option :flag => '-T4', :name => :aggressive_timing
290
- short_option :flag => '-T5', :name => :insane_timing
291
-
292
- # FIREWALL/IDS EVASION AND SPOOFING:
293
- short_option :flag => '-f', :name => :packet_fragments
294
- long_option :flag => '--mtu'
295
- short_option :flag => '-D', :name => :decoys, :separator => ','
296
- short_option :flag => '-S', :name => :spoof
297
- short_option :flag => '-e', :name => :interface
298
- short_option :flag => '-g', :name => :source_port
299
- long_option :flag => '--data-length'
300
- long_option :flag => '--ip-options'
301
- long_option :flag => '--ttl'
302
- long_option :flag => '--randomize-hosts'
303
- long_option :flag => '--spoof-mac'
304
- long_option :flag => '--badsum', :name => :bad_checksum
305
- long_option :flag => '--adler32', :name => :sctp_adler32
306
-
307
- # OUTPUT:
308
- short_option :flag => '-oN', :name => :save
309
- short_option :flag => '-oX', :name => :xml
310
- short_option :flag => '-oS', :name => :skiddie
311
- short_option :flag => '-oG', :name => :grepable
312
- short_option :flag => '-oA', :name => :output_all
313
-
314
- # Verbosity and Debugging:
315
- short_option :flag => '-v', :name => :verbose
316
- short_option :flag => '-v0', :name => :quiet
317
- short_option :flag => '-d', :name => :debug
318
- long_option :flag => '--reason', :name => :show_reason
319
- long_option :flag => '--stats-every'
320
- long_option :flag => '--packet-trace', :name => :show_packets
321
- long_option :flag => '--open', :name => :show_open_ports
322
- long_option :flag => '--iflist', :name => :show_interfaces
323
- long_option :flag => '--log-errors', :name => :show_log_errors
324
-
325
- # Miscellaneous output:
326
- long_option :flag => '--append-output', :name => :append
327
- long_option :flag => '--resume'
328
- long_option :flag => '--stylesheet'
329
- long_option :flag => '--webxml', :name => :nmap_stylesheet
330
- long_option :flag => '--no-stylesheet', :name => :disable_stylesheet
331
-
332
- # MISC:
333
- short_option :flag => '-6', :name => :ipv6
334
- short_option :flag => '-A', :name => :all
335
- long_option :flag => '--datadir', :name => :nmap_datadir
336
- long_option :flag => '--servicedb'
337
- long_option :flag => '--versiondb'
338
- long_option :flag => '--send-eth', :name => :raw_ethernet
339
- long_option :flag => '--send-ip', :name => :raw_ip
340
- long_option :flag => '--privileged'
341
- long_option :flag => '--unprivleged'
342
- long_option :flag => '--release-memory'
343
- long_option :flag => '--interactive'
344
- short_option :flag => '-V', :name => :version
345
- short_option :flag => '-h', :name => :help
346
-
347
- non_option :tailing => true, :name => :targets
348
-
349
- private
350
-
351
- #
352
- # Fomats a port list.
353
- #
354
- # @param [Array<Integer,Range>] ports
355
- # The port ranges.
356
- #
357
- # @return [String]
358
- # Comma separated string.
359
- #
360
- def self.format_port_list(ports)
361
- ports.map { |port|
362
- case port
363
- when Range
364
- "#{port.first}-#{port.last}"
365
- else
366
- port.to_s
367
- end
368
- }.join(',')
369
- end
370
-
371
- #
372
- # Formats a protocol list.
373
- #
374
- # @param [Array<Integer,Range>] protocols
375
- # The IP protocol numbers.
376
- #
377
- # @return [String]
378
- # Comma separated string.
379
- #
380
- def self.format_protocol_list(protocols)
381
- # NOTE: the man page says the protocol list is similar to the format of
382
- # a port range.
383
- format_port_list(protocols)
384
- end
385
-
386
- end
387
- end
@@ -1,46 +0,0 @@
1
- require 'nmap/sequence'
2
-
3
- module Nmap
4
- #
5
- # Represents a TCP sequence number.
6
- #
7
- # @since 0.5.0
8
- #
9
- class TcpSequence < Sequence
10
-
11
- #
12
- # @return [Numeric]
13
- # The difficulty index from nmap
14
- #
15
- # @since 0.5.0
16
- #
17
- def index
18
- @index ||= if (index_string = @node['index'])
19
- index_string.to_i
20
- end
21
- end
22
-
23
- #
24
- # @return [String]
25
- # The difficulty description from nmap
26
- #
27
- # @since 0.5.0
28
- #
29
- def difficulty
30
- @difficulty ||= @node['difficulty']
31
- end
32
-
33
- #
34
- # Converts the TcpSequence class to a String.
35
- #
36
- # @return [String]
37
- # The String form of the object.
38
- #
39
- # @since 0.5.0
40
- #
41
- def to_s
42
- "index=#{index} difficulty=#{difficulty.inspect} values=#{values.inspect}"
43
- end
44
-
45
- end
46
- end
@@ -1,22 +0,0 @@
1
- require 'nmap/sequence'
2
-
3
- module Nmap
4
- #
5
- # Represents a TCP timestamp.
6
- #
7
- class TcpTsSequence < Sequence
8
-
9
- #
10
- # Converts the TcpTsSequence class to a String.
11
- #
12
- # @return [String]
13
- # The String form of the object.
14
- #
15
- # @since 0.5.0
16
- #
17
- def to_s
18
- "description=#{description.inspect} values=#{values.inspect}"
19
- end
20
-
21
- end
22
- end