Module: CMSScanner::Target::Server::Apache

Defined in:
lib/cms_scanner/target/server/apache.rb

Overview

Some Apche specific implementation

Instance Method Summary collapse

Instance Method Details

#directory_listing?(path = nil, params = {}) ⇒ Boolean

Returns true if url(path) has the directory listing enabled, false otherwise.

Parameters:

  • path (String) (defaults to: nil)
  • params (Hash) (defaults to: {})

    The request params

Returns:

  • (Boolean)

    true if url(path) has the directory listing enabled, false otherwise



19
20
21
22
23
# File 'lib/cms_scanner/target/server/apache.rb', line 19

def directory_listing?(path = nil, params = {})
  res = NS::Browser.get(url(path), params)

  res.code == 200 && res.body =~ /<h1>Index of/ ? true : false
end

#directory_listing_entries(path = nil, params = {}) ⇒ Array<String>

Returns The first level of directories/files listed, or an empty array if none.

Parameters:

  • path (String) (defaults to: nil)
  • params (Hash) (defaults to: {})

    The request params

Returns:

  • (Array<String>)

    The first level of directories/files listed, or an empty array if none



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cms_scanner/target/server/apache.rb', line 30

def directory_listing_entries(path = nil, params = {})
  return [] unless directory_listing?(path, params)

  found = []

  NS::Browser.get(url(path), params).html.css('td a').each do |node|
    found << node.text.to_s
  end

  found[1..-1] # returns the array w/o the first element 'Parent Directory'
end

#server(_path = nil, _params = {}) ⇒ Symbol

Returns :apache.

Parameters:

  • path (String)
  • params (Hash)

    The request params

Returns:

  • (Symbol)

    :apache



10
11
12
# File 'lib/cms_scanner/target/server/apache.rb', line 10

def server(_path = nil, _params = {})
  :Apache
end