Secure Deletion

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

User avatar
Vendetta
Emperor's Hand
Posts: 10895
Joined: 2002-07-07 04:57pm
Location: Sheffield, UK

Post by Vendetta »

There's another great way to render CDs completely useless.

1. balance the centre of the CD on something, so the sides hang over.
2. pour lighter fluid on the CD.
3. Ignite.

The CD will soften and melt, the edges will sag downwards, and you will have an attractive little shiny pot type thing..
User avatar
Durandal
Bile-Driven Hate Machine
Posts: 17927
Joined: 2002-07-03 06:26pm
Location: Silicon Valley, CA
Contact:

Re: Secure Deletion

Post by Durandal »

Admiral Valdemar wrote:I'm looking for a secure way of deleting files totally on Ubuntu 5.10 Breezy Badger, but so far I see that using any journaling filesystem means secure deletion isn't guaranteed (I'm using Ext3 as default).

In that case, is it best to encrypt files tagged for deletion before sending them to the waste bin? Assuming someone wanted to get at my old password keys or financial documents etc., they'd have to not only recover the file from deletion, but crack a 4 kilobyte cipher. Would that do it?

Code: Select all

/*
 *  secure_delete.c
 *  
 *
 *  Created by Damien Sorresso on 4/26/06.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>

int main(int argc, char *argv[]) 
{
	if( argc != 2 ) {
		printf("Usage: %s <file to delete>\n", argv[0]);
		return 0;
	}
	
	FILE *file = fopen(argv[1], "rb+");
	
	if( !file ) {
		printf("Could not open file %s. Exiting.\n", argv[1]);
	}
	
	struct stat buff;
	stat(argv[1], &buff);
	
	long size = buff.st_size;
	
	int byte = 1;
	long i = 0;
	srand(time(0));
	
	while( i < size ) {
		fputc(byte << (rand() % 32), file);
		fseek(file, i, SEEK_SET);
		i++;
	}
	
	fclose(file);
	
	return 0;
}
This will simply write over the file, byte-by-byte, with a randomly-shifted binary number. Then you just delete it. It should compile just fine under Linux.
Damien Sorresso

"Ever see what them computa bitchez do to numbas? It ain't natural. Numbas ain't supposed to be code, they supposed to quantify shit."
- The Onion
User avatar
Admiral Valdemar
Outside Context Problem
Posts: 31572
Joined: 2002-07-04 07:17pm
Location: UK

Post by Admiral Valdemar »

My hero!
Post Reply