ruby-nmap 0.9.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.document +1 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +31 -0
- data/ChangeLog.md +122 -67
- data/Gemfile +11 -5
- data/LICENSE.txt +1 -1
- data/README.md +88 -50
- data/Rakefile +8 -3
- data/UPGRADING.md +47 -0
- data/gemspec.yml +6 -6
- data/lib/nmap/command.rb +765 -0
- data/lib/nmap/version.rb +1 -1
- data/lib/nmap/xml/address.rb +38 -0
- data/lib/nmap/xml/cpe/url.rb +80 -0
- data/lib/nmap/xml/cpe.rb +47 -0
- data/lib/nmap/xml/hop.rb +22 -0
- data/lib/nmap/xml/host.rb +546 -0
- data/lib/nmap/xml/host_script.rb +26 -0
- data/lib/nmap/xml/hostname.rb +44 -0
- data/lib/nmap/xml/ip_id_sequence.rb +26 -0
- data/lib/nmap/xml/os.rb +131 -0
- data/lib/nmap/xml/os_class.rb +86 -0
- data/lib/nmap/xml/os_match.rb +22 -0
- data/lib/nmap/xml/port.rb +114 -0
- data/lib/nmap/xml/postscript.rb +26 -0
- data/lib/nmap/xml/prescript.rb +26 -0
- data/lib/nmap/xml/run_stat.rb +22 -0
- data/lib/nmap/xml/scan.rb +38 -0
- data/lib/nmap/xml/scan_task.rb +55 -0
- data/lib/nmap/xml/scanner.rb +22 -0
- data/lib/nmap/xml/script.rb +110 -0
- data/lib/nmap/xml/scripts.rb +33 -0
- data/lib/nmap/xml/sequence.rb +52 -0
- data/lib/nmap/xml/service.rb +172 -0
- data/lib/nmap/xml/status.rb +22 -0
- data/lib/nmap/xml/tcp_sequence.rb +48 -0
- data/lib/nmap/xml/tcp_ts_sequence.rb +26 -0
- data/lib/nmap/xml/traceroute.rb +73 -0
- data/lib/nmap/xml/uptime.rb +22 -0
- data/lib/nmap/xml.rb +46 -44
- data/ruby-nmap.gemspec +38 -83
- data/spec/command_spec.rb +726 -0
- data/spec/fixtures/down_host_scan.xml +16 -0
- data/spec/{local_scan.xml → fixtures/local_scan.xml} +1 -1
- data/spec/{scan.xml → fixtures/scan.xml} +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/{address_spec.rb → xml/address_spec.rb} +2 -2
- data/spec/{cpe → xml/cpe}/url_spec.rb +1 -1
- data/spec/{cpe_examples.rb → xml/cpe_examples.rb} +1 -1
- data/spec/{hop_spec.rb → xml/hop_spec.rb} +2 -2
- data/spec/{host_script_spec.rb → xml/host_script_spec.rb} +2 -2
- data/spec/{host_spec.rb → xml/host_spec.rb} +12 -8
- data/spec/{hostname_spec.rb → xml/hostname_spec.rb} +2 -2
- data/spec/{ip_id_sequence_spec.rb → xml/ip_id_sequence_spec.rb} +3 -3
- data/spec/{os_class_spec.rb → xml/os_class_spec.rb} +3 -3
- data/spec/{os_match_spec.rb → xml/os_match_spec.rb} +2 -2
- data/spec/{os_spec.rb → xml/os_spec.rb} +3 -3
- data/spec/{port_spec.rb → xml/port_spec.rb} +10 -5
- data/spec/{postscript_spec.rb → xml/postscript_spec.rb} +2 -2
- data/spec/{prescript_spec.rb → xml/prescript_spec.rb} +2 -2
- data/spec/{run_stat_spec.rb → xml/run_stat_spec.rb} +2 -2
- data/spec/{scan_spec.rb → xml/scan_spec.rb} +2 -2
- data/spec/{scan_task_spec.rb → xml/scan_task_spec.rb} +6 -6
- data/spec/{scanner_spec.rb → xml/scanner_spec.rb} +3 -3
- data/spec/xml/script_spec.rb +137 -0
- data/spec/xml/scripts_examples.rb +19 -0
- data/spec/{sequence_examples.rb → xml/sequence_examples.rb} +1 -0
- data/spec/{service_spec.rb → xml/service_spec.rb} +31 -5
- data/spec/{status_spec.rb → xml/status_spec.rb} +4 -3
- data/spec/{tcp_sequence_spec.rb → xml/tcp_sequence_spec.rb} +3 -3
- data/spec/{tcp_ts_sequence_spec.rb → xml/tcp_ts_sequence_spec.rb} +3 -3
- data/spec/{traceroute_spec.rb → xml/traceroute_spec.rb} +3 -3
- data/spec/{uptime_spec.rb → xml/uptime_spec.rb} +2 -2
- data/spec/xml_spec.rb +93 -45
- metadata +78 -99
- data/.travis.yml +0 -14
- data/lib/nmap/address.rb +0 -34
- data/lib/nmap/cpe/url.rb +0 -78
- data/lib/nmap/cpe.rb +0 -45
- data/lib/nmap/hop.rb +0 -20
- data/lib/nmap/host.rb +0 -586
- data/lib/nmap/host_script.rb +0 -18
- data/lib/nmap/hostname.rb +0 -42
- data/lib/nmap/ip_id_sequence.rb +0 -24
- data/lib/nmap/os.rb +0 -127
- data/lib/nmap/os_class.rb +0 -82
- data/lib/nmap/os_match.rb +0 -18
- data/lib/nmap/port.rb +0 -99
- data/lib/nmap/postscript.rb +0 -16
- data/lib/nmap/prescript.rb +0 -16
- data/lib/nmap/program.rb +0 -102
- data/lib/nmap/run_stat.rb +0 -20
- data/lib/nmap/scan.rb +0 -34
- data/lib/nmap/scan_task.rb +0 -50
- data/lib/nmap/scanner.rb +0 -18
- data/lib/nmap/scripts.rb +0 -71
- data/lib/nmap/sequence.rb +0 -50
- data/lib/nmap/service.rb +0 -170
- data/lib/nmap/status.rb +0 -18
- data/lib/nmap/task.rb +0 -381
- data/lib/nmap/tcp_sequence.rb +0 -46
- data/lib/nmap/tcp_ts_sequence.rb +0 -22
- data/lib/nmap/traceroute.rb +0 -71
- data/lib/nmap/uptime.rb +0 -20
- data/spec/scripts_examples.rb +0 -35
- data/spec/task_spec.rb +0 -150
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'sequence_examples'
|
2
|
+
require 'xml/sequence_examples'
|
3
3
|
|
4
|
-
require 'nmap/tcp_sequence'
|
4
|
+
require 'nmap/xml/tcp_sequence'
|
5
5
|
|
6
|
-
describe TcpSequence do
|
6
|
+
describe Nmap::XML::TcpSequence do
|
7
7
|
subject { @xml.hosts.first.tcp_sequence }
|
8
8
|
|
9
9
|
describe "#index" do
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'sequence_examples'
|
2
|
+
require 'xml/sequence_examples'
|
3
3
|
|
4
|
-
require 'nmap/tcp_ts_sequence'
|
4
|
+
require 'nmap/xml/tcp_ts_sequence'
|
5
5
|
|
6
|
-
describe TcpTsSequence do
|
6
|
+
describe Nmap::XML::TcpTsSequence do
|
7
7
|
subject { @xml.hosts.first.tcp_ts_sequence }
|
8
8
|
|
9
9
|
describe "#description" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'nmap/traceroute'
|
2
|
+
require 'nmap/xml/traceroute'
|
3
3
|
|
4
|
-
describe Traceroute do
|
4
|
+
describe Nmap::XML::Traceroute do
|
5
5
|
subject { @xml.hosts.first.traceroute }
|
6
6
|
|
7
7
|
describe "#port" do
|
@@ -22,7 +22,7 @@ describe Traceroute do
|
|
22
22
|
describe "#each" do
|
23
23
|
subject { super().each.first }
|
24
24
|
|
25
|
-
it { is_expected.to be_kind_of(Hop) }
|
25
|
+
it { is_expected.to be_kind_of(Nmap::XML::Hop) }
|
26
26
|
|
27
27
|
describe '#addr' do
|
28
28
|
subject { super().addr }
|
data/spec/xml_spec.rb
CHANGED
@@ -1,36 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'nmap/xml'
|
3
3
|
|
4
|
-
describe XML do
|
5
|
-
let(:
|
4
|
+
describe Nmap::XML do
|
5
|
+
let(:file) { 'spec/fixtures/scan.xml' }
|
6
|
+
let(:path) { File.expand_path(file) }
|
7
|
+
let(:doc) { Nokogiri::XML(File.open(path)) }
|
6
8
|
|
7
|
-
subject { described_class.new(
|
9
|
+
subject { described_class.new(doc) }
|
8
10
|
|
9
11
|
describe "#initialize" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
it "should use the document" do
|
14
|
-
expect(described_class.new(document).version).to eq(subject.version)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when given an IO object" do
|
19
|
-
let(:io) { File.new(path) }
|
20
|
-
|
21
|
-
it "should parse the IO object" do
|
22
|
-
expect(described_class.new(io).version).to eq(subject.version)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when given a String" do
|
27
|
-
it "should parse the file at the path" do
|
28
|
-
expect(described_class.new(path).version).to eq(subject.version)
|
29
|
-
end
|
12
|
+
it "must set #doc" do
|
13
|
+
expect(described_class.new(doc).doc).to be(doc)
|
30
14
|
end
|
31
15
|
end
|
32
16
|
|
33
|
-
describe "parse" do
|
17
|
+
describe ".parse" do
|
34
18
|
let(:xml) { File.read(path) }
|
35
19
|
|
36
20
|
subject { described_class.parse(xml) }
|
@@ -44,7 +28,7 @@ describe XML do
|
|
44
28
|
end
|
45
29
|
end
|
46
30
|
|
47
|
-
describe "open" do
|
31
|
+
describe ".open" do
|
48
32
|
subject { described_class.open(path) }
|
49
33
|
|
50
34
|
it "should return an XML object" do
|
@@ -72,7 +56,7 @@ describe XML do
|
|
72
56
|
end
|
73
57
|
|
74
58
|
it "should parse the scanner arguments" do
|
75
|
-
expect(subject.scanner.arguments).to eq(
|
59
|
+
expect(subject.scanner.arguments).to eq("nmap -v -sS -sU -A -O --script ssh2-enum-algos,ssh-hostkey -oX #{file} scanme.nmap.org")
|
76
60
|
end
|
77
61
|
|
78
62
|
it "should parse the scanner start time" do
|
@@ -108,7 +92,7 @@ describe XML do
|
|
108
92
|
subject { super().each_run_stat.first }
|
109
93
|
|
110
94
|
it "should yield RunStat objects" do
|
111
|
-
expect(subject).to be_kind_of(RunStat)
|
95
|
+
expect(subject).to be_kind_of(Nmap::XML::RunStat)
|
112
96
|
end
|
113
97
|
|
114
98
|
it "should parse the end time" do
|
@@ -132,7 +116,7 @@ describe XML do
|
|
132
116
|
subject { super().run_stats }
|
133
117
|
|
134
118
|
it { is_expected.not_to be_empty }
|
135
|
-
it { is_expected.to all(be_kind_of(RunStat)) }
|
119
|
+
it { is_expected.to all(be_kind_of(Nmap::XML::RunStat)) }
|
136
120
|
end
|
137
121
|
|
138
122
|
describe "#each_task" do
|
@@ -152,7 +136,7 @@ describe XML do
|
|
152
136
|
end
|
153
137
|
|
154
138
|
it "should parse the extrainfo" do
|
155
|
-
expect(subject.
|
139
|
+
expect(subject.extra_info).not_to be_empty
|
156
140
|
end
|
157
141
|
end
|
158
142
|
|
@@ -160,7 +144,25 @@ describe XML do
|
|
160
144
|
subject { super().tasks }
|
161
145
|
|
162
146
|
it { is_expected.not_to be_empty }
|
163
|
-
it { is_expected.to all(be_kind_of(ScanTask)) }
|
147
|
+
it { is_expected.to all(be_kind_of(Nmap::XML::ScanTask)) }
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#task" do
|
151
|
+
context "when the task with the given name exists" do
|
152
|
+
it "must return the matching task" do
|
153
|
+
name = "Parallel DNS resolution of 1 host."
|
154
|
+
task = subject.task(name)
|
155
|
+
|
156
|
+
expect(task).to be_kind_of(Nmap::XML::ScanTask)
|
157
|
+
expect(task.name).to be == name
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when no task with the given name can be found" do
|
162
|
+
it "must return nil" do
|
163
|
+
expect(subject.task('Foo')).to be(nil)
|
164
|
+
end
|
165
|
+
end
|
164
166
|
end
|
165
167
|
|
166
168
|
describe "#prescript" do
|
@@ -179,7 +181,7 @@ describe XML do
|
|
179
181
|
subject { super().each_host.first }
|
180
182
|
|
181
183
|
it "should yield Host objects" do
|
182
|
-
expect(subject).to be_kind_of(Host)
|
184
|
+
expect(subject).to be_kind_of(Nmap::XML::Host)
|
183
185
|
end
|
184
186
|
end
|
185
187
|
|
@@ -187,20 +189,62 @@ describe XML do
|
|
187
189
|
subject { super().hosts }
|
188
190
|
|
189
191
|
it { is_expected.not_to be_empty }
|
190
|
-
it { expect(subject).to all(be_kind_of(Host)) }
|
192
|
+
it { expect(subject).to all(be_kind_of(Nmap::XML::Host)) }
|
191
193
|
end
|
192
194
|
|
193
195
|
describe "#host" do
|
194
196
|
subject { super().host }
|
195
197
|
|
196
|
-
it { expect(subject).to be_kind_of(Host) }
|
198
|
+
it { expect(subject).to be_kind_of(Nmap::XML::Host) }
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "#each_down_host" do
|
202
|
+
let(:file) { 'spec/fixtures/down_host_scan.xml' }
|
203
|
+
|
204
|
+
context "when given a block" do
|
205
|
+
it "must yield Host objects" do
|
206
|
+
expect { |b|
|
207
|
+
subject.each_down_host(&b)
|
208
|
+
}.to yield_successive_args(Nmap::XML::Host)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "status must be down" do
|
212
|
+
yielded_hosts = []
|
213
|
+
|
214
|
+
subject.each_down_host do |host|
|
215
|
+
yielded_hosts << host
|
216
|
+
end
|
217
|
+
|
218
|
+
expect(yielded_hosts).to_not be_empty
|
219
|
+
expect(yielded_hosts.map { |host| host.status.state }).to all(eq(:down))
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "when not given a block" do
|
224
|
+
it "must return an Enumerator for the method" do
|
225
|
+
expect(subject.each_down_host).to be_kind_of(Enumerator)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "#down_hosts" do
|
231
|
+
let(:file) { 'spec/fixtures/down_host_scan.xml' }
|
232
|
+
|
233
|
+
subject { super().down_hosts }
|
234
|
+
|
235
|
+
it { expect(subject).to_not be_empty }
|
236
|
+
it { expect(subject).to all(be_kind_of(Nmap::XML::Host)) }
|
237
|
+
|
238
|
+
it "should contain only up hosts" do
|
239
|
+
expect(subject.map { |host| host.status.state }).to all(eq(:down))
|
240
|
+
end
|
197
241
|
end
|
198
242
|
|
199
243
|
describe "#down_host" do
|
200
244
|
pending "need down hosts in scan.xml" do
|
201
245
|
subject { super().down_host }
|
202
246
|
|
203
|
-
it { is_expected.to be_kind_of(Host) }
|
247
|
+
it { is_expected.to be_kind_of(Nmap::XML::Host) }
|
204
248
|
|
205
249
|
it "should contain only up hosts" do
|
206
250
|
expect(subject.status.state).to be(:down)
|
@@ -212,7 +256,7 @@ describe XML do
|
|
212
256
|
subject { super().each_up_host.first }
|
213
257
|
|
214
258
|
it "should yield Host objects" do
|
215
|
-
expect(subject).to be_kind_of(Host)
|
259
|
+
expect(subject).to be_kind_of(Nmap::XML::Host)
|
216
260
|
end
|
217
261
|
|
218
262
|
it "should be up" do
|
@@ -223,18 +267,18 @@ describe XML do
|
|
223
267
|
describe "#up_hosts" do
|
224
268
|
subject { super().up_hosts }
|
225
269
|
|
226
|
-
it {
|
227
|
-
it {
|
270
|
+
it { expect(subject).not_to be_empty }
|
271
|
+
it { expect(subject).to all(be_kind_of(Nmap::XML::Host)) }
|
228
272
|
|
229
273
|
it "should contain only up hosts" do
|
230
|
-
expect(subject.
|
274
|
+
expect(subject.map { |host| host.status.state }).to all(eq(:up))
|
231
275
|
end
|
232
276
|
end
|
233
277
|
|
234
278
|
describe "#up_host" do
|
235
279
|
subject { super().up_host }
|
236
280
|
|
237
|
-
it { is_expected.to be_kind_of(Host) }
|
281
|
+
it { is_expected.to be_kind_of(Nmap::XML::Host) }
|
238
282
|
|
239
283
|
it "should contain only up hosts" do
|
240
284
|
expect(subject.status.state).to be(:up)
|
@@ -248,14 +292,18 @@ describe XML do
|
|
248
292
|
end
|
249
293
|
|
250
294
|
describe "#to_s" do
|
251
|
-
|
252
|
-
|
295
|
+
context "when #path is set" do
|
296
|
+
subject { described_class.new(doc, path: path) }
|
297
|
+
|
298
|
+
it "must return #path" do
|
299
|
+
expect(subject.to_s).to eq(path)
|
300
|
+
end
|
253
301
|
end
|
254
|
-
end
|
255
302
|
|
256
|
-
|
257
|
-
|
258
|
-
|
303
|
+
context "when #path is not set" do
|
304
|
+
it "must return the raw XML" do
|
305
|
+
expect(subject.to_s).to eq(doc.to_s)
|
306
|
+
end
|
259
307
|
end
|
260
308
|
end
|
261
309
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: command_mapper
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
@@ -44,15 +44,16 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: A Ruby
|
54
|
+
version: '2.0'
|
55
|
+
description: A Ruby API to nmap, the exploration tool and security / port scanner.
|
56
|
+
Allows automating nmap and parsing nmap XML files.
|
56
57
|
email: postmodern.mod3@gmail.com
|
57
58
|
executables: []
|
58
59
|
extensions: []
|
@@ -60,87 +61,92 @@ extra_rdoc_files:
|
|
60
61
|
- ChangeLog.md
|
61
62
|
- LICENSE.txt
|
62
63
|
- README.md
|
64
|
+
- UPGRADING.md
|
63
65
|
files:
|
64
66
|
- ".document"
|
67
|
+
- ".editorconfig"
|
68
|
+
- ".github/workflows/ruby.yml"
|
65
69
|
- ".gitignore"
|
66
70
|
- ".rspec"
|
67
|
-
- ".travis.yml"
|
68
71
|
- ".yardopts"
|
69
72
|
- ChangeLog.md
|
70
73
|
- Gemfile
|
71
74
|
- LICENSE.txt
|
72
75
|
- README.md
|
73
76
|
- Rakefile
|
77
|
+
- UPGRADING.md
|
74
78
|
- gemspec.yml
|
75
79
|
- lib/nmap.rb
|
76
|
-
- lib/nmap/
|
77
|
-
- lib/nmap/cpe.rb
|
78
|
-
- lib/nmap/cpe/url.rb
|
79
|
-
- lib/nmap/hop.rb
|
80
|
-
- lib/nmap/host.rb
|
81
|
-
- lib/nmap/host_script.rb
|
82
|
-
- lib/nmap/hostname.rb
|
83
|
-
- lib/nmap/ip_id_sequence.rb
|
84
|
-
- lib/nmap/os.rb
|
85
|
-
- lib/nmap/os_class.rb
|
86
|
-
- lib/nmap/os_match.rb
|
87
|
-
- lib/nmap/port.rb
|
88
|
-
- lib/nmap/postscript.rb
|
89
|
-
- lib/nmap/prescript.rb
|
90
|
-
- lib/nmap/program.rb
|
91
|
-
- lib/nmap/run_stat.rb
|
92
|
-
- lib/nmap/scan.rb
|
93
|
-
- lib/nmap/scan_task.rb
|
94
|
-
- lib/nmap/scanner.rb
|
95
|
-
- lib/nmap/scripts.rb
|
96
|
-
- lib/nmap/sequence.rb
|
97
|
-
- lib/nmap/service.rb
|
98
|
-
- lib/nmap/status.rb
|
99
|
-
- lib/nmap/task.rb
|
100
|
-
- lib/nmap/tcp_sequence.rb
|
101
|
-
- lib/nmap/tcp_ts_sequence.rb
|
102
|
-
- lib/nmap/traceroute.rb
|
103
|
-
- lib/nmap/uptime.rb
|
80
|
+
- lib/nmap/command.rb
|
104
81
|
- lib/nmap/version.rb
|
105
82
|
- lib/nmap/xml.rb
|
83
|
+
- lib/nmap/xml/address.rb
|
84
|
+
- lib/nmap/xml/cpe.rb
|
85
|
+
- lib/nmap/xml/cpe/url.rb
|
86
|
+
- lib/nmap/xml/hop.rb
|
87
|
+
- lib/nmap/xml/host.rb
|
88
|
+
- lib/nmap/xml/host_script.rb
|
89
|
+
- lib/nmap/xml/hostname.rb
|
90
|
+
- lib/nmap/xml/ip_id_sequence.rb
|
91
|
+
- lib/nmap/xml/os.rb
|
92
|
+
- lib/nmap/xml/os_class.rb
|
93
|
+
- lib/nmap/xml/os_match.rb
|
94
|
+
- lib/nmap/xml/port.rb
|
95
|
+
- lib/nmap/xml/postscript.rb
|
96
|
+
- lib/nmap/xml/prescript.rb
|
97
|
+
- lib/nmap/xml/run_stat.rb
|
98
|
+
- lib/nmap/xml/scan.rb
|
99
|
+
- lib/nmap/xml/scan_task.rb
|
100
|
+
- lib/nmap/xml/scanner.rb
|
101
|
+
- lib/nmap/xml/script.rb
|
102
|
+
- lib/nmap/xml/scripts.rb
|
103
|
+
- lib/nmap/xml/sequence.rb
|
104
|
+
- lib/nmap/xml/service.rb
|
105
|
+
- lib/nmap/xml/status.rb
|
106
|
+
- lib/nmap/xml/tcp_sequence.rb
|
107
|
+
- lib/nmap/xml/tcp_ts_sequence.rb
|
108
|
+
- lib/nmap/xml/traceroute.rb
|
109
|
+
- lib/nmap/xml/uptime.rb
|
106
110
|
- ruby-nmap.gemspec
|
107
|
-
- spec/
|
108
|
-
- spec/
|
109
|
-
- spec/
|
110
|
-
- spec/
|
111
|
-
- spec/host_script_spec.rb
|
112
|
-
- spec/host_spec.rb
|
113
|
-
- spec/hostname_spec.rb
|
114
|
-
- spec/ip_id_sequence_spec.rb
|
115
|
-
- spec/local_scan.xml
|
111
|
+
- spec/command_spec.rb
|
112
|
+
- spec/fixtures/down_host_scan.xml
|
113
|
+
- spec/fixtures/local_scan.xml
|
114
|
+
- spec/fixtures/scan.xml
|
116
115
|
- spec/nmap_spec.rb
|
117
|
-
- spec/os_class_spec.rb
|
118
|
-
- spec/os_match_spec.rb
|
119
|
-
- spec/os_spec.rb
|
120
|
-
- spec/port_spec.rb
|
121
|
-
- spec/postscript_spec.rb
|
122
|
-
- spec/prescript_spec.rb
|
123
|
-
- spec/run_stat_spec.rb
|
124
|
-
- spec/scan.xml
|
125
|
-
- spec/scan_spec.rb
|
126
|
-
- spec/scan_task_spec.rb
|
127
|
-
- spec/scanner_spec.rb
|
128
|
-
- spec/scripts_examples.rb
|
129
|
-
- spec/sequence_examples.rb
|
130
|
-
- spec/service_spec.rb
|
131
116
|
- spec/spec_helper.rb
|
132
|
-
- spec/
|
133
|
-
- spec/
|
134
|
-
- spec/
|
135
|
-
- spec/
|
136
|
-
- spec/
|
137
|
-
- spec/
|
117
|
+
- spec/xml/address_spec.rb
|
118
|
+
- spec/xml/cpe/url_spec.rb
|
119
|
+
- spec/xml/cpe_examples.rb
|
120
|
+
- spec/xml/hop_spec.rb
|
121
|
+
- spec/xml/host_script_spec.rb
|
122
|
+
- spec/xml/host_spec.rb
|
123
|
+
- spec/xml/hostname_spec.rb
|
124
|
+
- spec/xml/ip_id_sequence_spec.rb
|
125
|
+
- spec/xml/os_class_spec.rb
|
126
|
+
- spec/xml/os_match_spec.rb
|
127
|
+
- spec/xml/os_spec.rb
|
128
|
+
- spec/xml/port_spec.rb
|
129
|
+
- spec/xml/postscript_spec.rb
|
130
|
+
- spec/xml/prescript_spec.rb
|
131
|
+
- spec/xml/run_stat_spec.rb
|
132
|
+
- spec/xml/scan_spec.rb
|
133
|
+
- spec/xml/scan_task_spec.rb
|
134
|
+
- spec/xml/scanner_spec.rb
|
135
|
+
- spec/xml/script_spec.rb
|
136
|
+
- spec/xml/scripts_examples.rb
|
137
|
+
- spec/xml/sequence_examples.rb
|
138
|
+
- spec/xml/service_spec.rb
|
139
|
+
- spec/xml/status_spec.rb
|
140
|
+
- spec/xml/tcp_sequence_spec.rb
|
141
|
+
- spec/xml/tcp_ts_sequence_spec.rb
|
142
|
+
- spec/xml/traceroute_spec.rb
|
143
|
+
- spec/xml/uptime_spec.rb
|
138
144
|
- spec/xml_spec.rb
|
139
|
-
homepage: https://github.com/
|
145
|
+
homepage: https://github.com/postmodern/ruby-nmap#readme
|
140
146
|
licenses:
|
141
147
|
- MIT
|
142
148
|
metadata: {}
|
143
|
-
post_install_message:
|
149
|
+
post_install_message:
|
144
150
|
rdoc_options: []
|
145
151
|
require_paths:
|
146
152
|
- lib
|
@@ -153,38 +159,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
159
|
requirements:
|
154
160
|
- - ">="
|
155
161
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
162
|
+
version: '0'
|
157
163
|
requirements:
|
158
164
|
- nmap >= 5.00
|
159
|
-
|
160
|
-
|
161
|
-
signing_key:
|
165
|
+
rubygems_version: 3.3.7
|
166
|
+
signing_key:
|
162
167
|
specification_version: 4
|
163
|
-
summary: A Ruby
|
164
|
-
test_files:
|
165
|
-
- spec/address_spec.rb
|
166
|
-
- spec/cpe/url_spec.rb
|
167
|
-
- spec/hop_spec.rb
|
168
|
-
- spec/host_script_spec.rb
|
169
|
-
- spec/host_spec.rb
|
170
|
-
- spec/hostname_spec.rb
|
171
|
-
- spec/ip_id_sequence_spec.rb
|
172
|
-
- spec/nmap_spec.rb
|
173
|
-
- spec/os_class_spec.rb
|
174
|
-
- spec/os_match_spec.rb
|
175
|
-
- spec/os_spec.rb
|
176
|
-
- spec/port_spec.rb
|
177
|
-
- spec/postscript_spec.rb
|
178
|
-
- spec/prescript_spec.rb
|
179
|
-
- spec/run_stat_spec.rb
|
180
|
-
- spec/scan_spec.rb
|
181
|
-
- spec/scan_task_spec.rb
|
182
|
-
- spec/scanner_spec.rb
|
183
|
-
- spec/service_spec.rb
|
184
|
-
- spec/status_spec.rb
|
185
|
-
- spec/task_spec.rb
|
186
|
-
- spec/tcp_sequence_spec.rb
|
187
|
-
- spec/tcp_ts_sequence_spec.rb
|
188
|
-
- spec/traceroute_spec.rb
|
189
|
-
- spec/uptime_spec.rb
|
190
|
-
- spec/xml_spec.rb
|
168
|
+
summary: A Ruby API to nmap.
|
169
|
+
test_files: []
|
data/.travis.yml
DELETED
data/lib/nmap/address.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Nmap
|
2
|
-
#
|
3
|
-
# Represents an IP or MAC address and Vendor name.
|
4
|
-
#
|
5
|
-
class Address < Struct.new(:type, :addr, :vendor)
|
6
|
-
|
7
|
-
#
|
8
|
-
# Initializes the address.
|
9
|
-
#
|
10
|
-
# @param [Symbol] type
|
11
|
-
# The type of address.
|
12
|
-
#
|
13
|
-
# @param [String] addr
|
14
|
-
# The address.
|
15
|
-
#
|
16
|
-
# @param [String, nil] vendor
|
17
|
-
# The optional vendor.
|
18
|
-
#
|
19
|
-
def initialize(type,addr,vendor=nil)
|
20
|
-
super(type,addr,vendor)
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Converts the address to a String.
|
25
|
-
#
|
26
|
-
# @return [String]
|
27
|
-
# The address.
|
28
|
-
#
|
29
|
-
def to_s
|
30
|
-
self.addr.to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
data/lib/nmap/cpe/url.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
module Nmap
|
2
|
-
module CPE
|
3
|
-
#
|
4
|
-
# Represets a [Common Platform Enumeration (CPE)][CPE] URL.
|
5
|
-
#
|
6
|
-
# [CPE]: http://nmap.org/book/output-formats-cpe.html
|
7
|
-
#
|
8
|
-
# @since 0.7.0
|
9
|
-
#
|
10
|
-
class URL < Struct.new(:part,:vendor,:product,:version,:update,:edition,
|
11
|
-
:language)
|
12
|
-
|
13
|
-
# CPE part codes
|
14
|
-
PARTS = {
|
15
|
-
'/a' => :application,
|
16
|
-
'/h' => :hardware,
|
17
|
-
'/o' => :os
|
18
|
-
}
|
19
|
-
|
20
|
-
#
|
21
|
-
# Parses a CPE URL.
|
22
|
-
#
|
23
|
-
# @param [String] url
|
24
|
-
# The raw URL.
|
25
|
-
#
|
26
|
-
# @return [URL]
|
27
|
-
# The parsed URL.
|
28
|
-
#
|
29
|
-
def self.parse(url)
|
30
|
-
scheme,
|
31
|
-
part,
|
32
|
-
vendor,
|
33
|
-
product,
|
34
|
-
version,
|
35
|
-
update,
|
36
|
-
edition,
|
37
|
-
language = url.split(':',8)
|
38
|
-
|
39
|
-
unless scheme == 'cpe'
|
40
|
-
raise(ArgumentError,"CPE URLs must begin with 'cpe:'")
|
41
|
-
end
|
42
|
-
|
43
|
-
vendor = vendor.to_sym
|
44
|
-
product = product.to_sym
|
45
|
-
language = language.to_sym if language
|
46
|
-
|
47
|
-
return new(
|
48
|
-
PARTS[part],
|
49
|
-
vendor,
|
50
|
-
product,
|
51
|
-
version,
|
52
|
-
update,
|
53
|
-
edition,
|
54
|
-
language
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
#
|
59
|
-
# Converts the CPE URL back into a String.
|
60
|
-
#
|
61
|
-
# @return [String]
|
62
|
-
# The raw CPE URL.
|
63
|
-
#
|
64
|
-
def to_s
|
65
|
-
'cpe:' + [
|
66
|
-
PARTS.invert[part],
|
67
|
-
vendor,
|
68
|
-
product,
|
69
|
-
version,
|
70
|
-
update,
|
71
|
-
edition,
|
72
|
-
language
|
73
|
-
].compact.join(':')
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|