检索文件系统的magic签名

cramfs文件头特征为 0x28cd3d45

1
2
3
❯  strings DIR645A1_FW102B08.bin|grep `python -c 'print "\x28\xcd\x3d\x45"'`
#大小端依次检索
❯ strings DIR645A1_FW102B08.bin|grep `python -c 'print "\x45\x3d\xcd\x28"'`

检索squashfs文件系统

标志的squashfs文件头大致有七种,分别为:

1
sqsh、hsqs、 qshs、 shsq、 hsqt、 tqsh、 sqlz 
1
❯ strings DIR645A1_FW102B08.bin|grep sqsh  

进一步确定是否为squashfs文件

使用hexdump判断其文件头所在的地址

1
❯ hexdump -C DIR645A1_FW102B08.bin|grep -n sqsh 

使用dd命令提取该地址为始向后的100字节,最后用file工具对提取出来的文件进行检测来确定是否为squashfs文件系统

1
❯ dd if=DIR645A1_FW102B08.bin bs=1 count=100 skip=1441936 of=squash 
if count skip of
文件名 提取大小 十进制的地址 输出文件
1
❯ file squash 

手动提取文件系统

根据上一步的file命令可以知道该文件系统的大小为 5958022字节,那么我们就可以继续使用dd命令来对其文件系统的进行完整提取

1
2
3
4
5
❯ dd if=DIR645A1_FW102B08.bin bs=1 count=5958022 skip211=1441936 of=squash_file
#然后进一步对的对文件压缩方式进行查询,可以使用file命令加参数-m
❯ file -m filesystems-hsqs squash_file
#最后确定该文件系统采用的是LZMA格式压缩的,可以使用工具unsquashfs对文件进行解压
❯ unsquashfs -f squash_file