Module: Msf::Exploit::Remote::HTTP::Moodle::Login
- Included in:
- Msf::Exploit::Remote::HTTP::Moodle
- Defined in:
- lib/msf/core/exploit/remote/http/moodle/login.rb
Instance Method Summary collapse
-
#moodle_login(user, pass, timeout = 20) ⇒ HttpCookie?
performs a moodle login.
-
#moodle_loginas(course_id, user_id, session_key, timeout = 20) ⇒ HttpResponse?
performs a loginas moodle account impersonation.
Instance Method Details
#moodle_login(user, pass, timeout = 20) ⇒ HttpCookie?
performs a moodle login
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/msf/core/exploit/remote/http/moodle/login.rb', line 10 def moodle_login(user, pass, timeout = 20) res = send_request_cgi({ 'uri' => moodle_url_login, 'keep_cookies' => true }, timeout) return nil unless res res.body =~ /name="logintoken" value="([^"]+)">/ res = send_request_cgi!({ 'method' => 'POST', 'uri' => moodle_url_login, 'vars_post' => moodle_helper_login_post_data(user, pass, Regexp.last_match(1)), 'keep_cookies' => true }, timeout, 20) # typical redirect is 3-5, but it may do more if caching gets messed up on server if !res || (res.code != 200) || !res.body.include?('<title>Dashboard') return nil end = . .clear store_valid_credential(user: user, private: pass) return end |
#moodle_loginas(course_id, user_id, session_key, timeout = 20) ⇒ HttpResponse?
performs a loginas moodle account impersonation
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/msf/core/exploit/remote/http/moodle/login.rb', line 42 def moodle_loginas(course_id, user_id, session_key, timeout = 20) res = send_request_cgi({ 'uri' => moodle_url_loginas, 'vars_get' => moodle_helper_loginas_get_data(course_id, user_id, session_key), 'keep_cookies' => true }, timeout) return nil unless res # click the 'continue' button res = send_request_cgi({ 'uri' => normalize_uri(target_uri.path, 'course', 'view.php'), 'vars_get' => { 'id' => course_id }, 'keep_cookies' => true }) return nil unless res res end |