PDA

Просмотр полной версии : PHP crashes / Blue elephant down


crlf
13.12.2017, 17:35
В процессе поиска на bugs.php.net (https://bugs.php.net/) краша под свой случай, накопилось много различных реализаций. К сожаленю, я всё ещё в поисках, поэтому предлагаю постить здесь различные примеры и, по возможности, обсуждать их.

Различные кейсы могут быть полезны для возможности оставления временных файлов, развития дальнейшей атаки на интерпретатор и других хитрых штук

Потестить на различных версиях пыха можно здесь (https://3v4l.org/).

Следующие примеры тестились на LinuxсPHP 5.6.32.


PHP:




PHP:




PHP:




PHP:




PHP:
f=$foo=$d=newbad;unserialize(serialize($foo));gc_c ollect_cycles();

?>



PHP:
e=$this;$this->ob0ect=new\stdClass;}public function__destruct(){//
if(!$this->ob0ect)(0);var_dump($this);}}classSomeContainer{pu blic functionrun(){newSegfaultScenario;}}$contain er=newSomeContainer();$container->run();gc_collect_cycles();

?>



PHP:
newImage(1,1,'black');

// This works fine
$it=$im->getPixelIterator();
$row=$it->getCurrentIteratorRow();
$rgb=$row[0]->getColor();

var_dump($rgb);

// This crashes with SIGABRT
$row=$im->getPixelIterator()->getCurrentIteratorRow();
$rgb=$row[0]->getColor();

var_dump($rgb);

?>



PHP:




PHP:




PHP:




PHP:




PHP:




PHP:
0; --$len) {
$className.=$symbols[rand(0,count($symbols) -1)];
}
} while (class_exists($className,false));
$className=trim($className,'_ ');
$code='[PHP]



PHP:
data=$data;
}

public function__toString() {
openssl_pkey_export($this->data,$output);
return$output;
}

}

$csr=openssl_csr_new([],$privateKey);
$certificate=openssl_csr_sign($csr,NULL,$privateKe y,1);

$privateKey= newPrivateKey($privateKey);
openssl_pkcs12_export_to_file($certificate,'/tmp/test.p12',$privateKey,'');

?>



PHP:




PHP:
createElement('el_a');
$a->appendChild($doc1);

?>



PHP:




PHP:




PHP:
append($x);

?>



PHP:
stream);
}
}
stream_filter_register('user_filter','user_filter' );
$fd=fopen('php://memory','w');
$filter=stream_filter_append($fd,'user_filter');
fwrite($fd,"foo");

?>



PHP:

crlf
16.12.2017, 15:07
http://s018.radikal.ru/i512/1712/21/bc253850fbbb.jpg​

Ещё немного "роняний"


PHP:
"\r\n"));

$lines= [
"\r\n",
" -=()\r\n",
" -=\r\n",
"\r\n"
];

foreach ($linesas$line)
{
try
{
fwrite($fh,$line);
}
catch (\Exception $e) { }
}

fclose($fh);

?>



PHP:
5,'line-break-chars'=>"\r\n"));
rewind($data);
stream_copy_to_stream($data,$stream);

?>



PHP:
loadXML('

');
if ($dom->documentElement) {
if ($spaceNode=$dom->documentElement->getAttributeNode('xmlns')) {
$spaceNode->parentNode;
}
}

?>



PHP:
aProperty=$root;
$root=$tmp;
}

echo"Finished making objects!\n";
}

fun();
echo"Done!\n";
?>



PHP:
n0=$node;return$this;}}classLin0edList{private$d;p ublic functionaddNode(){$this->head=(newNode)->setNe0t($this->head);}}$ll=newLin0edList;for(;$iaddNode();}

?>



PHP:
self_recursive();
}
}

$obj= newABC();
$obj->self_recursive();

?>



PHP:




PHP:




PHP:




PHP:
object=$object;
$this->oarray= &$array;
$this->element=$element;
}
functionoffsetExists($index) {
echo__METHOD__."($this->element,$index)\n";
returnarray_key_exists($index,$thi s->oarray[$this->element]);
}
functionoffsetGet($index) {
echo__METHOD__."($this->element,$index)\n";
return isset($this->oarray[$this->element][$index]) ?$this->oarray[$this->element][$index] :NULL;
}
functionoffsetSet($index,$value) {
echo__METHOD__."($this->element,$index,$value)\n";
$this->oarray[$this->element][$index] =$value;
}
functionoffsetUnset($index) {
echo__METHOD__."($this->element,$index)\n";
unset($this->object[$this->element][$index]);
}
}
classPeoplesimplementsArrayAccess
{
public$person;

function__construct()
{
$this->person= array(array('name'=>'Foo'));
}
functionoffsetExists($index)
{
returnarray_key_exists($index,$thi s->person);
}
functionoffsetGet($index)
{
if (is_array($this->person[$index]))
{
return newArrayAccessRefe renceProxy($this,$this->person,$index);
}
else
{
return$this->person[$index];
}
}
functionoffsetSet($index,$value)
{
$this->person[$index] =$value;
}
functionoffsetUnset($index)
{
unset($this->person[$index]);
}
}
$people= newPeoples;
echo"===ArrayOverloading===\n";
$people= newPeoples;
unset($people[0]['name']);
var_dump($people[0]);

?>

crlf
22.12.2017, 17:53
Britney Spears said:
Gimme gimme more, gimme more, gimme gimme more [x4]




PHP:
$x='O:16:"DOMConfiguration":1:{s:1:"A";r:1;}';
var_dump(unserialize($x));




PHP:
functiontest() {
static$i=0;
if ($i===PHP_INT_MAX) {
echo$i.PHP_EOL;
return ;
}
if (!($i%256)) {
echo$i.PHP_EOL;
}
$i++;
test();
}
test();




PHP:
interfaceMyInterface{
public functiontoHtml();
}

abstract classMyAbstract{
protected function_toHtml()
{
return'';
}

final public functiontoHtml()
{
return$this->_toHtml();
}
}

classMyClassextendsMyAbstractimplementsMyInterface {
function_toHtml() {
return$this->toHtml();
}
}

$obj= newMyClass();
var_dump($obj->_toHtml());
exit;