Guest User

Untitled

a guest
Oct 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. class Foo
  3. {
  4.         private $bar = "boo";
  5.         private $baz = "buz";
  6. }
  7.  
  8. $foo = new Foo();
  9. $tmp = serialize($foo);
  10. $nul = preg_quote(chr(0));
  11. $reg = "/s\:([0-9]+)\:\"$nul(.*?)$nul/";
  12. preg_match_all($reg, $tmp, $matches);
  13. foreach ($matches[0] as $i => $match) {
  14.         $class = $matches[2][$i];
  15.         $clen = strlen($class);
  16.         $len = intval($matches[1][$i]) - ($clen + 2);
  17.         $tmp = str_replace($match, "s:$len:\"", $tmp);
  18.         $tmp = str_replace("O:$clen:\"$class\"", "O:8:\"stdClass\"", $tmp);
  19. }
  20. $tmp = unserialize($tmp);
  21. echo $tmp->bar;
  22. echo "\n";
  23. die;
Add Comment
Please, Sign In to add comment