是否有用于 PHP 的代码混淆器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/232736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:00:23  来源:igfitidea点击:

Is there a code obfuscator for PHP?

phpobfuscation

提问by user29593

Has anybody used a good obfuscator for PHP? I've tried some but they don't work for very big projects. They can't handle variables that are included in one file and used in another, for instance.

有没有人为 PHP 使用过好的混淆器?我尝试了一些,但它们不适用于非常大的项目。例如,它们无法处理包含在一个文件中并在另一个文件中使用的变量。

Or do you have any other tricks for stopping the spread of your code?

或者您还有其他阻止代码传播的技巧吗?

回答by yossi

You can try PHP protectwhich is a free PHP obfuscator to obfuscate your PHP code.
It is very nice, easy to use and also free.
EDIT: This service is not live anymore.

您可以尝试PHP 保护,它是一个免费的 PHP 混淆器来混淆您的 PHP 代码。
它非常好,易于使用且免费。
编辑:此服务不再存在。

As for what others have written here about not using obfuscation because it can be broken etc:
I have only one thing to answer them - don't lock your house door because anyone can pick your lock.
This is exactly the case, obfuscation is not meant to prevent 100% code theft. It only needs to make it a time-consuming task so it will be cheaper to pay the original coder. Hope this helps.

至于其他人在这里写的关于不使用混淆的内容,因为它可以被破坏等:
我只有一件事要回答他们 - 不要锁你的房门,因为任何人都可以撬你的锁。
情况正是如此,混淆并不意味着防止 100% 的代码被盗。它只需要使它成为一项耗时的任务,因此支付原始编码器的费用会更便宜。希望这可以帮助。

回答by Schwern

People will offer you obfuscators, but no amount of obfuscation can prevent someone from getting at your code. None. If your computer can run it, or in the case of movies and music if it can play it, the user can get at it. Even compiling it to machine code just makes the job a little more difficult. If you use an obfuscator, you are just fooling yourself. Worse, you're also disallowing your users from fixing bugs or making modifications.

人们会为您提供混淆器,但再多的混淆也无法阻止他人获取您的代码。没有任何。如果您的计算机可以运行它,或者在可以播放电影和音乐的情况下,用户就可以使用它。即使将其编译为机器代码也只会使工作变得更加困难。如果你使用混淆器,你只是在自欺欺人。更糟糕的是,您还禁止用户修复错误或进行修改。

Music and movie companies haven't quite come to terms with this yet, they still spend millions on DRM.

音乐和电影公司还没有完全接受这一点,他们仍然在 DRM 上花费数百万美元。

In interpreted languages like PHP and Perl it's trivial. Perl used to have lots of code obfuscators, then we realized you can trivially decompile them.

在像 PHP 和 Perl 这样的解释型语言中,这是微不足道的。Perl 曾经有很多代码混淆器,然后我们意识到您可以轻松地反编译它们。

perl -MO=Deparse some_program

PHP has things like DeZenderand Show My Code.

PHP 有DeZenderShow My Code 之类的东西。

My advice? Write a license and get a lawyer. The only other option is to not give out the code and instead run a hosted service.

我的建议?写许可证并请律师。唯一的其他选择是不提供代码,而是运行托管服务。

See also the perlfaq entry on the subject.

另请参阅有关该主题perlfaq 条目

回答by John

Nothing will be perfect. If you just want something to stop non-programmers then here's a little script I wrote you can use:

没有什么是完美的。如果你只是想阻止非程序员,那么这里有一个我写的小脚本,你可以使用:

<?php
$infile=$_SERVER['argv'][1];
$outfile=$_SERVER['argv'][2];
if (!$infile || !$outfile) {
    die("Usage: php {$_SERVER['argv'][0]} <input file> <output file>\n");
}
echo "Processing $infile to $outfile\n";
$data="ob_end_clean();?>";
$data.=php_strip_whitespace($infile);
// compress data
$data=gzcompress($data,9);
// encode in base64
$data=base64_encode($data);
// generate output text
$out='<?ob_start();$a=\''.$data.'\';eval(gzuncompress(base64_decode($a)));$v=ob_get_contents();ob_end_clean();?>';
// write output text
file_put_contents($outfile,$out);

回答by tomfumb

I'm not sure you can label obfuscation of an interpreted language as pointless (I'm unable to add a comment to Schwern's post, so here goes a new entry).

我不确定您是否可以将解释性语言的混淆标记为毫无意义(我无法在 Schwern 的帖子中添加评论,因此这里有一个新条目)。

I think it's a little shortsighted to assume you know all the possible scenarios where someone would like to obfuscate code, and you assume that anyone will actually be willing to go to whatever necessary lengths to view that code once obfuscated. Consider my current scenario:

我认为假设您知道有人想要混淆代码的所有可能场景,并且您假设任何人实际上都愿意不遗余力地查看混淆后的代码,这有点短视。考虑我目前的情况:

I work for a consulting company that is developing a large and fairly sophisticated PHP-based site. The project will be hosted on a client's server that is hosting other sites developed by other consultancies. Technically any code we write is owned by the client, so we can't license it. However, any other consultancy (competitor) with access to the server can copy our code without getting permission from the client first. We therefore have a genuine reason for obfuscation - to make the effort required for a competitor to understand our code more than the effort of creating a copy of our work from scratch.

我在一家咨询公司工作,该公司正在开发一个大型且相当复杂的基于 PHP 的站点。该项目将托管在托管其他咨询公司开发的其他站点的客户服务器上。从技术上讲,我们编写的任何代码都归客户所有,因此我们无法对其进行许可。但是,任何其他有权访问服务器的咨询公司(竞争对手)都可以在未经客户许可的情况下复制我们的代码。因此,我们有一个真正的混淆理由 - 使竞争对手理解我们的代码所需的努力比从头开始创建我们工作的副本的努力更多。

回答by Ira Baxter

See our SD Thicket PHP Obfuscatorfor an obfuscator that works just fine with arbitrarily large sets of pages. It operates primarily by scrambling identifier names. With modest to large applications, this can make the code extremely difficult to understand, which is the entire purpose.

请参阅我们的SD Thicket PHP Obfuscator,了解一个适用于任意大页面集的混淆器。它主要通过加扰标识符名称来操作。对于中到大型的应用程序,这会使代码极难理解,这就是全部目的。

It doesn't waste any energy on "eval(decode(encodedprogramcode))" schemes, which a lot of PHP "obfuscators" do [these are "encoder"s, not "obfuscator"s], because any clod can find that call and execute the eval-decode himself and get the decoded code.

它不会在“eval(decode( encodedprogramcode))”方案上浪费任何精力,很多 PHP“混淆器”都这样做 [这些是“编码器”,而不是“混淆器”],因为任何 clod 都可以找到那个调用并自己执行 eval-decode 并获得解码后的代码。

It uses a language-precise parser to process the PHP; it will tell you if your program is syntactically invalid. More importantly, it knows the whole language precisely; it won't get lost or confused, and it won't break your code (other that what happens if you obfuscate "incorrectly", e.g., fail to identify the public API of the code correctly).

它使用语言精确的解析器来处理 PHP;它会告诉你你的程序是否在语法上无效。更重要的是,它准确地了解整个语言;它不会迷路或混淆,也不会破坏您的代码(如果您“错误地”混淆会发生什么,例如,无法正确识别代码的公共 API)。

Yes, it obfuscates identifiers identically across pages; if it didn't do that, the result wouldn't work.

是的,它混淆了跨页面的相同标识符;如果它不这样做,结果将不起作用。

回答by CMS

The best I've seen is Zend Guard.

我见过的最好的是Zend Guard

回答by PatlaDJ

Try this one: http://www.pipsomania.com/best_php_obfuscator.do

试试这个:http: //www.pipsomania.com/best_php_obfuscator.do

Recently I wrote it in Java to obfuscate my PHP projects, because I didnt find any good and compatible ready written on the net, I decided to put it online as saas, so everyone use it free. It does not change variable names between different scripts for maximum compatibility, but is obfuscating them very good, with random logic, every instruction too. Strings... everything. I believe its much better then this buggy codeeclipse, that is by the way written in PHP and very slow :)

最近我用Java写的来混淆我的PHP项目,因为网上没有找到好的兼容的ready,所以决定把它作为saas放到网上,大家免费使用。它不会更改不同脚本之间的变量名称以获得最大的兼容性,但是很好地混淆了它们,使用随机逻辑,每条指令也是如此。弦……一切。我相信它比这个有缺陷的 codeeclipse 好得多,顺便说一下,它是用 PHP 编写的,而且速度很慢:)

回答by Praveen Kumar Purushothaman

Thicket? Obfuscator for PHP

灌木丛?PHP混淆器

The PHP Obfuscatortool scrambles PHP source code to make it very difficult to understand or reverse-engineer (example). This provides significant protection for source code intellectual property that must be hosted on a website or shipped to a customer. It is a member of SD's family of Source Code Obfuscators.

PHP混淆工具争PHP源代码,使其很难理解或反向工程(例子)。这为必须托管在网站上或运送给客户的源代码知识产权提供了重要保护。它是 SD 的源代码混淆器系列的成员。

回答by Herr

Using SourceGuardian is good as it comes with a cool and easy to use GUI.

使用 SourceGuardian 很好,因为它带有一个很酷且易于使用的 GUI。

But be aware:

但请注意:

Pay attention to its -rather funny- licensing terms.

注意其相当有趣的许可条款。

  • You are only allowed to run 1 per machine -so far this is acceptable
  • If you want to run the command line interface on another machine, say your web server, YOU WILL NEED ANOTHER LICENSE(Yes, it's funny and I can hear you laughing too).
  • 每台机器只能运行 1 个 - 到目前为止这是可以接受的
  • 如果你想在另一台机器上运行命令行界面,比如你的网络服务器,你需要另一个许可证(是的,这很有趣,我也能听到你在笑)。

回答by L??o???n???g???p??o???k???e???

Obfuscation is only adding another layer of potential bugs and security vulnerabilities to your program. Please don't do it.

混淆只是为您的程序添加了另一层潜在的错误和安全漏洞。请不要这样做。

The kind of people who write obfuscation software usually seem very sketchy and non-skilled anyway.

无论如何,编写混淆软件的那种人通常看起来非常粗略和不熟练。

If your code is "great", crackers will go through great lengths to spread it, regardless of whether or not it is obfuscated. If nobody knows/cares about your code, they probably won't, either.

如果您的代码“很棒”,无论是否被混淆,破解者都会不遗余力地传播它。如果没有人知道/关心您的代码,他们也可能不会。