dradis-qualys 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Qualys::Element do
4
+ pending "create some unit tests for the Qualys::Element wrapper class"
5
+ end
@@ -0,0 +1,190 @@
1
+ require "spec_helper"
2
+ require "ostruct"
3
+
4
+ describe Dradis::Plugins::Qualys::Importer do
5
+ let(:plugin) { Dradis::Plugins::Qualys }
6
+
7
+ let(:content_service) { Dradis::Plugins::ContentService.new(plugin: plugin) }
8
+ let(:template_service) { Dradis::Plugins::TemplateService.new(plugin: plugin) }
9
+
10
+ let(:importer) {
11
+ described_class.new(
12
+ content_service: content_service,
13
+ template_service: template_service
14
+ )
15
+ }
16
+
17
+ before do
18
+ # Stub template service
19
+ templates_dir = File.expand_path('../../../templates', __FILE__)
20
+ allow_any_instance_of(Dradis::Plugins::TemplateService).to \
21
+ receive(:default_templates_dir).and_return(templates_dir)
22
+
23
+ # Stub dradis-plugins methods
24
+ #
25
+ # They return their argument hashes as objects mimicking
26
+ # Nodes, Issues, etc
27
+ %i[node note evidence issue].each do |model|
28
+ allow(content_service).to receive(:"create_#{model}") do |args|
29
+ OpenStruct.new(args)
30
+ end
31
+ end
32
+ end
33
+
34
+ let(:example_xml) { 'spec/fixtures/files/simple.xml' }
35
+
36
+ pending "collapses INFOS|SERVICES|VULNS|PRACTICES node if only a single element is found"
37
+
38
+ def run_import!
39
+ importer.import(file: example_xml)
40
+ end
41
+
42
+ it "creates nodes as needed" do
43
+ # Host node
44
+ expect_to_create_node_with(label: '10.0.155.160')
45
+
46
+ # Information gathering node
47
+ expect_to_create_node_with(label: 'infos - Information gathering')
48
+
49
+ # Services node with its child nodes
50
+ expect_to_create_node_with(label: 'services')
51
+ expect_to_create_node_with(label: 'TCP/IP')
52
+ expect_to_create_node_with(label: 'Web server')
53
+
54
+ run_import!
55
+ end
56
+
57
+
58
+ it "creates notes as needed" do
59
+ # Host node notes
60
+ expect_to_create_note_with(text: "Basic host info")
61
+
62
+ # Information gathering node and notes
63
+ expect_to_create_note_with(
64
+ text: "DNS Host Name",
65
+ node_label: "infos - Information gathering"
66
+ )
67
+ expect_to_create_note_with(
68
+ text: "Host Scan Time",
69
+ node_label: "infos - Information gathering"
70
+ )
71
+
72
+ # Child notes of Services node
73
+ expect_to_create_note_with(
74
+ text: "Open TCP Services List",
75
+ node_label: "TCP/IP"
76
+ )
77
+
78
+ expect_to_create_note_with(
79
+ text: "Web Server Version",
80
+ node_label: "Web server"
81
+ )
82
+
83
+ run_import!
84
+ end
85
+
86
+ # Issues and evidences from vulns
87
+ # There are 3 vulns in total:
88
+ # - TCP/IP: Sequence number in both hosts
89
+ # - Web server: Apache 1.3
90
+ # - Web server: ETag
91
+ # Each one should create 1 issue and 1 evidence
92
+
93
+ it "creates issues from vulns" do
94
+ expect_to_create_issue_with(
95
+ text: "Sequence Number Approximation Based Denial of Service"
96
+ )
97
+
98
+ expect_to_create_issue_with(
99
+ text: "Apache 1.3 HTTP Server Expect Header Cross-Site Scripting"
100
+ )
101
+
102
+ expect_to_create_issue_with(
103
+ text: "Apache Web Server ETag Header Information Disclosure Weakness"
104
+ )
105
+
106
+ run_import!
107
+ end
108
+
109
+ it "creates evidence from vulns" do
110
+ expect_to_create_evidence_with(
111
+ content: "Tested on port 80 with an injected SYN/RST offset by 16 bytes.",
112
+ issue: "Sequence Number Approximation Based Denial of Service",
113
+ node_label: "10.0.155.160"
114
+ )
115
+
116
+ expect_to_create_evidence_with(
117
+ content: "The expectation given in the Expect request-header",
118
+ issue: "Apache 1.3 HTTP Server Expect Header Cross-Site Scripting",
119
+ node_label: "10.0.155.160"
120
+ )
121
+
122
+ expect_to_create_evidence_with(
123
+ content: "bee-4f12-00794aef",
124
+ issue: "Apache Web Server ETag Header Information Disclosure Weakness",
125
+ node_label: "10.0.155.160"
126
+ )
127
+
128
+ run_import!
129
+ end
130
+
131
+ # A VULN is not required to have a RESULT element.
132
+ # See:
133
+ # https://github.com/securityroots/dradispro-tracker/issues/8
134
+ # https://qualysapi.qualys.eu/qwebhelp/fo_help/reports/report_dtd.htm
135
+ context "when an issue has no RESULT element" do
136
+ let(:example_xml) { 'spec/fixtures/files/no_result.xml' }
137
+
138
+ it "detects an issue without a RESULT element and applies (n/a)" do
139
+ # 1 node should be created:
140
+ expect_to_create_node_with(label: '10.0.155.160')
141
+
142
+ # There is 1 vuln in total:
143
+ # - TCP/IP: Sequence number in both hosts
144
+ # Each one should create 1 issue and 1 evidence
145
+ expect_to_create_issue_with(
146
+ text: "Sequence Number Approximation Based Denial of Service"
147
+ )
148
+
149
+ expect_to_create_evidence_with(
150
+ content: "n/a",
151
+ issue: "Sequence Number Approximation Based Denial of Service",
152
+ node_label: "10.0.155.160"
153
+ )
154
+
155
+ run_import!
156
+ end
157
+ end
158
+
159
+
160
+ def expect_to_create_node_with(label:)
161
+ expect(content_service).to receive(:create_node).with(
162
+ hash_including label: label
163
+ ).once
164
+ end
165
+
166
+ def expect_to_create_note_with(node_label: nil, text:)
167
+ expect(content_service).to receive(:create_note) do |args|
168
+ expect(args[:text]).to include text
169
+ expect(args[:node].label).to eq node_label unless node_label.nil?
170
+ end.once
171
+ end
172
+
173
+ def expect_to_create_issue_with(text:)
174
+ expect(content_service).to receive(:create_issue) do |args|
175
+ expect(args[:text]).to include text
176
+ OpenStruct.new(args)
177
+ end.once
178
+ end
179
+
180
+ def expect_to_create_evidence_with(content:, issue:, node_label:)
181
+ expect(content_service).to receive(:create_evidence) do |args|
182
+ expect(args[:content]).to include content
183
+ expect(args[:issue].text).to include issue
184
+ expect(args[:node].label).to eq node_label
185
+ end.once
186
+ end
187
+
188
+
189
+ end
190
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'nokogiri'
4
+
5
+ require 'combustion'
6
+
7
+ Combustion.initialize!
8
+
9
+ RSpec.configure do |config|
10
+ end
@@ -0,0 +1,16 @@
1
+ element.number
2
+ element.severity
3
+ element.cveid
4
+ element.title
5
+ element.last_update
6
+ element.cvss_base
7
+ element.cvss_temporal
8
+ element.pci_flag
9
+ element.vendor_reference_list
10
+ element.cve_id_list
11
+ element.bugtraq_id_list
12
+ element.diagnosis
13
+ element.consequence
14
+ element.solution
15
+ element.compliance
16
+ element.result
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0"?>
2
+ <CAT value="Web server" port="443" protocol="tcp">
3
+ <VULN number="42366" severity="3" cveid="CVE-2011-3389">
4
+ <TITLE><![CDATA[SSLv3.0/TLSv1.0 Protocol Weak CBC Mode Vulnerability]]></TITLE>
5
+ <LAST_UPDATE><![CDATA[2011-12-30T18:56:26Z]]></LAST_UPDATE>
6
+ <CVSS_BASE>4.3</CVSS_BASE>
7
+ <CVSS_TEMPORAL>3.5</CVSS_TEMPORAL>
8
+ <PCI_FLAG>0</PCI_FLAG>
9
+ <CVE_ID_LIST>
10
+ <CVE_ID>
11
+ <ID><![CDATA[CVE-2011-3389]]></ID>
12
+ <URL><![CDATA[http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3389]]></URL>
13
+ </CVE_ID>
14
+ </CVE_ID_LIST>
15
+ <DIAGNOSIS><![CDATA[SSLv 3.0 and TLS v1.0 protocols are used to provide integrity, authenticity and privacy to other protocols such as HTTP and LDAP. They provide these services by using encryption for privacy, x509 certificates for authenticity and one-way hash functions for integrity. To encrypt data SSL and TLS can use block ciphers, which are encryption algorithms that can encrypt only a fixed block of original data to an encrypted block of the same size. Note that these cihpers will always obtain the same resulting block for the same original blockof data. To achieve difference in the output the output of encryption is XORed with yet another block of the same size referred to as initialization vectors (IV). A special mode of operation for block ciphers known as CBC (cipher block chaining) uses one IV for the initial block and the result of the previous block for each subsequent block to obtain difference in the output of block cipher encryption.
16
+ <P>
17
+ In SSLv3.0 and TLSv1.0 implementation the choice CBC mode usage was poor because the entire traffic shares one CBC session with single set of initial IVs. The rest of the IV are as mentioned above results of the encryption of the previous blocks. The subsequent IV are available to the eavesdroppers. This allows an attacker with the capability to inject arbitrary traffic into the plain-text stream (to be encrypted by the client) to verify their guess of the plain-text preceding the injected block. If the attackers guess is correct then the output of the encryption will be the same for two blocks.
18
+ <P>For low entropy data it is possible to guess the plain-text block with relatively few number of attempts. For example for data that has 1000 possibilities the number of attempts can be 500.
19
+ <P>For more information please see <A HREF="http://eprint.iacr.org/2006/136.pdf" TARGET="_blank">a paper by Gregory V. Bard.</A>]]></DIAGNOSIS>
20
+ <CONSEQUENCE><![CDATA[Recently attacks against the web authentication cookies have been described which used this vulnerability. If the authentication cookie is guessed by the attacker then the attacker can impersonate the legitimate user on the Web site which accepts the authentication cookie.]]></CONSEQUENCE>
21
+ <SOLUTION><![CDATA[This attack was identified in 2004 and later revisions of TLS protocol which contain a fix for this. If possible, upgrade to TLSv1.1 or TLSv1.2. If upgrading to TLSv1.1 or TLSv1.2 is not possible, then disabling CBC mode ciphers will remove the vulnerability.
22
+ <P>
23
+ Openssl.org has posted information including countermeasures. Refer to the following link for further details:
24
+ <A HREF="https://www.openssl.org/~bodo/tls-cbc.txt" TARGET="_blank">Security of CBC Ciphersuites in SSL/TLS</A>
25
+ <P>
26
+ Setting your SSL server to prioritize RC4 ciphers mitigates this vulnerability. Microsoft has posted information including workarounds for IIS at <A HREF="http://technet.microsoft.com/en-us/security/advisory/2588513" TARGET="_blank">KB2588513</A>.
27
+ <P>
28
+ Using the following SSL configuration in Apache mitigates this vulnerability:<P>
29
+ SSLHonorCipherOrder On<BR>
30
+ SSLCipherSuite RC4-SHA:HIGH:!ADH<BR>]]></SOLUTION>
31
+ <RESULT format="table"><![CDATA[Available non CBC cipher Server&apos;s choice SSL version
32
+ RC4-SHA EDH-RSA-DES-CBC3-SHA SSLv3
33
+ RC4-SHA EDH-RSA-DES-CBC3-SHA TLSv1]]></RESULT>
34
+ </VULN>
35
+ </CAT>
@@ -0,0 +1,35 @@
1
+ #[Title]#
2
+ %element.title%
3
+
4
+
5
+ #[Severity]#
6
+ %element.severity%
7
+
8
+
9
+ #[CVE]#
10
+ %element.cveid%
11
+
12
+
13
+ #[CVSS]#
14
+ Base: %element.cvss_base%
15
+ Temporal: %element.cvss_temporal%
16
+
17
+
18
+ #[Diagnosis]#
19
+ %element.diagnosis%
20
+
21
+
22
+ #[Consequence]#
23
+ %element.consequence%
24
+
25
+
26
+ #[Solution]#
27
+ %element.solution%
28
+
29
+
30
+ #[Result]#
31
+ %element.result%
32
+
33
+
34
+ #[CVEList]#
35
+ %element.cve_id_list%
@@ -0,0 +1,6 @@
1
+ evidence.cat_fqdn
2
+ evidence.cat_misc
3
+ evidence.cat_port
4
+ evidence.cat_protocol
5
+ evidence.cat_value
6
+ evidence.result
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0"?>
2
+ <CAT value="Web server" port="443" protocol="tcp">
3
+ <VULN number="42366" severity="3" cveid="CVE-2011-3389">
4
+ <TITLE><![CDATA[SSLv3.0/TLSv1.0 Protocol Weak CBC Mode Vulnerability]]></TITLE>
5
+ <LAST_UPDATE><![CDATA[2011-12-30T18:56:26Z]]></LAST_UPDATE>
6
+ <CVSS_BASE>4.3</CVSS_BASE>
7
+ <CVSS_TEMPORAL>3.5</CVSS_TEMPORAL>
8
+ <PCI_FLAG>0</PCI_FLAG>
9
+ <CVE_ID_LIST>
10
+ <CVE_ID>
11
+ <ID><![CDATA[CVE-2011-3389]]></ID>
12
+ <URL><![CDATA[http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3389]]></URL>
13
+ </CVE_ID>
14
+ </CVE_ID_LIST>
15
+ <DIAGNOSIS><![CDATA[SSLv 3.0 and TLS v1.0 protocols are used to provide integrity, authenticity and privacy to other protocols such as HTTP and LDAP. They provide these services by using encryption for privacy, x509 certificates for authenticity and one-way hash functions for integrity. To encrypt data SSL and TLS can use block ciphers, which are encryption algorithms that can encrypt only a fixed block of original data to an encrypted block of the same size. Note that these cihpers will always obtain the same resulting block for the same original blockof data. To achieve difference in the output the output of encryption is XORed with yet another block of the same size referred to as initialization vectors (IV). A special mode of operation for block ciphers known as CBC (cipher block chaining) uses one IV for the initial block and the result of the previous block for each subsequent block to obtain difference in the output of block cipher encryption.
16
+ <P>
17
+ In SSLv3.0 and TLSv1.0 implementation the choice CBC mode usage was poor because the entire traffic shares one CBC session with single set of initial IVs. The rest of the IV are as mentioned above results of the encryption of the previous blocks. The subsequent IV are available to the eavesdroppers. This allows an attacker with the capability to inject arbitrary traffic into the plain-text stream (to be encrypted by the client) to verify their guess of the plain-text preceding the injected block. If the attackers guess is correct then the output of the encryption will be the same for two blocks.
18
+ <P>For low entropy data it is possible to guess the plain-text block with relatively few number of attempts. For example for data that has 1000 possibilities the number of attempts can be 500.
19
+ <P>For more information please see <A HREF="http://eprint.iacr.org/2006/136.pdf" TARGET="_blank">a paper by Gregory V. Bard.</A>]]></DIAGNOSIS>
20
+ <CONSEQUENCE><![CDATA[Recently attacks against the web authentication cookies have been described which used this vulnerability. If the authentication cookie is guessed by the attacker then the attacker can impersonate the legitimate user on the Web site which accepts the authentication cookie.]]></CONSEQUENCE>
21
+ <SOLUTION><![CDATA[This attack was identified in 2004 and later revisions of TLS protocol which contain a fix for this. If possible, upgrade to TLSv1.1 or TLSv1.2. If upgrading to TLSv1.1 or TLSv1.2 is not possible, then disabling CBC mode ciphers will remove the vulnerability.
22
+ <P>
23
+ Openssl.org has posted information including countermeasures. Refer to the following link for further details:
24
+ <A HREF="https://www.openssl.org/~bodo/tls-cbc.txt" TARGET="_blank">Security of CBC Ciphersuites in SSL/TLS</A>
25
+ <P>
26
+ Setting your SSL server to prioritize RC4 ciphers mitigates this vulnerability. Microsoft has posted information including workarounds for IIS at <A HREF="http://technet.microsoft.com/en-us/security/advisory/2588513" TARGET="_blank">KB2588513</A>.
27
+ <P>
28
+ Using the following SSL configuration in Apache mitigates this vulnerability:<P>
29
+ SSLHonorCipherOrder On<BR>
30
+ SSLCipherSuite RC4-SHA:HIGH:!ADH<BR>]]></SOLUTION>
31
+ <RESULT format="table"><![CDATA[Available non CBC cipher Server&apos;s choice SSL version
32
+ RC4-SHA EDH-RSA-DES-CBC3-SHA SSLv3
33
+ RC4-SHA EDH-RSA-DES-CBC3-SHA TLSv1]]></RESULT>
34
+ </VULN>
35
+ </CAT>
@@ -0,0 +1,11 @@
1
+ #[Category]#
2
+ %evidence.cat_value%
3
+
4
+ #[Protocol]#
5
+ %evidence.cat_protocol%
6
+
7
+ #[Port]#
8
+ %evidence.cat_port%
9
+
10
+ #[Output]#
11
+ %evidence.result%
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dradis-qualys
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dradis-plugins
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
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.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: combustion
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.2
97
+ description: This add-on allows you to upload and parse output produced from Qualys
98
+ Vulnerability Scanner into Dradis.
99
+ email:
100
+ - etd@nomejortu.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - CONTRIBUTING.md
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - dradis-qualys.gemspec
113
+ - lib/dradis-qualys.rb
114
+ - lib/dradis/plugins/qualys.rb
115
+ - lib/dradis/plugins/qualys/engine.rb
116
+ - lib/dradis/plugins/qualys/field_processor.rb
117
+ - lib/dradis/plugins/qualys/gem_version.rb
118
+ - lib/dradis/plugins/qualys/importer.rb
119
+ - lib/dradis/plugins/qualys/version.rb
120
+ - lib/qualys/element.rb
121
+ - lib/tasks/thorfile.rb
122
+ - spec/.keep
123
+ - spec/fixtures/files/no_result.xml
124
+ - spec/fixtures/files/simple.xml
125
+ - spec/fixtures/files/two_hosts_common_issue.xml
126
+ - spec/qualys/element_spec.rb
127
+ - spec/qualys/importer_spec.rb
128
+ - spec/spec_helper.rb
129
+ - templates/element.fields
130
+ - templates/element.sample
131
+ - templates/element.template
132
+ - templates/evidence.fields
133
+ - templates/evidence.sample
134
+ - templates/evidence.template
135
+ homepage: http://dradisframework.org
136
+ licenses:
137
+ - GPL-2
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.4.5
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Qualys add-on for the Dradis Framework.
159
+ test_files:
160
+ - spec/.keep
161
+ - spec/fixtures/files/no_result.xml
162
+ - spec/fixtures/files/simple.xml
163
+ - spec/fixtures/files/two_hosts_common_issue.xml
164
+ - spec/qualys/element_spec.rb
165
+ - spec/qualys/importer_spec.rb
166
+ - spec/spec_helper.rb