There is a class encrypted ioncube (let's call class A). When using it, this class was inherited (class B), overriding the public method. The source data has now changed, and you need to change the private property of class A. To change the private property of an object, it found https://3v4l.org/nCMor (description https://habrahabr.ru/post/186718/ ), but how to get to private property of the parent class? If I use class A directly, the property is updated without problems (using the method above), but how to overload the required method in the created instance? I watched the reflection, but did not understand how to do it. Example:

<?php class A { //зашифрованный private $field = array('field1', 'field2'); public function getNameTable(){ return 'Table1'; } /*...... разные методы ......*/ } class B extends A{ public function getNameTable(){ return 'Table2'; } } 

It is necessary to add another 1 'field3' element to the $ field array, but the table 'Table2' should be used.

P.S. I contacted the developer of class A, he said that he no longer does this, and he no longer has the source code.

  • That is, besides the field value, do you need to change the method in the base class itself ? - Maxim Timakov
  • one
    @Alex, decipher the class and change what your heart desires in it. - Visman
  • @Visman, and which program is better to do this? (decoding) I did the IonCube v8.3 Decoder, but most of the variable names were shown abrakatabroy .... the rest is normal. I tried to select the encoding - did not work .... - Alex

1 answer 1

Example with Reflection for modifying the private field of the parent class

 <?php class A { private $data = array('one', 'two'); public function __construct() { } } class B extends A { public function __construct($value) { parent::__construct(); $this->patchWithReflect($this, 'data', $value); } public function patchWithReflect($object, $name, $value) { // Получаем информацию о родительском классе $reflect = new ReflectionClass(get_parent_class($object)); // Получаем доступ к свойству $data = $reflect->getProperty($name); $data->setAccessible(true); // Получаем старое значение $dataA = $data->getValue($object); // Устанавливаем новое $dataA[] = $value; $data->setValue($object, $dataA); } } $bz = new B('z'); $bx = new B('x'); var_dump($bx); var_dump($bz); 

result on ideone