Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于“室友的加密硬盘”官方题解中提到的非预期解 #52

Open
chuangzhu opened this issue Feb 2, 2021 · 0 comments
Open
Labels

Comments

@chuangzhu
Copy link
Contributor

不知是因为 LUKS 分区打开的时候本该如此,还是出题人操作不慎在分区创建的时候密码复制到了剪贴板上,密码本身明文在 swap 中出现了,所以 strings 一下然后逐个字符串尝试就可以求解。但感觉其实这样做出来也算是正常解法了。密码是什么留作练习。

一时兴起想试着通过这种方式解一下,首先将 swap 分区单独拿出来:

dd if=roommates_disk_part.img of=swap.img bs=512 count=1497088 skip=393216  

然后用 GCC binutils 中的 strings 工具将文件中的字符串提取出来:

strings swap.img > swap.strings

一眼看过去挺多重复的,用 uniq 去一下重:

sort swap.strings | uniq > swap.strings.uniq

这样就得到了一个词典,使用 Hashcat 的 LUKS 模式破解:

hashcat -a 0 -m 14600 chome.img swap.strings.uniq -o hashcat-recovered2 --force

在旧机子上跑了一整天,破解出来了一个密码(Recovered...1/2,因为事先按照官方题解添加了一个密码 1 所以显示有两个)

[s]tatus [p]ause [b]ypass [c]heckpoint [q]uit => s

Session..........: hashcat
Status...........: Running
Hash.Name........: LUKS
Hash.Target......: chome.img
Time.Started.....: Mon Feb  1 16:43:05 2021, (1 day, 2 hours)
Time.Estimated...: Wed Feb  3 07:46:31 2021, (12 hours, 27 mins)
Guess.Base.......: File (swap.strings.uniq)
Guess.Queue......: 1/1 (100.00%)
Speed.#1.........:       11 H/s (6.58ms) @ Accel:4 Loops:128 Thr:8 Vec:1
Recovered........: 1/2 (50.00%) Digests, 1/2 (50.00%) Salts
Progress.........: 1140480/2129440 (53.56%)
Rejected.........: 0/1140480 (0.00%)
Restore.Point....: 569856/1064720 (53.52%)
Restore.Sub.#1...: Salt:1 Amplifier:0-1 Iteration:503296-503424
Candidates.#1....: K-|g.} ->         ki
$ cat hashcat-recovered
chome.img:h189-~asfnb.asdfjp2i3

看起来 h189-~asfnb.asdfjp2i3 就是密码了,试着用这个密码解密分区,成功。

$ dd if=roommates_disk_part.img of=chome.img bs=512 count=1998848 skip=1892352
$ sudo cryptsetup luksOpen chome.img chome                              
Enter passphrase for chome.img: h189-~asfnb.asdfjp2i3
$ sudo mount /dev/mapper/chome /mnt       
$ cat /mnt/petergu/flag.txt 
flag{lets_do_A_c01d_b00t_next_time}

一些细节:虽然我的机子是 i915 集成显卡,但用使用了 GPU 计算的 Hashcat 仍然比使用多线程 CPU 运算的 bruceforce-luks 要快 20 倍左右。

@taoky taoky added the solution label Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants