codesake-dawn 0.72 → 0.75
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/.ruby-version +1 -1
- data/.travis.yml +8 -0
- data/Competitive_matrix.md +8 -2
- data/Rakefile +1 -0
- data/Roadmap.md +28 -22
- data/bin/dawn +42 -34
- data/codesake-dawn.gemspec +1 -0
- data/lib/codesake-dawn.rb +1 -0
- data/lib/codesake/dawn/engine.rb +31 -13
- data/lib/codesake/dawn/kb/basic_check.rb +10 -1
- data/lib/codesake/dawn/kb/combo_check.rb +63 -0
- data/lib/codesake/dawn/kb/cve_2010_1330.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_0446.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_0995.rb +63 -0
- data/lib/codesake/dawn/kb/cve_2011_2929.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2011_4815.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_3424.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2012_4522.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_5380.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_1655.rb +48 -12
- data/lib/codesake/dawn/kb/dependency_check.rb +2 -0
- data/lib/codesake/dawn/kb/operating_system_check.rb +97 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet.rb +39 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/command_injection.rb +26 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/csrf.rb +28 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/mass_assignment_in_model.rb +30 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb +37 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/session_stored_in_database.rb +28 -0
- data/lib/codesake/dawn/kb/pattern_match_check.rb +21 -3
- data/lib/codesake/dawn/kb/ruby_version_check.rb +31 -7
- data/lib/codesake/dawn/knowledge_base.rb +24 -0
- data/lib/codesake/dawn/sinatra.rb +2 -2
- data/lib/codesake/dawn/utils.rb +10 -0
- data/lib/codesake/dawn/version.rb +1 -1
- data/spec/lib/dawn/codesake_knowledgebase_spec.rb +47 -0
- data/spec/lib/dawn/codesake_sinatra_engine_spec.rb +1 -0
- data/spec/lib/kb/codesake_cve_2013_1655_spec.rb +31 -0
- data/spec/lib/kb/owasp_ror_cheatsheet_spec.rb +56 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/hello_world_3.2.13/app/helpers/application_helper.rb +8 -0
- data/spec/support/hello_world_3.2.13/app/models/test.rb +3 -0
- metadata +69 -63
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-09
|
|
5
|
+
class CVE_2010_1330
|
|
6
|
+
include RubyVersionCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message="The regular expression engine in JRuby before 1.4.1, when $KCODE is set to 'u', does not properly handle characters immediately after a UTF-8 character, which allows remote attackers to conduct cross-site scripting (XSS) attacks via a crafted string."
|
|
10
|
+
super({
|
|
11
|
+
:name=>"CVE-2010-1330",
|
|
12
|
+
:cvss=>"AV:N/AC:M/Au:N/C:N/I:P/A:N",
|
|
13
|
+
:release_date => Date.new(2012, 11, 23),
|
|
14
|
+
:cwe=>"79",
|
|
15
|
+
:owasp=>"A3",
|
|
16
|
+
:applies=>["rails", "sinatra", "padrino"],
|
|
17
|
+
:kind=>Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
|
18
|
+
:message=>message,
|
|
19
|
+
:mitigation=>"Upgrade your jruby interpreter",
|
|
20
|
+
:aux_links=>["http://www.jruby.org/2010/04/26/jruby-1-4-1-xss-vulnerability.html"]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.safe_rubies = [{:engine=>"jruby", :version=>"1.4.2", :patchlevel=>"p0"}]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-09
|
|
5
|
+
class CVE_2011_0446
|
|
6
|
+
include DependencyCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "Multiple cross-site scripting (XSS) vulnerabilities in the mail_to helper in Ruby on Rails before 2.3.11, and 3.x before 3.0.4, when javascript encoding is used, allow remote attackers to inject arbitrary web script or HTML via a crafted (1) name or (2) email value. Please note that victim must voluntarily interact with attack mechanism"
|
|
10
|
+
|
|
11
|
+
super({
|
|
12
|
+
:name=>"CVE-2011-0446",
|
|
13
|
+
:cvss=>"AV:N/AC:M/Au:N/C:N/I:P/A:N",
|
|
14
|
+
:release_date => Date.new(2011, 2, 14),
|
|
15
|
+
:cwe=>"79",
|
|
16
|
+
:owasp=>"A3",
|
|
17
|
+
:applies=>["rails"],
|
|
18
|
+
:kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
|
19
|
+
:message=>message,
|
|
20
|
+
:mitigation=>"Please upgrade rails version at least to 2.3.11 or 3.0.4 or higher. As a general rule, using the latest stable rails version is recommended.",
|
|
21
|
+
:aux_links=>["http://groups.google.com/group/rubyonrails-security/msg/365b8a23b76a6b4a?dmode=source&output=gplain"]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
self.safe_dependencies = [{:name=>"rails", :version=>['2.3.12', '3.0.5']}]
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
|
|
5
|
+
class CVE_2011_0995_a
|
|
6
|
+
|
|
7
|
+
include DependencyCheck
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
message = "CVE-2011:0995: sqlite3 gem version 1.2.4 is vulnerable"
|
|
11
|
+
|
|
12
|
+
super({
|
|
13
|
+
:name=>"CVE-2011-0995_a",
|
|
14
|
+
:kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
self.safe_dependencies = [{:name=>"sqlite3", :version=>['1.2.4']}]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class CVE_2011_0995_b
|
|
22
|
+
include OperatingSystemCheck
|
|
23
|
+
|
|
24
|
+
def initialize
|
|
25
|
+
message = "CVE-2011-0995: sqlite3 gem is vulnerable only in SuSE 11 sp1"
|
|
26
|
+
|
|
27
|
+
super({
|
|
28
|
+
:name=>"CVE-2011-0995_b",
|
|
29
|
+
:kind=>Codesake::Dawn::KnowledgeBase::OS_CHECK,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
self.safe_os = [{:family=>"linux", :vendor=>"suse", :version=>['11sp2']}]
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Automatically created with rake on 2013-07-10
|
|
38
|
+
class CVE_2011_0995
|
|
39
|
+
include ComboCheck
|
|
40
|
+
|
|
41
|
+
def initialize
|
|
42
|
+
message = "The sqlite3-ruby gem in the rubygem-sqlite3 package before 1.2.4-0.5.1 in SUSE Linux Enterprise (SLE) 11 SP1 uses weak permissions for unspecified files, which allows local users to gain privileges via unknown vectors."
|
|
43
|
+
|
|
44
|
+
super({
|
|
45
|
+
:name=>"CVE-2011-0995",
|
|
46
|
+
:cvss=>"AV:L/AC:L/Au:N/C:N/I:P/A:N",
|
|
47
|
+
:release_date => Date.new(2011, 5, 13),
|
|
48
|
+
:cwe=>"264",
|
|
49
|
+
:owasp=>"A9",
|
|
50
|
+
:applies=>["sinatra", "padrino", "rails"],
|
|
51
|
+
:kind=>Codesake::Dawn::KnowledgeBase::COMBO_CHECK,
|
|
52
|
+
:message=>message,
|
|
53
|
+
:mitigation=>"Please upgrade rails version at least to 2.3.15, 3.2.5, 3.1.5 or 3.0.13. As a general rule, using the latest stable rails version is recommended.",
|
|
54
|
+
:aux_links=>["http://support.novell.com/security/cve/CVE-2011-0995.html"],
|
|
55
|
+
:checks=>[CVE_2011_0995_a.new, CVE_2011_0995_b.new]
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-12
|
|
5
|
+
class CVE_2011_2929
|
|
6
|
+
include DependencyCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "The template selection functionality in actionpack/lib/action_view/template/resolver.rb in Ruby on Rails 3.0.x before 3.0.10 and 3.1.x before 3.1.0.rc6 does not properly handle glob characters, which allows remote attackers to render arbitrary views via a crafted URL, related to a \"filter skipping vulnerability.\""
|
|
10
|
+
super({
|
|
11
|
+
:name=>"CVE-2011-2929",
|
|
12
|
+
:cvss=>"AV:N/AC:L/Au:N/C:N/I:P/A:N",
|
|
13
|
+
:release_date => Date.new(2011, 8, 29),
|
|
14
|
+
:cwe=>"20",
|
|
15
|
+
:owasp=>"A9",
|
|
16
|
+
:applies=>["rails"],
|
|
17
|
+
:kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
|
18
|
+
:message=>message,
|
|
19
|
+
:mitigation=>"Please upgrade rails version at least to 3.1.0 or 3.0.10. As a general rule, using the latest stable rails version is recommended.",
|
|
20
|
+
:aux_links=>["https://github.com/rails/rails/commit/5f94b93279f6d0682fafb237c301302c107a9552"]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.safe_dependencies = [{:name=>"rails", :version=>['3.1.0', '3.0.10']}]
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-12
|
|
5
|
+
class CVE_2011_4815
|
|
6
|
+
include RubyVersionCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "Ruby (aka CRuby) before 1.8.7-p357 computes hash values without restricting the ability to trigger hash collisions predictably, which allows context-dependent attackers to cause a denial of service (CPU consumption) via crafted input to an application that maintains a hash table."
|
|
10
|
+
super({
|
|
11
|
+
:name=>"CVE-2011-4815",
|
|
12
|
+
:cvss=>"AV:N/AC:L/Au:N/C:N/I:N/A:C",
|
|
13
|
+
:release_date => Date.new(2011, 12, 30),
|
|
14
|
+
:cwe=>"20",
|
|
15
|
+
:owasp=>"A9",
|
|
16
|
+
:applies=>["rails", "sinatra", "padrino"],
|
|
17
|
+
:kind=>Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
|
18
|
+
:message=>message,
|
|
19
|
+
:mitigation=>"Upgrade your ruby to latest available version",
|
|
20
|
+
:aux_links=>["http://www.ruby-lang.org/en/news/2011/12/28/denial-of-service-attack-was-found-for-rubys-hash-algorithm/"]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.safe_rubies = [{:engine=>"ruby", :version=>"1.8.7", :patchlevel=>"p357"}]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-12
|
|
5
|
+
class CVE_2012_3424
|
|
6
|
+
include DependencyCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "The decode_credentials method in actionpack/lib/action_controller/metal/http_authentication.rb in Ruby on Rails 3.x before 3.0.16, 3.1.x before 3.1.7, and 3.2.x before 3.2.7 converts Digest Authentication strings to symbols, which allows remote attackers to cause a denial of service by leveraging access to an application that uses a with_http_digest helper method, as demonstrated by the authenticate_or_request_with_http_digest method."
|
|
10
|
+
|
|
11
|
+
super({
|
|
12
|
+
:name=>"CVE-2012-3424",
|
|
13
|
+
:cvss=>"AV:N/AC:L/Au:N/C:N/I:N/A:P",
|
|
14
|
+
:release_date => Date.new(2012, 8, 8),
|
|
15
|
+
:cwe=>"287",
|
|
16
|
+
:owasp=>"A9",
|
|
17
|
+
:applies=>["rails"],
|
|
18
|
+
:kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
|
19
|
+
:message=>message,
|
|
20
|
+
:mitigation=>"Please upgrade rails version at least to 3.0.16, 3.1.7 or 3.2.7. As a general rule, using the latest stable rails version is recommended.",
|
|
21
|
+
:aux_links=>["https://groups.google.com/group/rubyonrails-security/msg/244d32f2fa25147d?hl=en&dmode=source&output=gplain"]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
self.safe_dependencies = [{:name=>"rails", :version=>['3.0.16', '3.1.7', '3.2.7']}]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-15
|
|
5
|
+
class CVE_2012_4522
|
|
6
|
+
include RubyVersionCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "The rb_get_path_check function in file.c in Ruby 1.9.3 before patchlevel 286 and Ruby 2.0.0 before r37163 allows context-dependent attackers to create files in unexpected locations or with unexpected names via a NUL byte in a file path."
|
|
10
|
+
super({
|
|
11
|
+
:name=>"CVE-2012-4522",
|
|
12
|
+
:cvss=>"AV:N/AC:L/Au:N/C:N/I:P/A:N",
|
|
13
|
+
:release_date => Date.new(2012, 11, 24),
|
|
14
|
+
:cwe=>"264",
|
|
15
|
+
:owasp=>"A9",
|
|
16
|
+
:applies=>["rails", "sinatra", "padrino"],
|
|
17
|
+
:kind=>Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
|
18
|
+
:message=>message,
|
|
19
|
+
:mitigation=>"Upgrade ruby interpreter to latest 1.9.3 patchset or even better use ruby 2.x",
|
|
20
|
+
:aux_links=>["http://www.ruby-lang.org/en/news/2012/10/12/poisoned-NUL-byte-vulnerability/"]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.safe_rubies = [{:engine=>"ruby", :version=>"1.9.3", :patchlevel=>"p286"}, {:engine=>"ruby", :version=>"2.0.0", :patchlevel=>"p0"}]
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
# Automatically created with rake on 2013-07-15
|
|
5
|
+
class CVE_2012_5380
|
|
6
|
+
include RubyVersionCheck
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
message = "** DISPUTED ** Untrusted search path vulnerability in the installation functionality in Ruby 1.9.3-p194, when installed in the top-level C:\ directory, might allow local users to gain privileges via a Trojan horse DLL in the C:\Ruby193\bin directory, which may be added to the PATH system environment variable by an administrator, as demonstrated by a Trojan horse wlbsctrl.dll file used by the \"IKE and AuthIP IPsec Keying Modules\" system service in Windows Vista SP1, Windows Server 2008 SP2, Windows 7 SP1, and Windows 8 Release Preview. NOTE: CVE disputes this issue because the unsafe PATH is established only by a separate administrative action that is not a default part of the Ruby installation."
|
|
10
|
+
super({
|
|
11
|
+
:name=>"CVE-2012-5380",
|
|
12
|
+
:cvss=>"AV:L/AC:H/Au:S/C:C/I:C/A:C",
|
|
13
|
+
:release_date => Date.new(2012, 10, 11),
|
|
14
|
+
:cwe=>"426",
|
|
15
|
+
:owasp=>"A9",
|
|
16
|
+
:applies=>["rails", "sinatra", "padrino"],
|
|
17
|
+
:kind=>Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
|
18
|
+
:message=>message,
|
|
19
|
+
:mitigation=>"Upgrade ruby to the latest 1.9.3 patch or even better use ruby 2.x",
|
|
20
|
+
:aux_links=>["https://www.htbridge.com/advisory/HTB23108"]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.safe_rubies = [{:engine=>"ruby", :version=>"1.9.3", :patchlevel=>"p195"}]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
module Codesake
|
|
2
2
|
module Dawn
|
|
3
3
|
module Kb
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
class CVE_2013_1655_a
|
|
6
|
+
|
|
6
7
|
include DependencyCheck
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
message = "
|
|
9
|
+
def initialize
|
|
10
|
+
message = "CVE-2013-1655: puppet versions 2.7.21 and 3.1.1 are vulnerable"
|
|
11
|
+
|
|
12
|
+
super({
|
|
13
|
+
:name=>"CVE-2013-1655_a",
|
|
14
|
+
:kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
self.safe_dependencies = [{:name=>"puppet", :version=>['2.7.21', '3.1.1']}]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class CVE_2013_1655_b
|
|
22
|
+
|
|
23
|
+
include RubyVersionCheck
|
|
24
|
+
|
|
25
|
+
def initialize
|
|
26
|
+
message = "CVE-2013-1655: puppet versions 2.7.21 and 3.1.1 are vulnerable only when running ruby 1.9.3 and 2.0.2"
|
|
27
|
+
|
|
28
|
+
super({
|
|
29
|
+
:name=>"CVE-2013-1655_b",
|
|
30
|
+
:kind=>Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
self.safe_rubies = [
|
|
34
|
+
{:engine=>"ruby", :version=>"1.8.7", :patchlevel=>"p357"},
|
|
35
|
+
{:engine=>"ruby", :version=>"1.9.4", :patchlevel=>"p0"},
|
|
36
|
+
{:engine=>"ruby", :version=>"2.0.1", :patchlevel=>"p0"}]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class CVE_2013_1655
|
|
41
|
+
|
|
42
|
+
include ComboCheck
|
|
43
|
+
|
|
44
|
+
def initialize
|
|
45
|
+
message = "Puppet 2.7.x before 2.7.21 and 3.1.x before 3.1.1, when
|
|
46
|
+
running Ruby 1.9.3 or later, allows remote attackers to execute
|
|
47
|
+
arbitrary code via vectors related to \"serialized attributes.\""
|
|
10
48
|
|
|
11
49
|
super({
|
|
12
50
|
:name=>"CVE-2013-1655",
|
|
@@ -15,17 +53,15 @@ module Codesake
|
|
|
15
53
|
:cwe=>"20",
|
|
16
54
|
:owasp=>"A9",
|
|
17
55
|
:applies=>["rails", "sinatra", "padrino"],
|
|
18
|
-
:kind=>Codesake::Dawn::KnowledgeBase::
|
|
56
|
+
:kind=>Codesake::Dawn::KnowledgeBase::COMBO_CHECK,
|
|
19
57
|
:message=>message,
|
|
20
58
|
:mitigation=>"Please upgrade puppet gem to a newer version",
|
|
21
59
|
:aux_links=>["https://puppetlabs.com/security/cve/cve-2013-1655/"],
|
|
22
|
-
:
|
|
60
|
+
:checks=>[CVE_2013_1655_a.new, CVE_2013_1655_b.new]
|
|
23
61
|
})
|
|
24
62
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
31
67
|
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module Codesake
|
|
2
|
+
module Dawn
|
|
3
|
+
module Kb
|
|
4
|
+
module OperatingSystemCheck
|
|
5
|
+
include BasicCheck
|
|
6
|
+
|
|
7
|
+
# safe_os is an Hash with this form {:family=>"", :vendor=>"", :version=>""}
|
|
8
|
+
#
|
|
9
|
+
# family can be one of the following:
|
|
10
|
+
# "linux"
|
|
11
|
+
# "windows"
|
|
12
|
+
# "unix"
|
|
13
|
+
# "osx"
|
|
14
|
+
# "freebsd"
|
|
15
|
+
# "netbsd"
|
|
16
|
+
# "openbsd"
|
|
17
|
+
# "unknown"
|
|
18
|
+
# vendor will be either "microsoft", "apple", unix flavour or linux distribution accordingly
|
|
19
|
+
attr_accessor :safe_os
|
|
20
|
+
attr_accessor :target_os
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def initialize(options={})
|
|
24
|
+
super(options)
|
|
25
|
+
os_detect
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def vuln?
|
|
29
|
+
|
|
30
|
+
return false if different_family?
|
|
31
|
+
return false if different_vendor?
|
|
32
|
+
return vulnerable_os?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def different_family?
|
|
36
|
+
ret = false
|
|
37
|
+
@safe_os.each do |sos|
|
|
38
|
+
ret = true if ! ret and sos[:family] == @target_os[:family]
|
|
39
|
+
end
|
|
40
|
+
ret
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def different_vendor?
|
|
44
|
+
ret = false
|
|
45
|
+
@safe_os.each do |sos|
|
|
46
|
+
ret = true if ! ret and sos[:vendor] == @target_os[:vendor]
|
|
47
|
+
end
|
|
48
|
+
ret
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def vulnerable_os?
|
|
52
|
+
ret = false
|
|
53
|
+
@safe_os.each do |sos|
|
|
54
|
+
ret = true if ! ret and is_vulnerable_version?(@target_os[:family], sos[:version])
|
|
55
|
+
end
|
|
56
|
+
ret
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def os_detect
|
|
61
|
+
platform = RUBY_PLATFORM
|
|
62
|
+
|
|
63
|
+
@target_os = {}
|
|
64
|
+
|
|
65
|
+
@target_os[:family] = "osx"; @target_os[:vendor]="apple" unless /darwin/.match(platform).nil?
|
|
66
|
+
@target_os[:family] = "windows"; @target_os[:vendor]="microsoft" unless /win32/.match(platform).nil?
|
|
67
|
+
@target_os[:family] = "linux" unless /linux/.match(platform).nil?
|
|
68
|
+
@target_os[:family] = "unix"; @target_os[:vendor]="freebsd" unless /freebsd/.match(platform).nil?
|
|
69
|
+
@target_os[:family] = "unix"; @target_os[:vendor]="openbsd" unless /openbsd/.match(platform).nil?
|
|
70
|
+
@target_os[:family] = "unix"; @target_os[:vendor]="netbsd" unless /netbsd/.match(platform).nil?
|
|
71
|
+
|
|
72
|
+
begin
|
|
73
|
+
require 'sys/uname'
|
|
74
|
+
@target_os[:version]= [Sys::Uname.release]
|
|
75
|
+
rescue # otherwise use shell
|
|
76
|
+
@target_os[:version] = [`uname -r`.strip]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
tmp = ""
|
|
80
|
+
if File.exist?("/etc/SuSE-release")
|
|
81
|
+
tmp = File.readlines("/etc/SuSE-release");
|
|
82
|
+
@target_os[:vendor]="suse"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if File.exist?("/etc/redhat_release")
|
|
86
|
+
tmp = File.readlines("/etc/redhat_release");
|
|
87
|
+
@target_os[:vendor]="redhat"
|
|
88
|
+
end
|
|
89
|
+
if File.exist?("/etc/debian_release")
|
|
90
|
+
tmp = File.readlines("/etc/debian_release");
|
|
91
|
+
@target_os[:vendor]="debian"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|