ruby-nmap 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +8 -0
- data/README.md +1 -1
- data/lib/nmap/address.rb +5 -22
- data/lib/nmap/host.rb +78 -45
- data/lib/nmap/ip_id_sequence.rb +6 -1
- data/lib/nmap/os.rb +5 -2
- data/lib/nmap/os_class.rb +5 -36
- data/lib/nmap/os_match.rb +5 -22
- data/lib/nmap/port.rb +12 -5
- data/lib/nmap/program.rb +3 -0
- data/lib/nmap/scan.rb +6 -14
- data/lib/nmap/scanner.rb +5 -36
- data/lib/nmap/sequence.rb +5 -0
- data/lib/nmap/service.rb +82 -0
- data/lib/nmap/status.rb +5 -22
- data/lib/nmap/tcp_sequence.rb +5 -0
- data/lib/nmap/tcp_ts_sequence.rb +3 -0
- data/lib/nmap/version.rb +1 -1
- data/lib/nmap/xml.rb +6 -3
- data/spec/host_spec.rb +26 -27
- data/spec/ip_id_sequence_spec.rb +20 -0
- data/spec/nmap_spec.rb +1 -1
- data/spec/os_spec.rb +6 -11
- data/spec/port_spec.rb +15 -20
- data/spec/service_spec.rb +40 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/task_spec.rb +0 -2
- data/spec/tcp_sequence_spec.rb +31 -0
- data/spec/tcp_ts_sequence_spec.rb +20 -0
- data/spec/xml_spec.rb +13 -19
- metadata +11 -4
- data/spec/sequence_spec.rb +0 -75
data/spec/nmap_spec.rb
CHANGED
data/spec/os_spec.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'helpers/xml'
|
3
2
|
|
4
3
|
require 'nmap/os'
|
5
|
-
require 'nmap/xml'
|
6
4
|
require 'cgi'
|
7
5
|
|
8
6
|
describe OS do
|
9
|
-
|
7
|
+
let(:xml) { XML.new(Helpers::SCAN_FILE) }
|
10
8
|
|
11
|
-
|
12
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
13
|
-
@os = @xml.hosts.first.os
|
14
|
-
end
|
9
|
+
subject { xml.hosts.first.os }
|
15
10
|
|
16
11
|
it "should parse the OS classes" do
|
17
|
-
classes =
|
12
|
+
classes = subject.classes
|
18
13
|
|
19
14
|
classes.length.should == 1
|
20
15
|
classes[0].type.should == :WAP
|
@@ -24,7 +19,7 @@ describe OS do
|
|
24
19
|
end
|
25
20
|
|
26
21
|
it "should parse the OS matches" do
|
27
|
-
matches =
|
22
|
+
matches = subject.matches
|
28
23
|
|
29
24
|
matches.length.should == 2
|
30
25
|
|
@@ -36,10 +31,10 @@ describe OS do
|
|
36
31
|
end
|
37
32
|
|
38
33
|
it "should parse the ports used" do
|
39
|
-
|
34
|
+
subject.ports_used.should == [443, 21]
|
40
35
|
end
|
41
36
|
|
42
37
|
it "should parse the OS fingerprints" do
|
43
|
-
|
38
|
+
subject.fingerprint.should == CGI.unescapeHTML("SCAN(V=4.68%D=8/16%OT=443%CT=21%CU=%PV=Y%DS=1%G=N%M=001D7E%TM=48A77607%P=i686-pc-linux-gnu)
SEQ(SP=19%GCD=FA00%ISR=9E%TI=I%TS=1)
OPS(O1=M5B4NW0NNT11%O2=M5B4NW0NNT11%O3=M5B4NW0NNT11%O4=M5B4NW0NNT11%O5=M5B4NW0NNT11%O6=M5B4NNT11)
WIN(W1=2000%W2=2000%W3=2000%W4=2000%W5=2000%W6=2000)
ECN(R=Y%DF=N%TG=40%W=2000%O=M5B4NW0%CC=N%Q=)
T1(R=Y%DF=N%TG=40%S=O%A=S+%F=AS%RD=0%Q=)
T2(R=N)
T3(R=N)
T4(R=N)
T5(R=Y%DF=N%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
T6(R=N)
T7(R=N)
U1(R=N)
IE(R=N)
")
|
44
39
|
end
|
45
40
|
end
|
data/spec/port_spec.rb
CHANGED
@@ -1,44 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'helpers/xml'
|
3
|
-
|
4
|
-
require 'nmap/xml'
|
5
2
|
require 'nmap/port'
|
6
3
|
|
7
4
|
describe Port do
|
8
|
-
|
9
|
-
|
10
|
-
before(:all) do
|
11
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
12
|
-
@nse_xml = XML.new(Helpers::NSE_FILE)
|
5
|
+
let(:xml) { XML.new(Helpers::SCAN_FILE) }
|
13
6
|
|
14
|
-
|
15
|
-
@nse_port = @nse_xml.hosts.first.ports.first
|
16
|
-
end
|
7
|
+
subject { xml.hosts.first.ports.first }
|
17
8
|
|
18
9
|
it "should parse the protocol" do
|
19
|
-
|
10
|
+
subject.protocol.should == :tcp
|
20
11
|
end
|
21
12
|
|
22
13
|
it "should parse the port number" do
|
23
|
-
|
14
|
+
subject.number.should == 21
|
24
15
|
end
|
25
16
|
|
26
17
|
it "should parse the state" do
|
27
|
-
|
18
|
+
subject.state.should == :closed
|
28
19
|
end
|
29
20
|
|
30
21
|
it "should parse the reason" do
|
31
|
-
|
22
|
+
subject.reason.should == 'reset'
|
32
23
|
end
|
33
24
|
|
34
25
|
it "should parse the detected service" do
|
35
|
-
|
26
|
+
subject.service.name.should == 'ftp'
|
36
27
|
end
|
37
28
|
|
38
|
-
|
39
|
-
|
29
|
+
context "when NSE scripts are ran" do
|
30
|
+
let(:xml) { XML.new(Helpers::NSE_FILE) }
|
31
|
+
|
32
|
+
it "should parse the output of scripts" do
|
33
|
+
subject.scripts.should_not be_empty
|
40
34
|
|
41
|
-
|
42
|
-
|
35
|
+
subject.scripts.keys.should_not include(nil)
|
36
|
+
subject.scripts.values.should_not include(nil)
|
37
|
+
end
|
43
38
|
end
|
44
39
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'helpers/xml'
|
3
|
+
|
4
|
+
require 'nmap/xml'
|
5
|
+
require 'nmap/service'
|
6
|
+
|
7
|
+
describe Service do
|
8
|
+
include Helpers
|
9
|
+
|
10
|
+
before(:all) do
|
11
|
+
@xml = XML.new(Helpers::SCAN_FILE)
|
12
|
+
@nse_xml = XML.new(Helpers::NSE_FILE)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { @xml.hosts.first.ports.first.service }
|
16
|
+
|
17
|
+
it "should have a name" do
|
18
|
+
subject.name.should == 'ftp'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have a fingerprint method" do
|
22
|
+
subject.fingerprint_method.should == :table
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have a confidence" do
|
26
|
+
subject.confidence.should == 3
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with improved detection" do
|
30
|
+
subject { @nse_xml.hosts.first.ports.first.service }
|
31
|
+
|
32
|
+
it "should have a product name" do
|
33
|
+
subject.product.should == 'OpenSSH'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a version" do
|
37
|
+
subject.version.should == '5.1p1 Debian 6ubuntu2'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/task_spec.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nmap/tcp_sequence'
|
3
|
+
|
4
|
+
describe TcpSequence do
|
5
|
+
let(:xml) { XML.new(Helpers::SCAN_FILE) }
|
6
|
+
|
7
|
+
subject { xml.hosts.first.tcp_sequence }
|
8
|
+
|
9
|
+
it "should be accessible from host objects" do
|
10
|
+
subject.should be_kind_of(TcpSequence)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse the index" do
|
14
|
+
subject.index.should == 25
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse the difficulty description" do
|
18
|
+
subject.difficulty.should == "Good luck!"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse the values" do
|
22
|
+
subject.values.should == [
|
23
|
+
0xAF1B39BD,
|
24
|
+
0xAF1C33BD,
|
25
|
+
0xAF1F21BD,
|
26
|
+
0xAF201BBD,
|
27
|
+
0xAF2115BD,
|
28
|
+
0xAF220FBD
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nmap/tcp_ts_sequence'
|
3
|
+
|
4
|
+
describe TcpTsSequence do
|
5
|
+
let(:xml) { XML.new(Helpers::SCAN_FILE) }
|
6
|
+
|
7
|
+
subject { xml.hosts.first.tcp_ts_sequence }
|
8
|
+
|
9
|
+
it "should be accessible from host objects" do
|
10
|
+
subject.should be_kind_of(TcpTsSequence)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse the description" do
|
14
|
+
subject.description.should == "2HZ"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse the values" do
|
18
|
+
subject.values.should == [0x1858, 0x1858, 0x1859, 0x1859, 0x1859, 0x1859]
|
19
|
+
end
|
20
|
+
end
|
data/spec/xml_spec.rb
CHANGED
@@ -1,37 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'helpers/xml'
|
3
|
-
|
4
2
|
require 'nmap/xml'
|
5
3
|
|
6
4
|
describe XML do
|
7
|
-
|
8
|
-
|
9
|
-
before(:all) do
|
10
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
11
|
-
end
|
5
|
+
subject { XML.new(Helpers::SCAN_FILE) }
|
12
6
|
|
13
7
|
it "should have a version" do
|
14
|
-
|
8
|
+
subject.version.should == '1.02'
|
15
9
|
end
|
16
10
|
|
17
11
|
it "should parse the scanner version" do
|
18
|
-
|
12
|
+
subject.scanner.version == '4.68'
|
19
13
|
end
|
20
14
|
|
21
15
|
it "should parse the scanner name" do
|
22
|
-
|
16
|
+
subject.scanner.name.should == 'nmap'
|
23
17
|
end
|
24
18
|
|
25
19
|
it "should parse the scanner arguments" do
|
26
|
-
|
20
|
+
subject.scanner.arguments.should == 'nmap -v -oX samples/backspace.xml -O -P0 -sS 192.168.5.*'
|
27
21
|
end
|
28
22
|
|
29
23
|
it "should parse the scanner start time" do
|
30
|
-
|
24
|
+
subject.scanner.start_time.should == Time.at(1218934249)
|
31
25
|
end
|
32
26
|
|
33
27
|
it "should parse the scan information" do
|
34
|
-
scan_info =
|
28
|
+
scan_info = subject.scan_info
|
35
29
|
|
36
30
|
scan_info.length.should == 1
|
37
31
|
scan_info.first.type.should == :syn
|
@@ -39,15 +33,15 @@ describe XML do
|
|
39
33
|
end
|
40
34
|
|
41
35
|
it "should parse the verbose level" do
|
42
|
-
|
36
|
+
subject.verbose.should == 1
|
43
37
|
end
|
44
38
|
|
45
39
|
it "should parse the debugging level" do
|
46
|
-
|
40
|
+
subject.debugging.should == 0
|
47
41
|
end
|
48
42
|
|
49
43
|
it "should parse the scan tasks" do
|
50
|
-
tasks =
|
44
|
+
tasks = subject.tasks
|
51
45
|
|
52
46
|
tasks.should_not be_empty
|
53
47
|
|
@@ -63,14 +57,14 @@ describe XML do
|
|
63
57
|
end
|
64
58
|
|
65
59
|
it "should parse the hosts" do
|
66
|
-
|
60
|
+
subject.hosts.length.should == 10
|
67
61
|
end
|
68
62
|
|
69
63
|
it "should iterate over each up host" do
|
70
|
-
|
64
|
+
subject.each.all? { |host| host.status.state == :up }.should == true
|
71
65
|
end
|
72
66
|
|
73
67
|
it "should convert to a String" do
|
74
|
-
|
68
|
+
subject.to_s.should == Helpers::SCAN_FILE
|
75
69
|
end
|
76
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/nmap/scan_task.rb
|
124
124
|
- lib/nmap/scanner.rb
|
125
125
|
- lib/nmap/sequence.rb
|
126
|
+
- lib/nmap/service.rb
|
126
127
|
- lib/nmap/status.rb
|
127
128
|
- lib/nmap/task.rb
|
128
129
|
- lib/nmap/tcp_sequence.rb
|
@@ -134,12 +135,15 @@ files:
|
|
134
135
|
- spec/helpers/scan.xml
|
135
136
|
- spec/helpers/xml.rb
|
136
137
|
- spec/host_spec.rb
|
138
|
+
- spec/ip_id_sequence_spec.rb
|
137
139
|
- spec/nmap_spec.rb
|
138
140
|
- spec/os_spec.rb
|
139
141
|
- spec/port_spec.rb
|
140
|
-
- spec/
|
142
|
+
- spec/service_spec.rb
|
141
143
|
- spec/spec_helper.rb
|
142
144
|
- spec/task_spec.rb
|
145
|
+
- spec/tcp_sequence_spec.rb
|
146
|
+
- spec/tcp_ts_sequence_spec.rb
|
143
147
|
- spec/xml_spec.rb
|
144
148
|
homepage: https://github.com/sophsec/ruby-nmap#readme
|
145
149
|
licenses:
|
@@ -169,9 +173,12 @@ specification_version: 3
|
|
169
173
|
summary: A Ruby interface to Nmap.
|
170
174
|
test_files:
|
171
175
|
- spec/host_spec.rb
|
176
|
+
- spec/ip_id_sequence_spec.rb
|
172
177
|
- spec/nmap_spec.rb
|
173
178
|
- spec/os_spec.rb
|
174
179
|
- spec/port_spec.rb
|
175
|
-
- spec/
|
180
|
+
- spec/service_spec.rb
|
176
181
|
- spec/task_spec.rb
|
182
|
+
- spec/tcp_sequence_spec.rb
|
183
|
+
- spec/tcp_ts_sequence_spec.rb
|
177
184
|
- spec/xml_spec.rb
|
data/spec/sequence_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'helpers/xml'
|
3
|
-
|
4
|
-
require 'nmap/tcp_sequence'
|
5
|
-
require 'nmap/tcp_ts_sequence'
|
6
|
-
require 'nmap/ip_id_sequence'
|
7
|
-
require 'nmap/xml'
|
8
|
-
require 'cgi'
|
9
|
-
|
10
|
-
describe TcpSequence do
|
11
|
-
include Helpers
|
12
|
-
|
13
|
-
before(:all) do
|
14
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
15
|
-
@tcpsequence = @xml.hosts.first.tcpsequence
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be accessible from host objects" do
|
19
|
-
@tcpsequence.should be_kind_of(TcpSequence)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should parse the index" do
|
23
|
-
@tcpsequence.index.should == 25
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should parse the difficulty description" do
|
27
|
-
@tcpsequence.difficulty.should == "Good luck!"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should parse the values" do
|
31
|
-
@tcpsequence.values.should == [0xAF1B39BD,0xAF1C33BD,0xAF1F21BD,0xAF201BBD,0xAF2115BD,0xAF220FBD]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe IpidSequence do
|
36
|
-
include Helpers
|
37
|
-
|
38
|
-
before(:all) do
|
39
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
40
|
-
@ipidsequence = @xml.hosts.first.ipidsequence
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should be accessible from host objects" do
|
44
|
-
@ipidsequence.should be_kind_of(IpidSequence)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should parse the description" do
|
48
|
-
@ipidsequence.description.should == "Incremental"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should parse the values" do
|
52
|
-
@ipidsequence.values.should == [0x1FB0,0x1FB2,0x1FB4,0x1FB6,0x1FB8,0x1FBA]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe TcpTsSequence do
|
57
|
-
include Helpers
|
58
|
-
|
59
|
-
before(:all) do
|
60
|
-
@xml = XML.new(Helpers::SCAN_FILE)
|
61
|
-
@tcptssequence = @xml.hosts.first.tcptssequence
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should be accessible from host objects" do
|
65
|
-
@tcptssequence.should be_kind_of(TcpTsSequence)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should parse the description" do
|
69
|
-
@tcptssequence.description.should == "2HZ"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should parse the values" do
|
73
|
-
@tcptssequence.values.should == [0x1858,0x1858,0x1859,0x1859,0x1859,0x1859]
|
74
|
-
end
|
75
|
-
end
|