Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.

Join the forum, it's quick and easy

Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.
Evo. G Tech Team Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

如何破解Ubuntu磁盘加密和用户密码

Go down

如何破解Ubuntu磁盘加密和用户密码 Empty 如何破解Ubuntu磁盘加密和用户密码

Post by khorcheeguan August 29th 2015, 14:55

[You must be registered and logged in to see this link.]上,我快速展示了[You must be registered and logged in to see this link.]和密码破解的过程。我在使用了Ubuntu的加密home目录功能后萌生了解密的想法,加密目录的功能可以在安装Ubuntu的时候开启,也可以之后再开启。
[You must be registered and logged in to see this image.]

如果你打开了上图中的这一选项,对用户来说其实变化不大,就是home目录被加密了。我对其中的原理很感兴趣,因为Ubuntu从没问我要过解密密钥。我发现eCryptfs这个工具是在GNU/Linux内核中的,而[You must be registered and logged in to see this link.]就是被Ubuntu用来加密home目录的。
加密过程

在阅读了代码之后,基本了解了加密的过程。首先Ubuntu会生成一个16字节的随机密码(passphrase)。Ubuntu会用这个密码和AES-128对文件夹中的数据进行加密解密。
/home/.ecrpytfs/$USER/.ecrpytfs/wrapped-passphrase

对密码进行加密的过程叫做密码包装(key wrapping)。要进行密码包装,Ubuntu会用一个8字节的salt和密码结合,然后用SHA-512计算哈希值,这一过程会反复65535次,如下图:

[You must be registered and logged in to see this image.]
结果中最前面的16字节是包装密码(wrapping key)。中间的结果会再一次经过SHA-512哈希计算,然后计算后的结果中,最前面的8字节就是包装密码的签名。前面提到的那个16字节密码(passphrase)就会被用包装密码和AES-128进行加密,加密后的结果和包装密码的签名会被放在wrapped-passphrase文件中,如下图:
[You must be registered and logged in to see this image.]

而解开包装密码的过程也很类似,salt和密码会被哈希65536次。

[You must be registered and logged in to see this image.]
得到的结果会再被计算一遍哈希,如果最前面的8字节与wrapped-passphrase文件中的签名一致,eCryptfs就会认为是生成了正确的包装密码。它就会用它解密那个16字节的密码(passphrase)。
破解密码

要想获取密码(passphrase),幼稚点的想法就会是用加密的数据暴力破解密码。但是由于这是随机生成的16字节字符,这种方法显然不实际。再或者我们也会想到暴力破解包装密码时用到的那个密码,然后生成包装密码,从而获取passphrase。攻击者可能会用事先准备好的字典或者是[You must be registered and logged in to see this link.],然而在密码包装的过程中我们用到了[You must be registered and logged in to see this link.],这就使得破解的难度上升。
然后我注意到,在Ubuntu系统中,密码包装时用到的密码就是登陆密码。这就解释了为什么Ubuntu在解密Home目录时没有让我们再提供别的密码。接下来我就研究了salt是如何生成的,因为salt没有储存在wrapped-passphrase文件中。最后通过查看代码我发现,ecryptfs-utils是在配置文件中寻找salt的
$HOME/.ecryptfsrc
如果这个文件不存在,就会使用默认值0×0011223344556677。
对于使用eCryptfs的系统,配置文件会被存储在home目录,而现在这个目录被加密了,文件也就找不到了,因此,凡是使用了这一版本eCryptfs的系统,程序都会使用默认的salt值来加密home目录。
[You must be registered and logged in to see this image.]
因此很明显,我们可以用字典或者彩虹表暴力破解获取用户密码。我们可以用[You must be registered and logged in to see this link.]进行破解,而在其1.8.0-jumbo版本中其实已经有相应的算法了:
$ecryptfs$0$1$0011223344556677$21ff10301b5457e1
0011223344556677:salt
21ff10301b5457e1:要攻击的密码的签名
我还找到一个python脚本[You must be registered and logged in to see this link.],它会直接读取wrapped-passphrase文件,将其转化为正确的格式。这个算法在[You must be registered and logged in to see this link.]里面也有。我对[You must be registered and logged in to see this link.]中的每一个密码计算签名,用我的个人电脑计算,大约花了我一个月,如果密码在rock you字典里的话,现在我们就可以非常容易地破解了。
我生成的字典:[You must be registered and logged in to see this link.]
修复

当然我们就此问题通知了ecryptfs-utils开发者,后者也对此进行了修复,他们给wrapped-passphrase使用了一个新的文件格式,现在文件会以0x3a02开头。Salt会从/etc/urandom/生成,并且默认也存储在这个位置。更新并注销后,老版本的文件会自动转换,新版文件内容如下图:

[You must be registered and logged in to see this image.]
转载来自Freebuf黑客与极客(FreeBuf.COM)

khorcheeguan
Sponsor
Sponsor

Posts : 51
Points : 70397
Reputation : 0
Join date : 2014-09-14
Age : 23

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum