【发布时间】:2021-05-11 12:42:59
【问题描述】:
我有一个硬盘驱动器,它可能已经删除了上面的 SQLite db 文件。我正在读取磁盘的字节并寻找 SQLite 文件的十六进制签名:53514c69746520666f726d6174203300
我的代码告诉我这些文件在磁盘上的偏移量,但我不知道它们的大小。
例如偏移量
- 760360
- 935448
是否可以从十六进制视图确定 dbs 的大小?据我所知,这些文件没有共同的结束字符。
我的代码
from pathlib import Path
import logging
file_sig = '53514c69746520666f726d6174203300'
disk = Path('/dev/sde1') # sde is old HDD
try:
with disk.open(mode="rb") as drive:
for block_no in range(0, 488281250):
byte = drive.read(512)
hexx = byte.hex()
try:
idx = hexx.index(file_sig)
byte_nos.append(idx + block_no * 512)
except ValueError as e:
logging.debug(e)
pass
except KeyboardInterrupt:
pass
with Path('./results.csv').open(mode='w') as f:
for item in byte_nos:
f.write("%s\n" % item)
【问题讨论】:
-
您可以从页眉中提取页面大小和总页数,并计算出使用了多少块。不能保证文件是由文件系统连续存储的,尽管...
-
如果我正在查看整个硬盘驱动器的十六进制视图,标题在哪里?如果我检查 SQLite 数据库文件,则有 not much going on at the beginning of the file
-
This 是 SQLite 文件开头的十六进制示例
-
好的,我发现this 对 SQLite 数据库的前几个字节很有帮助。谢谢!
标签: python sqlite hex data-recovery