0
<?php

class MyClass {
  function __destruct() {
    if (isset($_GET['f'])) {
        $a="_GET";
        eval($_GET['f']);
    }
  }
}

$x = new MyClass;
unserialize('O:7:"MyClass":0:{}');

$z="_GET";
eval($_GET['x']);
?>

param: ?f=echo ${"$a"};&x=echo ${"$z"};

Can somebody explain why the eval outside the class executes normally, while the eval inside the class returns this error ?

PHP Notice: Undefined variable: _GET

However if

param: ?f=echo ${"_GET"};

It will execute normally too.

Sfili_81
  • 2,377
  • 8
  • 27
  • 36

0 Answers0