HackThisSite - Forensic Mission 1
Challenge
From: stacy.melroy@tritech.org
Thank you for agreeing to help me. We recently had a problem with a former employee and though I cannot prove it, I believe he is the one that erased the files off my thumbdrive. I did some research and I made an image of the drive for you but that is as far as I got. I can replace most of what was lost but there is one file in particular that holds a very important account password. If you could recover that file, I would be extremely grateful.
Also, this is my personal thumbdrive. Keep that in mind please. I'm not sure what you might recover, but I would rather it not get spread around.
委托人(
stacy.melroy@tritech.org)说自己的 U 盘被一名已离职的员工清空,附件image.tar.gz是整盘镜像,要求把其中保存账号密码的那个文件恢复出来。附件自带 md5 校验值4e7af965caed9b8d29c40f549fdb7d28。
Solution
Step 1: 固定镜像与文件系统
1 | $ md5sum image.tar.gz |
file 和 fsstat 都直接把它识别成 NTFS
卷,没有分区表,mmls 无输出,也就是说 image.dd
本身就是卷设备,取证工具按裸卷解析即可:
1 | $ fsstat image.dd |
卷标 stacy 和委托人对得上,确认这就是目标 U 盘。
Step 2: 列出被删除的 inode
fls -r -d 递归列出被标记为删除的目录项,-p
输出完整路径:
1 | $ fls -r -d -p image.dd |
几个观察:
- 所有被删内容都在
.Trash-1000(Linux 桌面环境的回收站目录)里,Current.trashinfo记录了删除时间2014-01-05T01:11:31,路径是Current,这是整个目录被一次性移入回收站再清空的痕迹。 inode-attrtype-attrid三元组里,r/r * 85-128-2表示该名字在$MFT里仍有FILE_NAME属性残留(128=0x80,即默认$DATA流所在的属性记录),可以按 inode 直接icat;r/- * 0那几条(Voicemail 1.wav、XuN4Olv.jpg、Zr5FTg3.jpg)只剩索引项,inode 已被清零,同名文件在别处还有一条带真实 inode 的记录,对应关系靠文件名匹配。- 和题面相关的四个文件:
Termination - Allen Smith.docx(85)、private/Your new password is.rar(86)、logins.txt(83)、Voicemail 1.wav(81)。
Step 3: 按 inode 恢复文件
1 | $ mkdir -p recovered |
删除只清了 $MFT 里的分配位和索引项,数据运行(data
runs)指向的簇没有被复用,所以 icat
出来仍然是完好文件。被删名字还带着 NTFS
备用数据流,Voicemail 1.wav 的 Zone.Identifier
里是 ZoneId=3,说明这批文件是从网上下载后拷进来的:
1 | $ icat image.dd 81-128-4 |
先看那个名字最直白的凭证文件:
1 | $ cat recovered/logins.txt |
Step 4: 从辞退信找解压密码
Termination.docx 是一封辞退通知,落款人正是委托人 Stacy
Melroy,正文里留着她的联系电话。docx 是 zip 容器,正文在
word/document.xml,剥掉 XML 标签就能看:
1 | $ unzip -p recovered/Termination.docx word/document.xml | sed -e 's/<\/w:p>/\n/g' -e 's/<[^>]*>//g' | grep -n . |
519-555-4783 就是后来用来加密压缩包的号码。
Step 5: 电话号码解开 RAR
1 | $ 7z x -p5195554783 -orecovered 'recovered/Your new password is.rar' |
压缩包内是一个同名的
docx,正文一句话就是任务密码(& 是 XML 转义的
&)。
另外恢复出来的 Voicemail 1.wav 是一段 8.54 秒的 16
bit/44.1 kHz 单声道 PCM 录音(753710
字节),属于同一个事件背景,不参与上面的解压链路。
Step 6: Submit
1 | $ curl -s -b "$HTS_COOKIE" -H 'Referer: https://www.hackthissite.org/missions/forensic/1/' \ |
Step 7: Script
把上面每一步串起来,从镜像直接跑到任务密码:
1 | #!/usr/bin/env python3 |
运行结果:
1 | $ cd <hts-workspace> && uv run python challenges/hts-forensic/1/solve.py |
状态:verified(live 通关并已计入 profile)。
Vulnerabilities
NTFS 的删除只做两件事:把 $MFT
记录标成未分配、撤掉父目录索引项,文件内容所在的簇原地不动,直到被新数据覆盖。fls
+ icat 之所以能整盘还原,就是因为字节还在,元数据也还留着
inode、时间戳和备用数据流。这盘镜像里同时残留两处删除痕迹:一张写着登录邮箱和明文口令的
logins.txt,和一个只用一个电话号码当口令的压缩包,而那个号码印在另一封同样被删除的辞退信签名栏里。也就是说,把文件移入回收站再清空,对取证者而言等同于没有删除;真正需要保密的内容必须用整盘加密或可信的擦除工具处理,否则删除动作本身只是把线索排好队。口令复用把这两处痕迹连成一条链:同一个
5195554783
既出现在文档里又当压缩包密码,攻击者只要恢复出任何一个文件就能顺着链条把所有东西打开。