cms_scanner 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/core.rb +4 -3
  3. data/app/views/cli/core/finished.erb +1 -0
  4. data/app/views/json/core/finished.erb +1 -0
  5. data/cms_scanner.gemspec +13 -3
  6. data/lib/cms_scanner.rb +14 -2
  7. data/lib/cms_scanner/finders/finder.rb +16 -7
  8. data/lib/cms_scanner/finders/finder/enumerator.rb +4 -28
  9. data/lib/cms_scanner/finders/finder/fingerprinter.rb +60 -0
  10. data/lib/cms_scanner/finders/finding.rb +1 -1
  11. data/lib/cms_scanner/target/scope.rb +4 -1
  12. data/lib/cms_scanner/target/server/generic.rb +1 -1
  13. data/lib/cms_scanner/typhoeus/hydra.rb +10 -0
  14. data/lib/cms_scanner/version.rb +1 -1
  15. metadata +5 -203
  16. data/.gitignore +0 -7
  17. data/.rspec +0 -2
  18. data/.rubocop.yml +0 -10
  19. data/.travis.yml +0 -17
  20. data/Gemfile +0 -6
  21. data/Rakefile +0 -9
  22. data/spec/app/controllers/core_spec.rb +0 -167
  23. data/spec/app/controllers/interesting_files_spec.rb +0 -70
  24. data/spec/app/finders/interesting_files/fantastico_fileslist_spec.rb +0 -66
  25. data/spec/app/finders/interesting_files/headers_spec.rb +0 -36
  26. data/spec/app/finders/interesting_files/robots_txt_spec.rb +0 -54
  27. data/spec/app/finders/interesting_files/search_replace_db_2_spec.rb +0 -53
  28. data/spec/app/finders/interesting_files/xml_rpc_spec.rb +0 -136
  29. data/spec/app/finders/interesting_files_spec.rb +0 -12
  30. data/spec/app/formatters/cli_no_colour_spec.rb +0 -14
  31. data/spec/app/formatters/cli_spec.rb +0 -30
  32. data/spec/app/formatters/json_spec.rb +0 -30
  33. data/spec/app/models/fantastico_fileslist_spec.rb +0 -31
  34. data/spec/app/models/headers_spec.rb +0 -51
  35. data/spec/app/models/interesting_file_spec.rb +0 -69
  36. data/spec/app/models/robots_txt_spec.rb +0 -27
  37. data/spec/app/models/version_spec.rb +0 -51
  38. data/spec/app/models/xml_rpc_spec.rb +0 -46
  39. data/spec/app/views_spec.rb +0 -35
  40. data/spec/cache/.gitignore +0 -4
  41. data/spec/dummy_finding.rb +0 -25
  42. data/spec/dummy_independent_finders.rb +0 -26
  43. data/spec/dummy_unique_finders.rb +0 -33
  44. data/spec/fixtures/finders/interesting_files/fantastico_fileslist/fantastico_fileslist.txt +0 -12
  45. data/spec/fixtures/finders/interesting_files/file.txt +0 -4
  46. data/spec/fixtures/finders/interesting_files/headers/interesting.txt +0 -16
  47. data/spec/fixtures/finders/interesting_files/headers/no_interesting.txt +0 -12
  48. data/spec/fixtures/finders/interesting_files/robots_txt/robots.txt +0 -10
  49. data/spec/fixtures/finders/interesting_files/search_replace_db_2/searchreplacedb2.php +0 -188
  50. data/spec/fixtures/finders/interesting_files/xml_rpc/homepage_in_scope_pingback.html +0 -7
  51. data/spec/fixtures/finders/interesting_files/xml_rpc/homepage_out_of_scope_pingback.html +0 -7
  52. data/spec/fixtures/finders/interesting_files/xml_rpc/xmlrpc.php +0 -1
  53. data/spec/fixtures/output.txt +0 -0
  54. data/spec/fixtures/target/comments.html +0 -29
  55. data/spec/fixtures/target/platform/php/debug_log/debug.log +0 -2
  56. data/spec/fixtures/target/platform/php/fpd/wp_rss_functions.php +0 -2
  57. data/spec/fixtures/target/scope/index.html +0 -23
  58. data/spec/fixtures/target/server/apache/directory_listing/2.2.16.html +0 -15
  59. data/spec/fixtures/target/server/generic/server/apache/basic.txt +0 -5
  60. data/spec/fixtures/target/server/generic/server/iis/basic.txt +0 -6
  61. data/spec/fixtures/target/server/generic/server/not_detected.txt +0 -3
  62. data/spec/fixtures/target/server/iis/directory_listing/no_parent.html +0 -3
  63. data/spec/fixtures/target/server/iis/directory_listing/with_parent.html +0 -3
  64. data/spec/fixtures/views/base/ctrl/local.erb +0 -1
  65. data/spec/fixtures/views/base/ctrl/test.erb +0 -3
  66. data/spec/fixtures/views/base/global.erb +0 -1
  67. data/spec/fixtures/views/base/test.erb +0 -2
  68. data/spec/fixtures/views/based_format/test.erb +0 -1
  69. data/spec/fixtures/views/json/render_me.erb +0 -4
  70. data/spec/lib/browser_spec.rb +0 -140
  71. data/spec/lib/cache/file_store_spec.rb +0 -100
  72. data/spec/lib/cache/typhoeus_spec.rb +0 -28
  73. data/spec/lib/cms_scanner_spec.rb +0 -49
  74. data/spec/lib/controller_spec.rb +0 -30
  75. data/spec/lib/controllers_spec.rb +0 -48
  76. data/spec/lib/finders/confidence_spec.rb +0 -39
  77. data/spec/lib/finders/finder/enumerator_spec.rb +0 -89
  78. data/spec/lib/finders/finder/smart_url_checker/findings_spec.rb +0 -39
  79. data/spec/lib/finders/finder/smart_url_checker_spec.rb +0 -50
  80. data/spec/lib/finders/finder_spec.rb +0 -11
  81. data/spec/lib/finders/findings_spec.rb +0 -36
  82. data/spec/lib/finders/independent_finders_spec.rb +0 -134
  83. data/spec/lib/finders/same_type_finder_spec.rb +0 -24
  84. data/spec/lib/finders/same_type_finders_spec.rb +0 -126
  85. data/spec/lib/finders/unique_finder_spec.rb +0 -24
  86. data/spec/lib/finders/unique_finders_spec.rb +0 -222
  87. data/spec/lib/formatter_spec.rb +0 -145
  88. data/spec/lib/public_suffix/domain_spec.rb +0 -49
  89. data/spec/lib/sub_scanner_spec.rb +0 -45
  90. data/spec/lib/target/hashes_spec.rb +0 -90
  91. data/spec/lib/target/platforms_spec.rb +0 -13
  92. data/spec/lib/target/scope_spec.rb +0 -103
  93. data/spec/lib/target/servers_spec.rb +0 -13
  94. data/spec/lib/target_spec.rb +0 -69
  95. data/spec/lib/vulnerability/references_spec.rb +0 -75
  96. data/spec/lib/vulnerability_spec.rb +0 -27
  97. data/spec/lib/web_site_spec.rb +0 -121
  98. data/spec/output/core/finished.cli_no_colour +0 -3
  99. data/spec/output/core/finished.json +0 -5
  100. data/spec/output/core/started.cli_no_colour +0 -3
  101. data/spec/output/core/started.json +0 -5
  102. data/spec/output/interesting_files/empty.cli_no_colour +0 -2
  103. data/spec/output/interesting_files/empty.json +0 -5
  104. data/spec/output/interesting_files/findings.cli_no_colour +0 -30
  105. data/spec/output/interesting_files/findings.json +0 -75
  106. data/spec/shared_examples.rb +0 -11
  107. data/spec/shared_examples/browser_actions.rb +0 -30
  108. data/spec/shared_examples/finding.rb +0 -54
  109. data/spec/shared_examples/formatter_buffer.rb +0 -6
  110. data/spec/shared_examples/formatter_class_methods.rb +0 -26
  111. data/spec/shared_examples/independent_finder.rb +0 -31
  112. data/spec/shared_examples/target/platform/php.rb +0 -56
  113. data/spec/shared_examples/target/server/apache.rb +0 -32
  114. data/spec/shared_examples/target/server/generic.rb +0 -33
  115. data/spec/shared_examples/target/server/iis.rb +0 -37
  116. data/spec/shared_examples/views/core.rb +0 -26
  117. data/spec/shared_examples/views/interesting_files.rb +0 -36
  118. data/spec/spec_helper.rb +0 -43
@@ -1,56 +0,0 @@
1
-
2
- shared_examples CMSScanner::Target::Platform::PHP do
3
- before { stub_request(:get, target.url(path)).to_return(body: body) }
4
-
5
- describe '#debug_log?' do
6
- let(:path) { 'd.log' }
7
-
8
- context 'when the body matches' do
9
- %w(debug.log).each do |file|
10
- context "when #{file} body" do
11
- let(:body) { File.read(File.join(fixtures, 'debug_log', file)) }
12
-
13
- it 'returns true' do
14
- expect(target.debug_log?(path)).to be true
15
- end
16
- end
17
- end
18
- end
19
-
20
- context 'when the body does not match' do
21
- let(:body) { '' }
22
-
23
- it 'returns false' do
24
- expect(target.debug_log?(path)).to be false
25
- end
26
- end
27
- end
28
-
29
- describe '#full_path_disclosure?, #full_path_disclosure_entries' do
30
- let(:path) { 'p.php' }
31
-
32
- context 'when the body matches a FPD' do
33
- {
34
- 'wp_rss_functions.php' => %w(/short-path/rss-f.php)
35
- }.each do |file, expected|
36
- context "when #{file} body" do
37
- let(:body) { File.read(File.join(fixtures, 'fpd', file)) }
38
-
39
- it 'returns the expected array' do
40
- expect(target.full_path_disclosure_entries(path)).to eql expected
41
- expect(target.full_path_disclosure?(path)).to be true
42
- end
43
- end
44
- end
45
- end
46
-
47
- context 'when no FPD' do
48
- let(:body) { '' }
49
-
50
- it 'returns an empty array' do
51
- expect(target.full_path_disclosure_entries(path)).to eq []
52
- expect(target.full_path_disclosure?(path)).to be false
53
- end
54
- end
55
- end
56
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples CMSScanner::Target::Server::Apache do
4
- describe '#server' do
5
- its(:server) { should eq :Apache }
6
- end
7
-
8
- describe '#directory_listing?, #directory_listing_entries' do
9
- before { stub_request(:get, target.url(path)).to_return(body: body, status: status) }
10
- let(:path) { 'somedir' }
11
-
12
- context 'when not a 200' do
13
- let(:status) { 404 }
14
- let(:body) { '' }
15
-
16
- it 'returns false and an empty array' do
17
- expect(target.directory_listing?(path)).to be false
18
- expect(target.directory_listing_entries(path)).to eql []
19
- end
20
- end
21
-
22
- context 'when 200' do
23
- let(:status) { 200 }
24
- let(:body) { File.read(File.join(fixtures, 'directory_listing', '2.2.16.html')) }
25
-
26
- it 'returns true and the expected array' do
27
- expect(target.directory_listing?(path)).to be true
28
- expect(target.directory_listing_entries(path)).to eq %w(backup.php database-empty.php)
29
- end
30
- end
31
- end
32
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples CMSScanner::Target::Server::Generic do
4
- describe '#server' do
5
- before { stub_request(:head, target.url).to_return(headers: parse_headers_file(fixture)) }
6
-
7
- context 'when apache headers' do
8
- %w(basic.txt).each do |file|
9
- context "when #{file} headers" do
10
- let(:fixture) { File.join(fixtures, 'server', 'apache', file) }
11
-
12
- its(:server) { should eq :Apache }
13
- end
14
- end
15
- end
16
-
17
- context 'when iis headers' do
18
- %w(basic.txt).each do |file|
19
- context "when #{file} headers" do
20
- let(:fixture) { File.join(fixtures, 'server', 'iis', file) }
21
-
22
- its(:server) { should eq :IIS }
23
- end
24
- end
25
- end
26
-
27
- context 'not detected' do
28
- let(:fixture) { File.join(fixtures, 'server', 'not_detected.txt') }
29
-
30
- its(:server) { should be nil }
31
- end
32
- end
33
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples CMSScanner::Target::Server::IIS do
4
- describe '#server' do
5
- its(:server) { should eq :IIS }
6
- end
7
-
8
- describe '#directory_listing?, #directory_listing_entries' do
9
- before { stub_request(:get, target.url(path)).to_return(body: body, status: status) }
10
- let(:path) { 'dir' }
11
-
12
- context 'when not a 200' do
13
- let(:status) { 404 }
14
- let(:body) { '' }
15
-
16
- it 'returns false and an empty array' do
17
- expect(target.directory_listing?(path)).to be false
18
- expect(target.directory_listing_entries(path)).to eql []
19
- end
20
- end
21
-
22
- context 'when 200' do
23
- let(:status) { 200 }
24
-
25
- %w(with_parent.html no_parent.html).each do |file|
26
- context "when #{file} body" do
27
- let(:body) { File.read(File.join(fixtures, 'directory_listing', file)) }
28
-
29
- it 'returns true and the expected array' do
30
- expect(target.directory_listing?(path)).to be true
31
- expect(target.directory_listing_entries(path)).to eq %w(sub-dir web.config)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,26 +0,0 @@
1
-
2
- shared_examples 'App::Views::Core' do
3
- let(:controller) { CMSScanner::Controller::Core.new }
4
- let(:start) { Time.at(1_414_670_521).in_time_zone('Europe/London') }
5
- let(:tpl_vars) { { url: target_url, start_time: start } }
6
-
7
- describe 'started' do
8
- let(:view) { 'started' }
9
-
10
- it 'outputs the expected string' do
11
- @tpl_vars = tpl_vars.merge(start_memory: 10)
12
- end
13
- end
14
-
15
- describe 'finished' do
16
- let(:view) { 'finished' }
17
-
18
- it 'outputs the expected string' do
19
- @tpl_vars = tpl_vars.merge(
20
- stop_time: Time.at(1_414_670_523).in_time_zone('Europe/London'),
21
- used_memory: 100,
22
- elapsed: 2
23
- )
24
- end
25
- end
26
- end
@@ -1,36 +0,0 @@
1
-
2
- shared_examples 'App::Views::InterestingFiles' do
3
- let(:controller) { CMSScanner::Controller::InterestingFiles.new }
4
- let(:tpl_vars) { { url: target_url } }
5
- let(:interesting_file) { CMSScanner::InterestingFile }
6
-
7
- describe 'findings' do
8
- let(:view) { 'findings' }
9
- let(:opts) { { confidence: 10, found_by: 'Spec' } }
10
-
11
- context 'when empty results' do
12
- let(:expected_view) { 'empty' }
13
-
14
- it 'outputs the expected string' do
15
- @tpl_vars = tpl_vars.merge(findings: [])
16
- end
17
- end
18
-
19
- it 'outputs the expected string' do
20
- findings = CMSScanner::Finders::Findings.new
21
-
22
- findings <<
23
- interesting_file.new('F1', opts) <<
24
- interesting_file.new('F2', opts.merge(references: %w(R1), interesting_entries: %w(IE1))) <<
25
- interesting_file.new('F2', opts.merge(found_by: 'Spec2')) <<
26
- interesting_file.new('F3',
27
- opts.merge(references: %w(R1 R2), interesting_entries: %w(IE1 IE2))) <<
28
- interesting_file.new('F3', opts.merge(found_by: 'Spec2', confidence: 100)) <<
29
- interesting_file.new('F3', opts.merge(found_by: 'Spec3')) <<
30
- interesting_file.new('F4', opts.merge(confidence: 0)) <<
31
- interesting_file.new('F4', opts.merge(confidence: 0, found_by: 'Spec2'))
32
-
33
- @tpl_vars = tpl_vars.merge(findings: findings)
34
- end
35
- end
36
- end
data/spec/spec_helper.rb DELETED
@@ -1,43 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'simplecov'
4
- require 'rspec/its'
5
- require 'webmock/rspec'
6
- require 'active_support/time'
7
-
8
- if ENV['TRAVIS']
9
- require 'coveralls'
10
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
11
- end
12
-
13
- SimpleCov.start do
14
- add_filter '/spec/'
15
- add_filter 'helper'
16
- end
17
-
18
- # See http://betterspecs.org/
19
- RSpec.configure do |config|
20
- config.expect_with :rspec do |c|
21
- c.syntax = :expect
22
- end
23
- end
24
-
25
- def count_files_in_dir(absolute_dir_path, files_pattern = '*')
26
- Dir.glob(File.join(absolute_dir_path, files_pattern)).count
27
- end
28
-
29
- # Parse a file containing raw headers and return the associated Hash
30
- # @return [ Hash ]
31
- def parse_headers_file(filepath)
32
- Typhoeus::Response::Header.new(File.read(filepath))
33
- end
34
-
35
- require 'cms_scanner'
36
- require 'shared_examples'
37
-
38
- SPECS = Pathname.new(__FILE__).dirname.to_s
39
- CACHE = File.join(SPECS, 'cache')
40
- FIXTURES = File.join(SPECS, 'fixtures')
41
- FIXTURES_VIEWS = File.join(FIXTURES, 'views')
42
- FIXTURES_FINDERS = File.join(FIXTURES, 'finders')
43
- APP_VIEWS = File.join(CMSScanner::APP_DIR, 'views')