Class: Yawast::Scanner::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/scanner/core.rb

Class Method Summary collapse

Class Method Details

.check_ssl(uri, options, head) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/scanner/core.rb', line 76

def self.check_ssl(uri, options, head)
  setup(uri, options)

  if uri.scheme == 'https' && !options.nossl
    head = Yawast::Shared::Http.head(uri) if head == nil

    if options.internalssl
      Yawast::Scanner::Ssl.info(uri, !options.nociphers, options.sweet32count)
    else
      Yawast::Scanner::SslLabs.info(uri, options.sslsessioncount)
    end

    Yawast::Scanner::Ssl.check_hsts(head)
  elsif uri.scheme == 'http'
    puts 'Skipping TLS checks; URL is not HTTPS'
  end
end

.get_cms(uri, options) ⇒ Object



69
70
71
72
73
74
# File 'lib/scanner/core.rb', line 69

def self.get_cms(uri, options)
  setup(uri, options)

  body = Yawast::Shared::Http.get(uri)
  Yawast::Scanner::Cms.get_generator(body)
end


4
5
6
7
8
9
# File 'lib/scanner/core.rb', line 4

def self.print_header(uri)
  Yawast.header

  puts "Scanning: #{uri.to_s}"
  puts
end

.process(uri, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/scanner/core.rb', line 22

def self.process(uri, options)
  setup(uri, options)

  begin
    #setup the proxy
    Yawast::Shared::Http.setup(options.proxy, options.cookie)

    #cache the HEAD result, so that we can minimize hits
    head = Yawast::Shared::Http.head(uri)
    Yawast::Scanner::Generic.head_info(head)

    #perfom SSL checks
    check_ssl(uri, options, head)

    #process the 'scan' stuff that goes beyond 'head'
    unless options.head
      #server specific checks
      Yawast::Scanner::Apache.check_all(uri, head)
      Yawast::Scanner::Iis.check_all(uri, head)

      Yawast::Scanner::ObjectPresence.check_source_control(uri)
      Yawast::Scanner::ObjectPresence.check_sitemap(uri)
      Yawast::Scanner::ObjectPresence.check_cross_domain(uri)
      Yawast::Scanner::ObjectPresence.check_wsftp_log(uri)
      Yawast::Scanner::ObjectPresence.check_trace_axd(uri)
      Yawast::Scanner::ObjectPresence.check_elmah_axd(uri)
      Yawast::Scanner::ObjectPresence.check_readme_html(uri)
      Yawast::Scanner::ObjectPresence.check_release_notes_txt(uri)

      Yawast::Scanner::Generic.check_propfind(uri)
      Yawast::Scanner::Generic.check_options(uri)
      Yawast::Scanner::Generic.check_trace(uri)

      #check for common directories
      if options.dir
        Yawast::Scanner::Generic.directory_search(uri, options.dirrecursive)
      end

      get_cms(uri, options)
    end

    puts 'Scan complete.'
  rescue => e
    Yawast::Utilities.puts_error "Fatal Error: Can not continue. (#{e.message})"
  end
end

.setup(uri, options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/scanner/core.rb', line 11

def self.setup(uri, options)
  unless @setup
    print_header(uri)
    Yawast.set_openssl_options

    Yawast::Scanner::Generic.server_info(uri, options)
  end

  @setup = true
end