View difference between Paste ID: cabDM3g9 and z53uwK7d
SHOW: | | - or go back to the newest paste.
1
# This script reads a reference sector from the partition, and then starting at
2
# startSector looks for an identical sector. If one isn't found by the time it
3
# gets to lastSector it will give up.
4
#
5
# This script is really slow (though gets close to my HDD's maximum transfer
6
# rate, so at least it's efficient), if you have any idea where the copied
7
# sector might be, use that information and save yourself some time!
8
9-
refSector   = 1685403600 # <- Reference sector           EDIT THIS!
9+
partitionName = "/dev/sda3" # <- Partition to probe         EDIT THIS!
10-
startSector = 1685403601 # <- Sector to start comparison EDIT THIS!
10+
refSector      = 1685403600 # <- Reference sector           EDIT THIS!
11-
endSector   = 2000000000 # <- Sector to end comparison   EDIT THIS!
11+
startSector    = 1685403601 # <- Sector to start comparison EDIT THIS!
12
endSector      = 2000000000 # <- Sector to end comparison   EDIT THIS!
13
14
compareSector = startSector
15
16
bytesPerSector = 512
17
18-
ntfspartition=open("/dev/sda3",'rb')
18+
19
partition=open(partitionName,'rb')
20
21-
ntfspartition.seek(refSector*bytesPerSector,0)
21+
22-
refData=ntfspartition.read(1*bytesPerSector)
22+
partition.seek(refSector*bytesPerSector,0)
23-
print("Data in reference sector is:\n\n" + nData + "\n\n")
23+
refData=partition.read(1*bytesPerSector)
24
print("Data in reference sector is:\n\n" + refData + "\n\n")
25
26-
ntfspartition.seek(startSector*512,0)
26+
27-
compareData=ntfspartition.read(1*bytesPerSector)
27+
partition.seek(startSector*512,0)
28
compareData=partition.read(1*bytesPerSector)
29-
print("Starting comparison with sector " + str(startSector))
29+
30
print("Starting comparison with sector: " + str(startSector))
31
32
# Loop through until we find an identical sector or we get to endSector
33
while ((refData != compareData) and (compareSector <= endSector)):
34-
	compareData = ntfspartition.read(512)
34+
35
	compareData = partition.read(512)
36-
		print("Offset: " + str(m/2097152) + " GiB, current sector: " + str(m))
36+
37
		print("Offset: " + str(compareSector/2097152) + " GiB, current sector: " + str(compareSector))
38
39-
ntfspartition.close()
39+
40
partition.close()
41
42
# Tell the user the outcome...
43
if (compareSector == (endSector+1)):
44
	print("Couldn't find any sector matching reference sector :(.")
45-
	print("Sector " + compareSector + " matches the reference sector! Yay!")
45+
46
	print("Sector " + str(compareSector) + " matches the reference sector! Yay!")