如何让代码不可读?

发布于 2024-10-02 19:01:37 字数 433 浏览 7 评论 0原文

就像,我们有这个:

<?php
$titles[3] = 'three'; 
$titles[2] = 'two'; 
$titles[1] = 'one'; 
print_r( $titles); 

foreach ($titles as $t ) { 
print "title=$t "; 
}
?>

如何把它变成这样的东西?

<?php eval(gzinflate(str_rot13(base64_decode('PGRpdiBzdHlsZT0nPGRpdiBzdPGRpdiBzdHlsZT0nHlsZT0nandsoon')))); ?>

绝对不明白它是如何完成的。到底有什么魔力呢?

请描述一下。

谢谢。

Like, we have this:

<?php
$titles[3] = 'three'; 
$titles[2] = 'two'; 
$titles[1] = 'one'; 
print_r( $titles); 

foreach ($titles as $t ) { 
print "title=$t "; 
}
?>

How to turn it into something, like this?

<?php eval(gzinflate(str_rot13(base64_decode('PGRpdiBzdHlsZT0nPGRpdiBzdPGRpdiBzdHlsZT0nHlsZT0nandsoon')))); ?>

Absolutely don't understand how its done. What is the magic?

Please describe.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

┊风居住的梦幻卍 2024-10-09 19:01:37

您要查找的术语是“混淆”。如果您只是在谷歌上搜索“php obfuscators”,您会找到可以复制并粘贴代码的软件,它会为您进行混淆。

The term you are looking for is "obfuscate". If you simply do a google search for "php obfuscators", you'll find software into which you can copy and paste your code and it will obfuscate it for you.

裂开嘴轻声笑有多痛 2024-10-09 19:01:37

如何让代码不可读?这很简单:将其分配给与我一起工作的一位程序员。

How to make code unreadable? That's easy: Assign it to one of the programmers I work with here.

心碎的声音 2024-10-09 19:01:37

尝试使用混淆器:http://www.fopo.com.ar/

Try using an obfuscator: http://www.fopo.com.ar/

顾挽 2024-10-09 19:01:37

您正在寻找一些东西来混淆代码。

这是一个开源 PHP 混淆器: http://www.raizlabs.com/software/phpobfuscator/

You're looking for something to obfuscate the code.

Here's an open-source PHP obfuscater: http://www.raizlabs.com/software/phpobfuscator/

撩动你心 2024-10-09 19:01:37

好吧,只需对原文进行相反操作即可,即按照这个顺序,gzdeflate、str_rot13、base64_encode。

well, just do the reverse on the original text, i.e., in this order, gzdeflate, str_rot13, base64_encode.

勿忘初心 2024-10-09 19:01:37

做这样的事情,你是故意让你的代码需要更长的时间来执行,而不会增加任何好处。由于任何人都可以将此代码解码回原始代码,因此,如果您确实想阻止其他人阅读您的代码,那么除了发现 php 的一些功能并能够说“看,我现在是一名黑客”之外,它实际上没有

任何用处。你需要像 Zend 编码器这样的东西,这将使你的代码不可读但仍然可以作为 php 运行。

Doing something like this you are intentionally make your code take longer to execute without adding any benefits whatsoever. Since anyone can decode this code back to the original, it really serves no purpose other than just discovering some capabilities of php and being able to say "look Ma! I am a hacker now"

If you really want to prevent others from reading your code you need something like Zend encoder, which will make your code unreadable and still runnable as php.

樱桃奶球 2024-10-09 19:01:37

请查看 http://www.ideone.com/vaAXz 以了解此处发生的情况。

基本上,使用 base64_encodestr_rot13gzdeflate 将您的字符串转换为混淆的字符串,然后通过以相反的顺序运行反向函数来消除混淆(gzinflate,再次str_rot13(它所做的只是*将字符串旋转13位,因此a <-> n,b <-> o等)和 base64_decode)。然后将未混淆的代码通过eval运行,以便可以执行。

如果这就是您想要的,这并不是实现“安全”代码的特别好方法,因为通过提供对代码进行反混淆的步骤,您本质上可以让任何有权访问该代码的人代码将其转换回明文。一般来说,代码混淆器通过用 $a$b 等替换有意义的变量名称,并删除注释、空格和任何其他便利,使代码变得不可读。我们通常使用它来使代码可读。

Take a look at http://www.ideone.com/vaAXz for a demonstration of what's going on here.

Basically, use of base64_encode, str_rot13 and gzdeflate convert your string into an obfuscated string, which is then de-obfuscated by running it through the reverse functions in the reverse order (gzinflate, str_rot13 again (all it does is *rotate a string 13 places, so a <-> n, b <-> o, etc.), and base64_decode). Then the unobfuscated code is run through eval so that it can be executed.

This isn't a particularly good way of achieving "secure" code, if that's what you're going for, because by providing the steps to deobfuscate your code, you are inherently letting anyone with access to the code convert it back into plaintext. Generally, code obfuscators make your code unreadable by replacing meaningful variables names with things like $a, $b, etc., and by removing comments, whitespace, and whatever other conveniences we normally use to make code readable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文