pk-fr / yakpro-po

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

Bloody html #32

Closed alpha-and-omega closed 5 years ago

alpha-and-omega commented 6 years ago

Hello. I have seen this:

Note: This tool has been written in order to obfuscate pure php sources. it is not intended to be used with html and embeded php inside (you may try to deactivate statements shuffling...). You can still embed html within php using the echo <<<END ... END; syntax!

How about converting embedded html to echo << END .. END syntax before obfuscation ? PHP-Parser can help with it ?

alpha-and-omega commented 6 years ago

Embedded html can also be splitted to small chunks and shuffled by goto's much better ...

alpha-and-omega commented 6 years ago

Here is my solution to this problem:

diff --git a/include/classes/parser_extensions/my_node_visitor.php b/include/classes/parser_extensions/my_node_visitor.php
index 5ea27e8..e2206a2 100644
--- a/include/classes/parser_extensions/my_node_visitor.php
+++ b/include/classes/parser_extensions/my_node_visitor.php
@@ -93,6 +93,11 @@ class MyNodeVisitor extends PhpParser\NodeVisitorAbstract       // all parsing a

         $node_modified = false;

+        if ($node instanceof PhpParser\Node\Stmt\InlineHTML ) {
+            $node = new PhpParser\Node\Stmt\Echo_([new PhpParser\Node\Scalar\String_($node->value)]);
+            $node_modified = true;
+        }
+
         if ($node instanceof PhpParser\Node\Stmt\Class_)             $this->current_class_name = null;
         if ($node instanceof PhpParser\Node\Stmt\ClassConst)         $this->is_in_class_const_definition = false;

Please integrate it without pull request. New config option probably should be added too.

pk-fr commented 6 years ago

I think it is a good idea. I do not have time to look further now and investigate on all possible side effects. The current version is a port of the legacy one using PHP-Parser 1.0 … the new PHP-Parser 4.x has a new syntax tree that certainly offers new possibilities... I think I will have more time in september… please wait a little.

pk-fr commented 5 years ago

done... thanx