Tag Archives: ext

Easy BASH for making data difficult to recover without damaging your filesystem.

There are a many programs designed specifically to recover lost data, even when a file has been “deleted” from a users hard-drive. This is not difficult to do because when a file is “deleted,” all that is happening is the pointer to a specific block of data is removed. The removal of this pointer is instantaneous, the removal of the data-block is not. However, once the pointer is removed the filesystem allows overwriting of the data-block. This means that files you meant to delete are still sometimes recoverable even months after they are removed from your computer. Most modern recovery programs are able to reverse this process by looking at the headers of data-blocks, and determining what type of file it resides there.

If you are paranoid about your security like I am you may ask yourself how do I prevent this from happening. One way is to utilize software that overwrites this data-block, with random patterns of data several times. Obviously the more passes the harder it is for the original data to ever be recovered. Another method, that works on a much larger scale, is to create so much write activity on the disk, that the original data will almost always be corrupted.

This script does just that, by generating a specified number of temporary files and then deleting them, overwriting the equivalent amount of data stored at that location.

[code language=”bash”]

#! /bin/bash

read -p "How much space do you want to overwrite? [MB]" space
read -p "Enter a valid directory path [example: /home/user/]: " directory
i=0
overwrites=$(($space/2))
while [ $i -lt 8500 ]; do
template+=$RANDOM
(( i = i+1 ))
done
i=0
while [ $i -lt $overwrites ]; do
clear
echo $(($i + 1))/$overwrites overwrites ~$(( 2*$i )) MB
(( i = i+1 ))
j=0
while [ $j -lt 50 ]; do
(( j = j+1 ))
echo $template >> $directory/$i-temp
done
done

i=0

while [ $i -lt $overwrites ]; do
(( i = i+1 ))
rm $directory/$i-temp
done
[/code]

Still if you want to guarantee the permanent deletion of your data, Thermite is the way to go.

~Jamin Becker

Tagged , , , , , , , , ,