repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
overview.mdMarkdown118 lines4.5 KiBrendered raw download
---
title: "Drupal"
section: "Network Services"
sectionSlug: "network-services-pentesting"
sourcePath: "src/network-services-pentesting/pentesting-web/drupal/README.md"
sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/drupal/README.md"
sha: "188de82beb54e70956b2952367a0af91d26758b8"
isIndex: true
modified: true
license: "CC-BY-NC-4.0"
---

# Drupal

## Discovery

- Check **meta**

```bash
curl https://www.drupal.org/ | grep 'content="Drupal'
```

- **Node**: Drupal content entities of the node type represent items such as articles and pages. Canonical routes commonly use `/node/<nodeid>`, although aliases can hide that route.<sup>[[2]](#references)</sup>

```bash
curl drupal-site.com/node/1
```

## Enumeration

### Version

- Check `/CHANGELOG.txt`

```bash
curl -s http://drupal-site.local/CHANGELOG.txt | grep -m2 ""

Drupal 7.57, 2018-02-21
```

> [!TIP]
> Newer installs of Drupal by default block access to the `CHANGELOG.txt` and `README.txt` files.

### Username enumeration

Drupal installs define the following broad roles by default; permissions and any additional roles are site-configurable:<sup>[[3]](#references)</sup>

1. **`Administrator`**: This user has complete control over the Drupal website.
2. **`Authenticated User`**: These users can log in to the website and perform operations such as adding and editing articles based on their permissions.
3. **`Anonymous`**: All website visitors are designated as anonymous. By default, these users are only allowed to read posts.

**To enumerate users you can:**

- **Profile probing:** Request `/user/1`, `/user/2`, `/user/3` and compare status, body, redirects, and timing. This only enumerates users when the site exposes distinguishable responses.
- **Registry**: Access`/user/register` and try to create a username and if the name is already taken it will be indicated in an error from the server.
- **Reset password**: Try to reset the password of a user and if the user doesn't exist it will be indicated clearly in an error message.

### Hidden pages

Just find new pages by looking into **`/node/FUZZ`** where **`FUZZ`** is a number (from 1 to 1000 for example).

### Installed modules info

Exposed configuration-synchronization files may reveal enabled modules and service settings.<sup>[[5]](#references)</sup>

```bash
# Technique shared by Intigriti; see reference 5
#Get info on installed modules
curl https://example.com/config/sync/core.extension.yml
curl https://example.com/core/core.services.yml

# Download content from files exposed in the previous step
curl https://example.com/config/sync/swiftmailer.transport.yml
```

## Automatic Tools

```bash
droopescan scan drupal -u http://drupal-site.local
```

`droopescan` fingerprints CMS versions, plug-ins, and themes; validate its findings manually because content filtering and customized paths can cause false results.<sup>[[4]](#references)</sup>

## RCE

If you have access to the Drupal web console check these options to get RCE:


[Drupal Rce](/hacktricks/network-services-pentesting/pentesting-web/drupal/drupal-rce)

## From XSS to RCE

- **Drupalwned** is a Drupal exploitation script whose documented chains can elevate XSS into RCE or other critical impact.<sup>[[1]](#references)[[6]](#references)</sup> Its documented targets include Drupal 7.x through 10.x, and it supports:
  - _**Privilege Escalation:**_ Creates an administrative user in Drupal.
  - _**(RCE) Upload Template:**_ Upload custom templates backdoored to Drupal.

## Post Exploitation

### Read settings.php

```bash
find / -name settings.php -exec grep "drupal_hash_salt\|'database'\|'username'\|'password'\|'host'\|'port'\|'driver'\|'prefix'" {} \; 2>/dev/null
```

### Dump users from DB

```bash
mysql -u drupaluser --password='2r9u8hu23t532erew' -e 'use drupal; select * from users'
```

## References

- [1] [Elevating Low Vulnerabilities to Critical in CMSs and E-Commerce Platforms](https://nowak0x01.github.io/papers/76bc0832a8f682a7e0ed921627f85d1d.html)
- [2] [Drupal documentation — Concept: Content entities and fields](https://www.drupal.org/docs/user_guide/en/planning-data-types.html)
- [3] [Drupal documentation — Concept: Users, roles, and permissions](https://www.drupal.org/docs/user_guide/en/user-concept.html)
- [4] [SamJoan/droopescan](https://github.com/SamJoan/droopescan)
- [5] [Intigriti — exposed Drupal configuration synchronization files](https://twitter.com/intigriti/status/1439192489093644292)
- [6] [nowak0x01/Drupalwned](https://github.com/nowak0x01/Drupalwned)