Module: Msf::Exploit::Remote::HTTP::Moodle::Base

Included in:
Msf::Exploit::Remote::HTTP::Moodle
Defined in:
lib/msf/core/exploit/remote/http/moodle/base.rb

Instance Method Summary collapse

Instance Method Details

#moodle_and_online?Rex::Proto::Http::Response?

Checks if the site is online and running moodle

Returns:


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/msf/core/exploit/remote/http/moodle/base.rb', line 7

def moodle_and_online?
  unless datastore['MOODLECHECK']
    vprint_status 'Skipping Moodle check...'
    return true
  end

  moodle_detect_regexes = [
    /"moodle":{"name":"moodle",/i,
  ]

  res = send_request_cgi!({
    'method' => 'GET',
    'uri' => normalize_uri(target_uri.path)
  }, 20, 10) # a cache inconsistency may result in 7 redirects

  return res if res && res.code == 200 && res.body && moodle_detect_regexes.any? { |r| res.body =~ r }

  return nil
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
  print_error("Error connecting to #{target_uri}: #{e}")
  return nil
end