Exploit databaseDownload repository ZIP
GH-e5e8309bda450f45464a82379d60134f
abraxas/drupal-install-takeover
Sources for CVE-2026-132165
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files7
abraxas/drupal-install-takeoverRevision ece95eaab565
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/install-site.php
PHP · 5,436 bytes<?php
/**
* Install a finished standard site, then leave install_task unfinished.
*
* The stuck task models the uncommon already-installed state from Drupal
* issues 3455853 and 3504327. install_time stays set. That is the condition
* 11.4.13 refuses and 11.4.12 resumes.
*/
declare(strict_types=1);
const LAB_ROOT = '/opt/drupal/web';
const SITE_PATH = 'sites/default';
const SQLITE_PATH = '/var/lib/lab/site.sqlite';
const DRIVER = 'Drupal\\sqlite\\Driver\\Database\\sqlite';
/**
* CLI bootstrap values so Drupal can find sites/default.
*/
function lab_cli_server(): void
{
$_SERVER['SCRIPT_FILENAME'] = LAB_ROOT . '/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['HTTP_HOST'] = '127.0.0.1';
$_SERVER['SERVER_NAME'] = '127.0.0.1';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
chdir(LAB_ROOT);
}
/**
* Non-interactive standard install into sqlite.
*/
function lab_install(object $autoloader): void
{
$settings_php = LAB_ROOT . '/' . SITE_PATH . '/settings.php';
if (!is_file($settings_php)) {
copy(LAB_ROOT . '/' . SITE_PATH . '/default.settings.php', $settings_php);
}
chmod($settings_php, 0666);
require_once LAB_ROOT . '/core/includes/install.core.inc';
install_drupal($autoloader, [
'interactive' => FALSE,
'site_path' => SITE_PATH,
'parameters' => [
'profile' => 'standard',
'langcode' => 'en',
],
'forms' => [
'install_settings_form' => [
'driver' => DRIVER,
DRIVER => [
'database' => SQLITE_PATH,
'prefix' => '',
],
],
'install_configure_form' => [
'site_name' => 'Lab',
'site_mail' => '[email protected]',
'account' => [
'name' => 'origadmin',
'mail' => '[email protected]',
'pass' => [
'pass1' => 'orig-pass-132165',
'pass2' => 'orig-pass-132165',
],
],
'date_default_timezone' => 'UTC',
'enable_update_status_module' => FALSE,
'enable_update_status_emails' => FALSE,
],
],
]);
}
/**
* Allow the loopback client to load the installed site.
*/
function lab_trust_loopback(string $settings_php): void
{
file_put_contents(
$settings_php,
"\n\$settings['trusted_host_patterns'] = ['^127\\.0\\.0\\.1\$'];\n",
FILE_APPEND
);
chmod($settings_php, 0644);
}
function lab_plant(): void
{
$autoloader = require LAB_ROOT . '/autoload.php';
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$kernel = Drupal\Core\DrupalKernel::createFromRequest($request, $autoloader, 'prod', FALSE);
$kernel->boot();
$kernel->preHandle($request);
$state = Drupal::state();
$task = $state->get('install_task');
$installed_at = $state->get('install_time');
if (!$installed_at) {
fwrite(STDERR, "install_time missing after install\n");
exit(1);
}
$account = Drupal\user\Entity\User::load(1);
if ($account === NULL || $account->getAccountName() !== 'origadmin') {
fwrite(STDERR, "uid 1 was not origadmin\n");
exit(1);
}
$state->set('install_task', 'install_install_profile');
$kernel->shutdown();
echo 'planted task=install_install_profile previous=' . $task
. ' install_time=' . $installed_at . PHP_EOL;
}
function main(): void
{
lab_cli_server();
if (($argv_mode = $GLOBALS['argv'][1] ?? '') === 'plant') {
try {
lab_plant();
} catch (Throwable $e) {
fwrite(STDERR, 'plant failed: ' . $e::class . ' ' . $e->getMessage() . PHP_EOL);
exit(1);
}
return;
}
if (!is_dir(dirname(SQLITE_PATH)) && !mkdir(dirname(SQLITE_PATH), 0775, TRUE)) {
fwrite(STDERR, "could not create sqlite directory\n");
exit(1);
}
$autoloader = require LAB_ROOT . '/autoload.php';
try {
lab_install($autoloader);
} catch (Throwable $e) {
fwrite(STDERR, 'install failed: ' . $e::class . ' ' . $e->getMessage() . PHP_EOL);
exit(1);
}
$settings_php = LAB_ROOT . '/' . SITE_PATH . '/settings.php';
lab_trust_loopback($settings_php);
chown(dirname(SQLITE_PATH), 'www-data');
chown(SQLITE_PATH, 'www-data');
chgrp(dirname(SQLITE_PATH), 'www-data');
chgrp(SQLITE_PATH, 'www-data');
chmod(dirname(SQLITE_PATH), 0775);
chmod(SQLITE_PATH, 0664);
$files = LAB_ROOT . '/' . SITE_PATH . '/files';
if (is_dir($files)) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($files, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $item) {
chown($item->getPathname(), 'www-data');
chgrp($item->getPathname(), 'www-data');
}
chown($files, 'www-data');
chgrp($files, 'www-data');
}
chown($settings_php, 'www-data');
chgrp($settings_php, 'www-data');
echo "installed sqlite=" . SQLITE_PATH . PHP_EOL;
}
main();