52 lines
1.2 KiB
Bash
52 lines
1.2 KiB
Bash
python3 -c "
|
|
CHUNK = 128*512 # 64KB
|
|
LV_START = 5120000*512
|
|
|
|
with open('/dev/sda','rb') as f:
|
|
# Read full first metadata chunk
|
|
phys = LV_START + 4 * CHUNK
|
|
f.seek(phys)
|
|
data = f.read(CHUNK)
|
|
|
|
# What's in it?
|
|
import struct
|
|
|
|
# Check for recognizable patterns
|
|
print(f'First 64 bytes:')
|
|
for i in range(0, 64, 16):
|
|
print(f' {data[i:i+16].hex()} {data[i:i+16].decode(\"latin1\",errors=\"replace\")}')
|
|
|
|
# Check if it repeats
|
|
chunk_size = len(data)
|
|
period = None
|
|
for p in [8, 16, 32, 64, 128, 256, 512]:
|
|
if data[:p] * (chunk_size // p) == data[:chunk_size - chunk_size%p]:
|
|
period = p
|
|
print(f'Data repeats every {p} bytes')
|
|
break
|
|
|
|
# Check if first 8 bytes appear elsewhere in the chunk
|
|
pattern = data[:8]
|
|
count = 0
|
|
pos = 0
|
|
while True:
|
|
idx = data.find(pattern, pos)
|
|
if idx < 0: break
|
|
count += 1
|
|
pos = idx + 1
|
|
print(f'First 8 bytes appear {count} times in chunk')
|
|
|
|
# Check spacing between repetitions
|
|
positions = []
|
|
pos = 0
|
|
while True:
|
|
idx = data.find(pattern, pos)
|
|
if idx < 0: break
|
|
positions.append(idx)
|
|
pos = idx + 1
|
|
if len(positions) > 1:
|
|
gaps = [positions[i+1]-positions[i] for i in range(len(positions)-1)]
|
|
print(f'Positions: {positions[:10]}')
|
|
print(f'Gaps: {gaps[:10]}')
|
|
"
|