This a type of question that depends on point of view:
At some point a damaged sector can not be read from or written to. But a hard drive is designed with the idea that bad sectors can happen at some point.
This would have consequences if there wasn't a mechanism in place to deal with such sectors: Assume the sector at LBA address turs bad, we'd all of a sudden have a hole in our sequential LBA address space. To counter this hard drives maintain a pool of spare sectors. Once the hard drive discovered the sector at LBA 100 for example has issues, it can remap LBA 100 to a spare sector and take the original sector out of commission.
So, no you will not be able to write to LBA 100, that is the original sector, however since the drive will map LBA address to a spare sector you can write to LBA 100 after all. So it will appear you can write to the sector as long as the drive has spare sectors available while you're in fact writing to a different physical sector.
There's a few conditions that will trigger the drive to deal with a bad sector:
- Error on read. The hard drive will attempt to recover the data from the sector and if it succeeds it may decide to remap the sector. If it can not the sector becomes 'pending' (you can see this in SMART - Pending). It will only remap a pending sector on write.
- Error on write. If the drive decides a sector can not be reliably used it will remap the sector (You can see this in SMART - Reallocated).
This drive has already been reallocating sectors and there's also pending sectors. Pending sectors will go away if you write to them:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/jtr0P.png)
About recovering data, or extracting as you say, data from bad sectors:
The best 'tool' to get data from bad sectors is the hard drive itself. If a drive can not read a sector it will apply all sorts of error recovery tricks without you even having to ask for it. This can take as much time as 20 seconds per sector. It's why people often complain about 'unstable' drives being slow; the drive is simply trying very hard to recover the data from a problematic sector.
Software specialized in recovery of data from such sectors can only do a few things:
- Ask the drive to try again.
- Try Long Reads (even though this feature was dropped from the ATA specification long ago). Normally if a drive can't read a sector you will not get any data, just an error. Using the Long Read command you basically tell the drive, give me any data you can read, even if you think it's wrong.
- Some times it may appear sectors can't be read due to them being bad, while it is some other issue plaguing the drive, a firmware issue for example. In such a case specialized data recovery tools, often a combination of hard and software, may be able to help read those sectors.
- Usually a data recovery tool will be used to image a drive in multiple passes, where the first pass tries to skip bad sectors as much as possible while each subsequent pass spends more time on the bad sectors. But again, often enough you'll encounter sectors that simply can not be read from.
EDIT: If this is about overwriting data and hitting a bad sector, same mechanisms apply:
If drive discovers a bad sector during the wipe it will be reallocated. Some may argue this is unsafe, or a possible attack vector since the original sector is taken out of commission and thus is not overwritten.
However recovery is unlikely:
- Access to sectors not mapped to LBA requires quite expensive tools like PC3000.
- Even then, a bad sector can not be read, that's what defines it as a bad sector. The chance that even with PC3000 the sector data can be recovered is very small.
- Original data in any sector that is successfully written to (so overwritten) is beyond recovery despite popular myth in which it is believed data can be reconstructed from vague residual traces and whatnot (this claim is bound to be made at some point in this type of threads).
If the drive supports enhanced erase then that would be your best option to securely erase all sectors, including the ones already reallocated.