Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script reads a reference sector from the partition, and then starting at
- # startSector looks for an identical sector. If one isn't found by the time it
- # gets to lastSector it will give up.
- #
- # This script is really slow (though gets close to my HDD's maximum transfer
- # rate, so at least it's efficient), if you have any idea where the copied
- # sector might be, use that information and save yourself some time!
- partitionName = "/dev/sda3" # <- Partition to probe EDIT THIS!
- refSector = 1685403600 # <- Reference sector absolute offset EDIT THIS!
- startSector = 1685403601 # <- Abs. offset to start comparison EDIT THIS!
- endSector = 2000000000 # <- Abs. offset to end comparison EDIT THIS!
- compareSector = startSector
- bytesPerSector = 512
- # Open the partition in binary, read only mode
- partition=open(partitionName,'rb')
- # Read data in refSector
- partition.seek(refSector*bytesPerSector,0)
- refData=partition.read(1*bytesPerSector)
- print("Data in reference sector is:\n\n" + refData + "\n\n")
- # Read data at startSector
- partition.seek(startSector*512,0)
- compareData=partition.read(1*bytesPerSector)
- print("Starting comparison with offset: " + str(startSector))
- # Loop through until we find an identical sector or we get to endSector
- while ((refData != compareData) and (compareSector <= endSector)):
- compareSector += 1
- compareData = partition.read(512)
- if (( compareSector % 2097152) == 0):
- print("Offset: " + str(compareSector/2097152) + " GiB, current sector: " + str(compareSector))
- # Close the 'file'
- partition.close()
- # Tell the user the outcome...
- if (compareSector == (endSector+1)):
- print("Couldn't find any sector matching reference sector :(.")
- else:
- print("Sector with absolute offset " + str(compareSector-1) + " matches the reference sector! Yay!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement