Aera223

Polymorphic?

Sep 22nd, 2020 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2. //Prepares the file, and some random text
  3. $t = file_get_contents("0.php");
  4. $a = ['q','v','p','o','j','g'];
  5. $b = $a[mt_rand(0,5)].$a[mt_rand(0,5)].$a[mt_rand(0,5)].$a[mt_rand(0,5)];
  6.  
  7.  
  8. //Removes some comments, and inserts random text into the output
  9. $t = str_replace('$','$'.$b,$t);
  10. $t = preg_replace('/\n\s*\n/', "\n", $t);
  11. $t = str_replace('$'.$b.'_','$_',$t);
  12.  
  13.  
  14. //Specific replacements
  15. $t = str_replace("wd.txt",$b.".txt",$t);
  16. $t = str_replace("writer.phtml",'\'.$_SERVER[\'PHP_SELF\'].\'',$t);
  17.  
  18.  
  19. //HTML output
  20. echo '<h1 style="font-family:arial">Code that modifies itself</h1><pre>';
  21. echo htmlspecialchars($t);
  22. echo '</pre>';
  23.  
  24.  
  25. //Thanks for reading this code.
  26. //This basically imports a specific file (my PHP file writer), and randomly modifies it
  27. //1296 possible outputs!
  28. ?>
Add Comment
Please, Sign In to add comment