ruby-ncrack 0.1.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 +7 -0
- data/.document +3 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +10 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.md +84 -0
- data/Rakefile +12 -0
- data/gemspec.yml +26 -0
- data/lib/ncrack/command.rb +108 -0
- data/lib/ncrack/version.rb +4 -0
- data/lib/ncrack/xml/address.rb +79 -0
- data/lib/ncrack/xml/credentials.rb +64 -0
- data/lib/ncrack/xml/port.rb +82 -0
- data/lib/ncrack/xml/service.rb +104 -0
- data/lib/ncrack/xml.rb +234 -0
- data/lib/ncrack.rb +2 -0
- data/ruby-ncrack.gemspec +58 -0
- data/spec/fixtures/ncrack.xml +13 -0
- data/spec/ncrack_spec.rb +8 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/xml/address_spec.rb +73 -0
- data/spec/xml/credentials_spec.rb +49 -0
- data/spec/xml/port_spec.rb +57 -0
- data/spec/xml/service_spec.rb +86 -0
- data/spec/xml_spec.rb +184 -0
- metadata +122 -0
data/spec/xml_spec.rb
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ncrack/xml'
|
3
|
+
|
4
|
+
describe Ncrack::XML do
|
5
|
+
let(:fixtures_dir) { File.expand_path(File.join(__dir__,'fixtures')) }
|
6
|
+
let(:path) { File.join(fixtures_dir,'ncrack.xml') }
|
7
|
+
let(:xml) { File.read(path) }
|
8
|
+
let(:doc) { Nokogiri::XML(File.open(path)) }
|
9
|
+
|
10
|
+
subject { described_class.new(doc, path: path) }
|
11
|
+
|
12
|
+
describe "#initialize" do
|
13
|
+
it "must set #doc" do
|
14
|
+
expect(subject.doc).to eq(doc)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when given a block" do
|
18
|
+
it "must yield the new XML object" do
|
19
|
+
expect { |b|
|
20
|
+
described_class.new(xml,&b)
|
21
|
+
}.to yield_with_args(described_class)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when the path: keyword argument is not given" do
|
26
|
+
subject { described_class.new(xml) }
|
27
|
+
|
28
|
+
it "must set #path to nil" do
|
29
|
+
expect(subject.path).to be(nil)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when the path: keyword argument is given" do
|
34
|
+
subject { described_class.new(xml, path: path) }
|
35
|
+
|
36
|
+
it "must set #path" do
|
37
|
+
expect(subject.path).to eq(path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".parse" do
|
43
|
+
subject { described_class.parse(xml) }
|
44
|
+
|
45
|
+
it "must parse the XML data" do
|
46
|
+
expect(subject.doc).to be_kind_of(Nokogiri::XML::Document)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "must set #path to nil" do
|
50
|
+
expect(subject.path).to be(nil)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".open" do
|
55
|
+
subject { described_class.open(path) }
|
56
|
+
|
57
|
+
it "must open the file and parse the XML" do
|
58
|
+
expect(subject.doc).to be_kind_of(Nokogiri::XML::Document)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "must set #path" do
|
62
|
+
expect(subject.path).to eq(path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#scanner" do
|
67
|
+
subject { super().scanner }
|
68
|
+
|
69
|
+
it "must return the 'scanner' attribute" do
|
70
|
+
expect(subject).to eq(doc.root['scanner'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#args" do
|
75
|
+
subject { super().args }
|
76
|
+
|
77
|
+
it "must return the 'args' attribute" do
|
78
|
+
expect(subject).to eq(doc.root['args'])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#start" do
|
83
|
+
subject { super().start }
|
84
|
+
|
85
|
+
it "must return the 'start' attribute as a Time object" do
|
86
|
+
expect(subject).to eq(Time.at(doc.root['start'].to_i))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#version" do
|
91
|
+
subject { super().version }
|
92
|
+
|
93
|
+
it "must return the 'version' attribute" do
|
94
|
+
expect(subject).to eq(doc.root['version'])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#xml_output_version" do
|
99
|
+
subject { super().xml_output_version }
|
100
|
+
|
101
|
+
it "must return the 'xmloutputversion' attribute" do
|
102
|
+
expect(subject).to eq(doc.root['xmloutputversion'])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#verbose" do
|
107
|
+
subject { super().verbose }
|
108
|
+
|
109
|
+
it "must return the 'level' attribute of the 'verbose' child element as an Integer" do
|
110
|
+
expect(subject).to eq(doc.root.at_xpath('verbose')['level'].to_i)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "must be > 0" do
|
114
|
+
expect(subject).to be > 0
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#debugging" do
|
119
|
+
subject { super().debugging }
|
120
|
+
|
121
|
+
it "must return the 'level' attribute of the 'debugging' child element as an Integer" do
|
122
|
+
expect(subject).to eq(doc.root.at_xpath('debugging')['level'].to_i)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
let(:services_count) { doc.root.xpath('/ncrackrun/service').count }
|
127
|
+
|
128
|
+
describe "#each_service" do
|
129
|
+
context "when given a block" do
|
130
|
+
it "must yield each Service object" do
|
131
|
+
expect { |b|
|
132
|
+
subject.each_service(&b)
|
133
|
+
}.to yield_successive_args(*Array.new(services_count,described_class::Service))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when no block is given" do
|
138
|
+
subject { super().each_service.to_a }
|
139
|
+
|
140
|
+
it "must return an Enumerator of #{described_class}::Service objects" do
|
141
|
+
expect(subject.length).to be(services_count)
|
142
|
+
expect(subject).to all(be_kind_of(described_class::Service))
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "#services" do
|
148
|
+
subject { super().services }
|
149
|
+
|
150
|
+
it "must return an Array of #{described_class}::Service" do
|
151
|
+
expect(subject).to be_kind_of(Array)
|
152
|
+
expect(subject.length).to be(services_count)
|
153
|
+
expect(subject).to all(be_kind_of(described_class::Service))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "#service" do
|
158
|
+
let(:first_service) { subject.services.first }
|
159
|
+
let(:service) { subject.service }
|
160
|
+
|
161
|
+
it "must return the first #scan_details" do
|
162
|
+
expect(service.start_time).to eq(first_service.start_time)
|
163
|
+
expect(service.end_time).to eq(first_service.end_time)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#to_s" do
|
168
|
+
context "when #path is set" do
|
169
|
+
subject { described_class.open(path) }
|
170
|
+
|
171
|
+
it "must return the #path" do
|
172
|
+
expect(subject.to_s).to eq(path)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "when #path is nil" do
|
177
|
+
subject { described_class.parse(xml) }
|
178
|
+
|
179
|
+
it "must return the XML" do
|
180
|
+
expect(subject.to_s).to eq(doc.to_s)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-ncrack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Postmodern
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: command_mapper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: A Ruby interface to Ncrack, Network authentication cracking tool.
|
56
|
+
email: postmodern.mod3@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- ChangeLog.md
|
61
|
+
- LICENSE.txt
|
62
|
+
- README.md
|
63
|
+
files:
|
64
|
+
- ".document"
|
65
|
+
- ".editorconfig"
|
66
|
+
- ".github/workflows/ruby.yml"
|
67
|
+
- ".gitignore"
|
68
|
+
- ".rspec"
|
69
|
+
- ".yardopts"
|
70
|
+
- ChangeLog.md
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- gemspec.yml
|
76
|
+
- lib/ncrack.rb
|
77
|
+
- lib/ncrack/command.rb
|
78
|
+
- lib/ncrack/version.rb
|
79
|
+
- lib/ncrack/xml.rb
|
80
|
+
- lib/ncrack/xml/address.rb
|
81
|
+
- lib/ncrack/xml/credentials.rb
|
82
|
+
- lib/ncrack/xml/port.rb
|
83
|
+
- lib/ncrack/xml/service.rb
|
84
|
+
- ruby-ncrack.gemspec
|
85
|
+
- spec/fixtures/ncrack.xml
|
86
|
+
- spec/ncrack_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/xml/address_spec.rb
|
89
|
+
- spec/xml/credentials_spec.rb
|
90
|
+
- spec/xml/port_spec.rb
|
91
|
+
- spec/xml/service_spec.rb
|
92
|
+
- spec/xml_spec.rb
|
93
|
+
homepage: http://github.com/postmodern/ruby-ncrack#readme
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata:
|
97
|
+
documentation_uri: https://rubydoc.info/gems/ruby-ncrack
|
98
|
+
source_code_uri: https://github.com/postmodern/ruby-ncrack
|
99
|
+
bug_tracker_uri: https://github.com/postmodern/ruby-ncrack/issues
|
100
|
+
changelog_uri: https://github.com/postmodern/ruby-ncrack/blob/master/ChangeLog.md
|
101
|
+
rubygems_mfa_required: 'true'
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements:
|
117
|
+
- ncrack >= 0.7
|
118
|
+
rubygems_version: 3.2.22
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: A Ruby interface to Ncrack.
|
122
|
+
test_files: []
|