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 | - | partitionName = "/dev/sda3" # <- Partition to probe EDIT THIS! |
9 | + | partitionName = "/dev/sda3" # <- Partition to probe EDIT THIS! |
10 | - | refSector = 1685403600 # <- Reference sector EDIT THIS! |
10 | + | refSector = 1685403600 # <- Reference sector absolute offset EDIT THIS! |
11 | - | startSector = 1685403601 # <- Sector to start comparison EDIT THIS! |
11 | + | startSector = 1685403601 # <- Abs. offset to start comparison EDIT THIS! |
12 | - | endSector = 2000000000 # <- Sector to end comparison EDIT THIS! |
12 | + | endSector = 2000000000 # <- Abs. offset to end comparison EDIT THIS! |
13 | ||
14 | compareSector = startSector | |
15 | ||
16 | bytesPerSector = 512 | |
17 | ||
18 | # Open the partition in binary, read only mode | |
19 | partition=open(partitionName,'rb') | |
20 | ||
21 | # Read data in refSector | |
22 | partition.seek(refSector*bytesPerSector,0) | |
23 | refData=partition.read(1*bytesPerSector) | |
24 | print("Data in reference sector is:\n\n" + refData + "\n\n") | |
25 | ||
26 | # Read data at startSector | |
27 | partition.seek(startSector*512,0) | |
28 | compareData=partition.read(1*bytesPerSector) | |
29 | ||
30 | - | print("Starting comparison with sector: " + str(startSector)) |
30 | + | print("Starting comparison with offset: " + 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 | compareSector += 1 | |
35 | compareData = partition.read(512) | |
36 | if (( compareSector % 2097152) == 0): | |
37 | print("Offset: " + str(compareSector/2097152) + " GiB, current sector: " + str(compareSector)) | |
38 | ||
39 | # Close the 'file' | |
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 | else: | |
46 | - | print("Sector " + str(compareSector) + " matches the reference sector! Yay!") |
46 | + | print("Sector with absolute offset " + str(compareSector-1) + " matches the reference sector! Yay!") |