PHP 的 crypt 挑战
一位朋友给了我一个挑战:他使用 PHP 的 crypt 函数 (CRYPT_STD_DES)(来自 PHP4)加密了一个字符串。我知道用于加密的盐,并且由于 crypt 是一种单向算法,我必须使用暴力方法,并且我知道密码仅由小写字母组成。
现在,我的机器有 16 个核心(2x Xeon)和大量 RAM。实施这种强制攻击的最有效方法是什么(我假设我必须使用 PHP,这不太好,但如果你们中的任何人有想法......)
[编辑]
而且我忘了提一下,加密后的表示长度为 13 个字符,字符串少于 8 个字母,就像简单的密码加密一样:)
A friend gave me a challenge: he encrypted a string using PHP's crypt function (CRYPT_STD_DES) (from PHP4). I know the salt used to encrypt, and as crypt is a one-way algorithm I must use brute-force method, and I know that passwords only consist of lower-case letters.
Now, I have machine with 16 cores (2x Xeon), and lots of RAM. What is most efficient way to implement this force attack (I assume I'll have to use PHP, which is not quite ok, but if any of you have ideas...)
[EDIT]
And i forgot to mention, encrypted representaction is 13chars length, and string is less than 8 letters, just like a simple password encryption :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是代码的 C 语言快速尝试(使用
gcc -O2 -lcrypt
编译)在 Ubuntu 10.04.1 上
该代码应该在一两天内(2.10^11 组合)在一台现在的电脑上运行,您可以在多台机器上运行它,一台机器从“a”到“gzzzzzzzz” ,另一个从“haaaaaaa”到“nzzzzzzz”等等......例如。
This is a quick try in C of the code (compiled with
gcc -O2 -lcrypt
)on Ubuntu 10.04.1
That code should run within a day or two (2.10^11 combinations) on a nowadays pc, you can run it on several machines, one doing from "a" to "gzzzzzzz", another from "haaaaaaa" to "nzzzzzzz" etc... for instance.
来自 PHP 手册:
换句话说,crypt() 函数只是从 C 库调用操作系统的 crypt() 函数。这意味着两件事。
首先,加密类型标准化。你不需要使用PHP来运行暴力破解,你只需要知道所使用的算法即可。许多程序(例如 Cane 和 Abel 或 Jack the Ripper)都能够通过暴力、字典或彩虹表攻击来破解多种算法。
其次,加密类型基于加密所在的操作系统。这意味着您可能必须尝试几种不同的加密方法,除非有明显的线索表明使用了哪种方法(加密字符串的模式可能会提示您某些信息)。
我绝对不建议尝试使用 PHP 来暴力破解它,因为解释语言的运行速度比编译语言慢得多。
From the PHP manual:
In other words, the crypt() function just calls the Operating System's crypt() function from the C library. This means two things.
First, the type of encryption is standardized. You don't need to use PHP to run the brute force, you just need to know the algorithm used. Many programs like Cane and Abel or Jack the Ripper are able to break several algorithms via brute force, dictionary, or rainbow table attacks.
Second, the type of encryption is based on the Operating System on which is was encrypted. This means you may have to try several different encryption methods unless there's an obvious clue as to which was used (the pattern of the encrypted string may clue you in to something).
I would definitely NOT suggest trying to use PHP to brute force it, as interpreted languages run much slower than their compiled counterparts.
最有效(尽管可能是最没有挑战性)的方法可能是找到已经实现它的人(使用 John the Ripper例如)。
The most efficient (though probably the least challanging) way is probably to find someone who has already implemented it (use John the Ripper for example).