pk-fr / yakpro-po

YAK Pro - Php Obfuscator
http://www.php-obfuscator.com
Other
1.24k stars 350 forks source link

Fix #72 #73

Closed CortexPE closed 4 years ago

CortexPE commented 4 years ago

This prevents the error from happening in the first place since the code block under the control statement only sets the current class name, do not set any if it is an anonymous class.

CortexPE commented 4 years ago

Before the patch:

C:\Users\ralph\PM\plugins\yakpro-po>..\..\bin\php\php.exe yakpro-po.php obf -o ext ... omitted ...
Info:   Using [C:\Users\ralph\PM\plugins\yakpro-po\yakpro-po.cnf] Config File...
Info:   yakpro-po version = 2.0.11
Info:   Process Mode            = directory
Info:   source_directory        = [C:\Users\ralph\PM\plugins\yakpro-po\obf]
Info:   target_directory        = [ext]
... omitted ...
Obfuscating C:\Users\ralph\PM\plugins\yakpro-po\obf/src/CortexPE/TeaSpoon/module/impl/PressurePlateBoundingBoxFixer.php

Fatal error: Uncaught TypeError: Argument 1 passed to MyNodeVisitor::get_identifier_name() must implement interface PhpParser\Node, null given, called in C:\Users\ralph\PM\plugins\yakpro-po\include\classes\parser_extensions\my_node_visitor.php on line 83 and defined in C:\Users\ralph\PM\plugins\yakpro-po\include\classes\parser_extensions\my_node_visitor.php:45
Stack trace:
#0 C:\Users\ralph\PM\plugins\yakpro-po\include\classes\parser_extensions\my_node_visitor.php(83): MyNodeVisitor->get_identifier_name(NULL)
#1 C:\Users\ralph\PM\plugins\yakpro-po\PHP-Parser\lib\PhpParser\NodeTraverser.php(123): MyNodeVisitor->enterNode(Object(PhpParser\Node\Stmt\Class_))
#2 C:\Users\ralph\PM\plugins\yakpro-po\PHP-Parser\lib\PhpParser\NodeTraverser.php(146): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Expr\New_))
#3 C:\Users\ralph\PM\plugins\yakpro-po\PHP-Parser\lib\PhpParser\NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Arg))
#4 C:\Users\ralph\PM\plugins\yakpro-po\PHP-Parser\lib\PhpPa in C:\Users\ralph\PM\plugins\yakpro-po\include\classes\parser_extensions\my_node_visitor.php on line 45

After this patch:

C:\Users\ralph\PM\plugins\yakpro-po>..\..\bin\php\php.exe yakpro-po.php obf -o ext2 ... omitted ...
Info:   Using [C:\Users\ralph\PM\plugins\yakpro-po\yakpro-po.cnf] Config File...
Info:   yakpro-po version = 2.0.11
Info:   Process Mode            = directory
Info:   source_directory        = [C:\Users\ralph\PM\plugins\yakpro-po\obf]
Info:   target_directory        = [ext2]
... omitted ...
Obfuscating C:\Users\ralph\PM\plugins\yakpro-po\obf/src/CortexPE/TeaSpoon/module/impl/PressurePlateBoundingBoxFixer.php
... omitted ...
Info:   [variable         ] scrambled   :      397
Info:   [function_or_class] scrambled   :        0
Info:   [method           ] scrambled   :        0
Info:   [property         ] scrambled   :        0
Info:   [class_constant   ] scrambled   :        0
Info:   [constant         ] scrambled   :        0
Info:   [label            ] scrambled   :      751

Output seems to be promising and consistent with other classes obfuscated with the same settings.

pk-fr commented 4 years ago

thanx for your report... fixed in 2.0.12