ruby-nmap 0.8.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -7
- data/ChangeLog.md +19 -1
- data/README.md +3 -0
- data/Rakefile +1 -1
- data/gemspec.yml +2 -0
- data/lib/nmap/address.rb +17 -1
- data/lib/nmap/cpe.rb +44 -1
- data/lib/nmap/host.rb +24 -10
- data/lib/nmap/host_script.rb +18 -0
- data/lib/nmap/port.rb +3 -20
- data/lib/nmap/postscript.rb +16 -0
- data/lib/nmap/prescript.rb +16 -0
- data/lib/nmap/scripts.rb +71 -0
- data/lib/nmap/service.rb +13 -1
- data/lib/nmap/task.rb +4 -2
- data/lib/nmap/traceroute.rb +8 -4
- data/lib/nmap/version.rb +1 -1
- data/lib/nmap/xml.rb +30 -0
- data/spec/host_script_spec.rb +6 -0
- data/spec/host_spec.rb +14 -9
- data/spec/local_scan.xml +35 -0
- data/spec/os_class_spec.rb +1 -1
- data/spec/os_spec.rb +1 -1
- data/spec/port_spec.rb +3 -0
- data/spec/postscript_spec.rb +6 -0
- data/spec/prescript_spec.rb +6 -0
- data/spec/scan.xml +166 -88
- data/spec/scripts_examples.rb +25 -0
- data/spec/service_spec.rb +16 -6
- data/spec/spec_helper.rb +2 -1
- data/spec/tcp_ts_sequence_spec.rb +1 -1
- data/spec/xml_spec.rb +14 -2
- metadata +29 -19
- data/lib/nmap/cpe/cpe.rb +0 -45
data/spec/scripts_examples.rb
CHANGED
@@ -6,5 +6,30 @@ shared_examples_for "#scripts" do
|
|
6
6
|
|
7
7
|
it { is_expected.to be_kind_of(Hash) }
|
8
8
|
it { is_expected.not_to be_empty }
|
9
|
+
|
10
|
+
it "should contain String keys" do
|
11
|
+
expect(subject.keys).to all(be_kind_of(String))
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should contain String values" do
|
15
|
+
expect(subject.values).to all(be_kind_of(String))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
shared_examples_for "#script_data" do
|
21
|
+
describe "#script_data" do
|
22
|
+
subject { super().script_data }
|
23
|
+
|
24
|
+
it { is_expected.to be_kind_of(Hash) }
|
25
|
+
it { is_expected.not_to be_empty }
|
26
|
+
|
27
|
+
it "should contain String keys" do
|
28
|
+
expect(subject.keys).to all(be_kind_of(String))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should contain Arrays or Hashes" do
|
32
|
+
expect(subject.values).to all(be_kind_of(Array).or(be_kind_of(Hash)))
|
33
|
+
end
|
9
34
|
end
|
10
35
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -5,11 +5,13 @@ require 'nmap/xml'
|
|
5
5
|
require 'nmap/service'
|
6
6
|
|
7
7
|
describe Service do
|
8
|
-
|
8
|
+
let(:port) { @xml.host.open_ports.find { |port| port.number == 80 } }
|
9
|
+
|
10
|
+
subject { port.service }
|
9
11
|
|
10
12
|
describe "#name" do
|
11
13
|
it "should parse the name" do
|
12
|
-
expect(subject.name).to eq('
|
14
|
+
expect(subject.name).to eq('http')
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -27,19 +29,19 @@ describe Service do
|
|
27
29
|
|
28
30
|
describe "#product" do
|
29
31
|
it "should parse the product name attribute" do
|
30
|
-
expect(subject.product).to eq('
|
32
|
+
expect(subject.product).to eq('Apache httpd')
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
describe "#version" do
|
35
37
|
it "should parse the version attribute" do
|
36
|
-
expect(subject.version).to eq('
|
38
|
+
expect(subject.version).to eq('2.4.7')
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
describe "#extra_info" do
|
41
43
|
it "should parse the extrainfo attribute" do
|
42
|
-
expect(subject.extra_info).to eq('
|
44
|
+
expect(subject.extra_info).to eq('(Ubuntu)')
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -51,7 +53,7 @@ describe Service do
|
|
51
53
|
|
52
54
|
describe "#os_type" do
|
53
55
|
it "should parse the ostype attribute" do
|
54
|
-
|
56
|
+
skip "need a service with the ostype attribute"
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -73,5 +75,13 @@ describe Service do
|
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
78
|
+
describe "#to_s" do
|
79
|
+
context "when #product and #version are not nil" do
|
80
|
+
it "should include the product and version" do
|
81
|
+
expect(subject.to_s).to be == "#{subject.product} #{subject.version}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
76
86
|
it_should_behave_like "CPE"
|
77
87
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/xml_spec.rb
CHANGED
@@ -72,7 +72,7 @@ describe XML do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should parse the scanner arguments" do
|
75
|
-
expect(subject.scanner.arguments).to eq('nmap -v -sS -sU -A -O -oX spec/scan.xml scanme.nmap.org')
|
75
|
+
expect(subject.scanner.arguments).to eq('nmap -v -sS -sU -A -O --script ssh2-enum-algos,ssh-hostkey -oX spec/scan.xml scanme.nmap.org')
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should parse the scanner start time" do
|
@@ -148,7 +148,7 @@ describe XML do
|
|
148
148
|
|
149
149
|
it "should parse the end time" do
|
150
150
|
expect(subject.end_time).to be_kind_of(Time)
|
151
|
-
expect(subject.end_time).to be
|
151
|
+
expect(subject.end_time).to be >= subject.start_time
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should parse the extrainfo" do
|
@@ -163,6 +163,18 @@ describe XML do
|
|
163
163
|
it { is_expected.to all(be_kind_of(ScanTask)) }
|
164
164
|
end
|
165
165
|
|
166
|
+
describe "#prescript" do
|
167
|
+
subject { super().prescript }
|
168
|
+
|
169
|
+
pending "scan.xml does not currently include any prescript elements"
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#postscript" do
|
173
|
+
subject { super().postscript }
|
174
|
+
|
175
|
+
pending "scan.xml does not currently include any postscript elements"
|
176
|
+
end
|
177
|
+
|
166
178
|
describe "#each_host" do
|
167
179
|
subject { super().each_host.first }
|
168
180
|
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rprogram
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.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
54
|
version: '1.0'
|
55
55
|
description: A Ruby interface to Nmap, the exploration tool and security / port scanner.
|
@@ -61,11 +61,11 @@ extra_rdoc_files:
|
|
61
61
|
- LICENSE.txt
|
62
62
|
- README.md
|
63
63
|
files:
|
64
|
-
- .document
|
65
|
-
- .gitignore
|
66
|
-
- .rspec
|
67
|
-
- .travis.yml
|
68
|
-
- .yardopts
|
64
|
+
- ".document"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- ".yardopts"
|
69
69
|
- ChangeLog.md
|
70
70
|
- Gemfile
|
71
71
|
- LICENSE.txt
|
@@ -75,21 +75,24 @@ files:
|
|
75
75
|
- lib/nmap.rb
|
76
76
|
- lib/nmap/address.rb
|
77
77
|
- lib/nmap/cpe.rb
|
78
|
-
- lib/nmap/cpe/cpe.rb
|
79
78
|
- lib/nmap/cpe/url.rb
|
80
79
|
- lib/nmap/hop.rb
|
81
80
|
- lib/nmap/host.rb
|
81
|
+
- lib/nmap/host_script.rb
|
82
82
|
- lib/nmap/hostname.rb
|
83
83
|
- lib/nmap/ip_id_sequence.rb
|
84
84
|
- lib/nmap/os.rb
|
85
85
|
- lib/nmap/os_class.rb
|
86
86
|
- lib/nmap/os_match.rb
|
87
87
|
- lib/nmap/port.rb
|
88
|
+
- lib/nmap/postscript.rb
|
89
|
+
- lib/nmap/prescript.rb
|
88
90
|
- lib/nmap/program.rb
|
89
91
|
- lib/nmap/run_stat.rb
|
90
92
|
- lib/nmap/scan.rb
|
91
93
|
- lib/nmap/scan_task.rb
|
92
94
|
- lib/nmap/scanner.rb
|
95
|
+
- lib/nmap/scripts.rb
|
93
96
|
- lib/nmap/sequence.rb
|
94
97
|
- lib/nmap/service.rb
|
95
98
|
- lib/nmap/status.rb
|
@@ -105,14 +108,18 @@ files:
|
|
105
108
|
- spec/cpe/url_spec.rb
|
106
109
|
- spec/cpe_examples.rb
|
107
110
|
- spec/hop_spec.rb
|
111
|
+
- spec/host_script_spec.rb
|
108
112
|
- spec/host_spec.rb
|
109
113
|
- spec/hostname_spec.rb
|
110
114
|
- spec/ip_id_sequence_spec.rb
|
115
|
+
- spec/local_scan.xml
|
111
116
|
- spec/nmap_spec.rb
|
112
117
|
- spec/os_class_spec.rb
|
113
118
|
- spec/os_match_spec.rb
|
114
119
|
- spec/os_spec.rb
|
115
120
|
- spec/port_spec.rb
|
121
|
+
- spec/postscript_spec.rb
|
122
|
+
- spec/prescript_spec.rb
|
116
123
|
- spec/run_stat_spec.rb
|
117
124
|
- spec/scan.xml
|
118
125
|
- spec/scan_spec.rb
|
@@ -139,18 +146,18 @@ require_paths:
|
|
139
146
|
- lib
|
140
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
148
|
requirements:
|
142
|
-
- -
|
149
|
+
- - ">="
|
143
150
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
151
|
+
version: 2.0.0
|
145
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
153
|
requirements:
|
147
|
-
- -
|
154
|
+
- - ">="
|
148
155
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
156
|
+
version: 2.0.0
|
150
157
|
requirements:
|
151
158
|
- nmap >= 5.00
|
152
159
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.4.7
|
154
161
|
signing_key:
|
155
162
|
specification_version: 4
|
156
163
|
summary: A Ruby interface to Nmap.
|
@@ -158,6 +165,7 @@ test_files:
|
|
158
165
|
- spec/address_spec.rb
|
159
166
|
- spec/cpe/url_spec.rb
|
160
167
|
- spec/hop_spec.rb
|
168
|
+
- spec/host_script_spec.rb
|
161
169
|
- spec/host_spec.rb
|
162
170
|
- spec/hostname_spec.rb
|
163
171
|
- spec/ip_id_sequence_spec.rb
|
@@ -166,6 +174,8 @@ test_files:
|
|
166
174
|
- spec/os_match_spec.rb
|
167
175
|
- spec/os_spec.rb
|
168
176
|
- spec/port_spec.rb
|
177
|
+
- spec/postscript_spec.rb
|
178
|
+
- spec/prescript_spec.rb
|
169
179
|
- spec/run_stat_spec.rb
|
170
180
|
- spec/scan_spec.rb
|
171
181
|
- spec/scan_task_spec.rb
|
data/lib/nmap/cpe/cpe.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'nmap/cpe/url'
|
2
|
-
|
3
|
-
module Nmap
|
4
|
-
#
|
5
|
-
# Mixins that adds methods for parsing [Common Platform Enumeration
|
6
|
-
# (CPE)][CPE] information.
|
7
|
-
#
|
8
|
-
# [CPE]: http://nmap.org/book/output-formats-cpe.html
|
9
|
-
#
|
10
|
-
# @since 0.7.0
|
11
|
-
#
|
12
|
-
module CPE
|
13
|
-
#
|
14
|
-
# Parses each Common Platform Enumeration (CPE) String.
|
15
|
-
#
|
16
|
-
# @yield [cpe]
|
17
|
-
# Passes each CPE URL to the given block.
|
18
|
-
#
|
19
|
-
# @yieldparam [URL] cpe
|
20
|
-
# The CPE URL.
|
21
|
-
#
|
22
|
-
# @return [Enumerator]
|
23
|
-
# If no block is given, an enumerator object will be returned.
|
24
|
-
#
|
25
|
-
def each_cpe
|
26
|
-
return enum_for(__method__) unless block_given?
|
27
|
-
|
28
|
-
@node.xpath('//cpe').each do |cpe|
|
29
|
-
yield URL.parse(cpe.inner_text)
|
30
|
-
end
|
31
|
-
|
32
|
-
return self
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Parses each Common Platform Enumeration (CPE) String.
|
37
|
-
#
|
38
|
-
# @return [Array<URL>]
|
39
|
-
# The CPE URLs.
|
40
|
-
#
|
41
|
-
def cpe
|
42
|
-
each_cpe.to_a
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|