home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 7 A / CHIP_HITWARE_7A.iso / Tools / FileKiller / kill.pl < prev    next >
Text File  |  2000-01-16  |  12KB  |  383 lines

  1. ##############################################################################
  2. #
  3. #    File Killer by Jens Luedicke <morpheus@irs-net.com>
  4. #    Copyright (C) 1999/2000  <Jens Luedicke>
  5. #    "Fisher Yates Shuffle" by Perl Core FAQ
  6. #
  7. #    Web: http://www.irs-net.com/
  8. #    Public-PGP-Keys: pgp-keys@irs-net.com <AUTORESPONDER>
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # any later version.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
  18. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
  19. # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
  20. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
  21. # OTHER DEALINGS IN THE SOFTWARE. 
  22. #
  23. ##############################################################################
  24.  
  25. $version = "v 0.0.8 dev";
  26. $year = "2000";
  27.  
  28. ############## Messages to be displayed:
  29.  
  30. $message_code1 = "Error: File isn't readable or doesn't exist!\n";
  31. $message_code2 = "Error: Your Recycle Bin is empty!\n";
  32. $message_code3 = "Error: Can't find any $ARGV[0] - Files!\n";
  33. $message_code4 = "Error: Can't find any files on floppy! Empty?\n";
  34. $message_code5 = "Please insert floppy into drive A:\n";
  35. $message_code6 = "Press <ENTER>";
  36. $message_code7 = "Aborting...\n";
  37. $message_code8 = "Starting the overwriting sequence...\n";
  38. $message_code9 = "Deleting...";
  39. $message_code10 = "Floppy overwritten!\n";
  40. $message_code11 = "Overwriting...";
  41. $message_code12 = "YOUR LAST CHANCE!! Continue?? (\[y\]es or \[n\]o) ";
  42. $message_code13 = "Couldn't change to drive A:";
  43.  
  44. ############## Script starts here:
  45. use File::DosGlob 'glob';
  46. srand(time());
  47.  
  48. if ($ARGV[0] eq "") {
  49. system("cls");
  50. &header("$version", "$year");
  51. print <<PROGRAM_INFO;
  52.  
  53. Usage: kill [files] [-y]
  54.             [-trash] [-y]
  55.             [-floppy] [-y]
  56.  
  57. files:   filename.xxx: deletes/wipes a single file
  58.          *.xxx:        deletes/wipes files with the given extension
  59.          *.*:          deletes/wipes all files in the current directory
  60. -trash:  Erases all files in the Win9X-Recycle Bin
  61. -floppy: Erases all files on a floppy in drive A: and
  62.          overwrites the floppy with 1,38 MB (1457664 bytes) of zeros
  63. -y:      Disables confirmation question
  64.  
  65. PROGRAM_INFO
  66. exit;
  67.  
  68. } elsif ($ARGV[0] eq "-c") {
  69.     &smallheader("$version", "$year");
  70.     ©right;
  71.     exit;
  72.  
  73. } elsif ($ARGV[0] eq "-w") {
  74.     &smallheader("$version", "$year");
  75.     &warranty;
  76.     exit;
  77.  
  78. } elsif ($ARGV[0] eq "*.*") {
  79.         &smallheader("$version", "$year");
  80.         &filelist("$message_code3", "$message_code7");
  81.         &command_line_arguments("$message_code7", "$message_code12");
  82.  
  83.         foreach $file (@flist) { &firststep("$file", "$message_code11"); }
  84.  
  85. } elsif ($ARGV[0] =~ /[\*\.]/) {
  86.         &smallheader("$version", "$year");
  87.         &file_list_2("$message_code3", "$message_code7");
  88.         &command_line_arguments("$message_code7", "$message_code12");
  89.  
  90.         foreach $file (@flist) { &firststep("$file", "$message_code11"); }
  91.  
  92. } elsif ($ARGV[0] eq "-trash") {
  93.     
  94.         &smallheader("$version", "$year");
  95.                 &command_line_arguments("$message_code7", "$message_code12");
  96.  
  97.         chdir("\\RECYCLED");
  98.  
  99.                 $INFO = glob "INFO";
  100.                 if (-w $INFO && -r $INFO) { } else
  101.                 {
  102.                         print "$message_code2";
  103.                         print "$message_code7";
  104.                         exit;
  105.                 }
  106.  
  107.         system("attrib", "-a -h desktop.ini");
  108.         rename("desktop.ini", "fk-trash.dat");
  109.  
  110.         &trashlist;
  111.  
  112.                 foreach $file (@flist) { &firststep("$file", "$message_code11"); }
  113.  
  114.                 $file = "INFO";
  115.                 &firststep("$file"); 
  116.  
  117.         rename("fk-trash.dat", "desktop.ini");
  118.         system("attrib", "+a +h desktop.ini");
  119.  
  120.         exit;        
  121.  
  122. } elsif($ARGV[0] eq "-floppy") {
  123.  
  124.         &smallheader("$version", "$year");
  125.         &command_line_arguments("$message_code7", "$message_code12");
  126.  
  127.                 print "\n";
  128.                 print "$message_code5";
  129.                 print "$message_code6";
  130.                 <STDIN>;
  131.                 print "\n";
  132.  
  133.         die("$message_code13") unless chdir("A:\\");
  134.  
  135.         &floppyfiles("$message_code4", "$message_code7");
  136.  
  137.         foreach $file (@floppyfiles)
  138.         {
  139.                 open(KILLFILE, ">$file");
  140.                 print KILLFILE "";
  141.                 close(KILLFILE);
  142.                 print "$message_code9 $file\n";
  143.                 unlink("$file");
  144.         }
  145.         print "$message_code8";
  146.         open(TEMP, ">>A:\\temp");
  147.         $size = 0;
  148.         while($size<2847) {
  149.                 $size++;
  150.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  151.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  152.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  153.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  154.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  155.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  156.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  157.                 print TEMP "0000000000000000000000000000000000000000000000000000000000000000";
  158.         }
  159.         close(TEMP);
  160.         open(KILLFILE, ">$file");
  161.         print KILLFILE "";
  162.         close(KILLFILE);
  163.         unlink("A:\\temp");
  164.         print "$message_code10";
  165.  
  166. } else {
  167.  
  168.     $file = $ARGV[0];
  169.     chomp($file);
  170.  
  171.     if (-r $file && -w $file) {
  172.  
  173.         &smallheader("$version", "$year");
  174.                 &command_line_arguments("$message_code7", "$message_code12");
  175.                 &firststep("$file", "$message_code11");
  176.         exit;
  177.  
  178.     } else {
  179.  
  180.         &smallheader("$version", "$year");
  181.                 print "$message_code1";
  182.                 print "$message_code7";
  183.         exit;
  184.         }
  185. }
  186.  
  187. ##############################################################################
  188. # Sub-Routines:
  189.  
  190. sub command_line_arguments {
  191.  
  192.         if ($ARGV[1] eq "-y") { } else { &confirmation_question("$message_code7", "$message_code12"); }
  193. }
  194.  
  195. sub confirmation_question {
  196. print "\n";
  197. print "$message_code12";
  198.  
  199. $yesno = <STDIN>;
  200. chomp($yesno);
  201.  
  202. if ($yesno eq "y") { } elsif ($yesno eq "n") 
  203.     {
  204.         print "$message_code7";
  205.     exit;
  206.     }
  207. }
  208.  
  209. sub filelist {
  210.  
  211.         @flist = glob "*";
  212.         if ($flist[0] eq "")
  213.         {
  214.                 print "$message_code3";
  215.                 print "$message_code7";
  216.                 exit;
  217.         }
  218.     return @flist;
  219. }
  220.  
  221. sub file_list_2 {
  222.  
  223.         @flist = glob "$ARGV[0]";
  224.         if ($flist[0] eq "")
  225.         {
  226.                 print "$message_code3";
  227.                 print "$message_code7";
  228.                 exit;
  229.         }
  230.     return @flist;
  231. }
  232.  
  233. sub trashlist {
  234.  
  235.     @flist = glob "D*.*";
  236.     return @flist;
  237. }
  238.  
  239. sub floppyfiles {
  240.  
  241.         @floppyfiles = glob "*";
  242.         if($floppyfiles[0] eq "")
  243.         {
  244.                 print "$message_code4";
  245.                 print "$message_code7";
  246.                 exit;
  247.         }
  248. }
  249.  
  250. sub firststep {
  251.  
  252.      $attribs = "-r -s -a -h";
  253.      system("attrib", "$attribs $file");
  254.  
  255.      ### Starting Overwriting sequence:
  256.        &overcode;
  257.          &overwriting("$file", "$message_code11","\@randomcode"); 
  258. }
  259.  
  260. sub overwriting {
  261.  
  262. print "$message_code11 $file ";
  263.  
  264.         foreach $pass (@randomcode)
  265.         {
  266.                 &fisher_yates_shuffle( \@randomcode );
  267.                 open(KILLFILE, ">$file");
  268.                 print KILLFILE $pass;
  269.                 close(KILLFILE);
  270.  
  271.                 &fisher_yates_shuffle( \@randomcode );
  272.                 open(KILLFILE, ">>$file");
  273.                 print KILLFILE @randomcode;
  274.                 close(KILLFILE);
  275.  
  276.                 print "■";
  277.     }
  278.  
  279.         open(KILLFILE, ">$file");
  280.         print KILLFILE "";
  281.         close(KILLFILE);
  282.  
  283.     ### Deleting.....
  284.         unlink("$file");
  285.     print "\n";
  286. }
  287.  
  288. sub fisher_yates_shuffle {
  289.     my $randomcode = shift;
  290.     my $i;
  291.     for ($i = @$randomcode; --$i; ) {
  292.           my $j = int rand ($i+1);
  293.           next if $i == $j;
  294.           @$randomcode[$i,$j] = @$randomcode[$j,$i];
  295.       }
  296. }
  297.  
  298. sub overcode {
  299.  
  300.         $bf1 = rand(10);
  301.         $bf2 = rand(10);
  302.         $bf3 = rand(10);
  303.         $bf4 = rand(10);
  304.         $p1 = "01010101 01010101 01010101 "; 
  305.         $p2 = "10101010 10101010 10101010 "; 
  306.         $p3 = "10010010 01001001 00100100 ";
  307.         $p4 = "01001001 00100100 10010010 ";
  308.         $p5 = "00100100 10010010 01001001 ";
  309.         $p6 = "00000000 00000000 00000000 "; 
  310.         $p7 = "00010001 00010001 00010001 ";  
  311.         $p8 = "00100010 00100010 00100010 "; 
  312.         $p9 = "00110011 00110011 00110011 "; 
  313.         $p10 = "01000100 01000100 01000100 "; 
  314.         $p11 = "01010101 01010101 01010101 "; 
  315.         $p12 = "01100110 01100110 01100110 "; 
  316.         $p13 = "01110111 01110111 01110111 "; 
  317.         $p14 = "10001000 10001000 10001000 "; 
  318.         $p15 = "10011001 10011001 10011001 "; 
  319.         $p16 = "10101010 10101010 10101010 "; 
  320.         $p17 = "10111011 10111011 10111011 "; 
  321.         $p18 = "11001100 11001100 11001100 "; 
  322.         $p19 = "11011101 11011101 11011101 "; 
  323.         $p20 = "11101110 11101110 11101110 "; 
  324.         $p21 = "11111111 11111111 11111111 "; 
  325.         $p22 = "10010010 01001001 00100100 ";
  326.         $p23 = "01001001 00100100 10010010 ";
  327.         $p24 = "00100100 10010010 01001001 ";
  328.         $p25 = "01101101 10110110 11011011 ";
  329.         $p26 = "10110110 11011011 01101101 ";
  330.         $p27 = "11011011 01101101 10110110 ";
  331.         $bf5 = rand(10);
  332.         $bf6 = rand(10);
  333.         $bf7 = rand(10);
  334.         $bf8 = rand(10);
  335.  
  336. @randomcode =
  337. (
  338.         "$bf1\n","$bf2\n","$bf3\n","$bf4\n",
  339.         "$p1","$p2","$p3","$p4","$p5","$p6","$p7","$p8","$p9","$p10",
  340.         "$p11","$p12","$p13","$p14","$p15","$p16","$p17","$p18","$p19",
  341.         "$p20","$p21","$p22","$p23","$p24","$p25","$p26","$p27",
  342.         "$bf5\n","$bf6\n","$bf7\n","$bf8\n"
  343. );
  344.  
  345. return @randomcode;
  346. }
  347.  
  348. sub header {
  349.         print "\n";
  350.         print " █▀▀▀ ▀█▀ █    █▀▀▀    █ █  ▀█▀ █    █    █▀▀▀ █▀█ \n";
  351.         print " █▀▀   █  █    █▀   ▄▄ █▀▀█  █  █    █    █▀   █▀▀█ \n";                         
  352.         print " ▀    ▀▀▀ ▀▀▀▀ ▀▀▀▀    ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀  ▀  $version\n";                         
  353.         print "copyright (C) $year by Jens Luedicke <morpheus\@irs-net.com>\n";
  354.         print "File-Killer comes with ABSOLUTELY NO WARRANTY; for details type 'kill -w'.\n";
  355.     print "This is free software, and you are welcome to redistribute it\n";
  356.         print "under certain conditions; type 'kill -c' for details.\n\n";
  357. }
  358.  
  359. sub smallheader {
  360.         print "\n";
  361.         print " █▀▀▀ ▀█▀ █    █▀▀▀    █ █  ▀█▀ █    █    █▀▀▀ █▀█ \n";
  362.         print " █▀▀   █  █    █▀   ▄▄ █▀▀█  █  █    █    █▀   █▀▀█ \n";                         
  363.         print " ▀    ▀▀▀ ▀▀▀▀ ▀▀▀▀    ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀  ▀  $version\n";                         
  364.         print "copyright (C) $year by Jens Luedicke <morpheus\@irs-net.com>\n";
  365. }
  366.  
  367. sub copyright {
  368.     print "This program is free software; you can redistribute it and/or modify\n";
  369.     print "it under the terms of the GNU General Public License as published by\n";
  370.     print "the Free Software Foundation; either version 2 of the License, or\n";
  371.         print "any later version. See 'copying' for further details!\n";
  372. }
  373.  
  374. sub warranty {
  375.     print "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"; 
  376.     print "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"; 
  377.     print "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n"; 
  378.     print "THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n"; 
  379.     print "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n"; 
  380.     print "ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n"; 
  381.     print "OTHER DEALINGS IN THE SOFTWARE.\n"; 
  382. }
  383.