Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.76 KB | None | 0 0
  1. use strict;
  2.  
  3. # A useful command to determine if you need this tool:
  4. #  find . -exec grep -li eval {} \; -print
  5.  
  6. # Written to undo the base64 encoding included in wordpress templates and modules.
  7. # Usage: perl php_cleanup.pl $filename
  8. #
  9. # When this runs it will ask "continue?" for each iteration.. just hit enter
  10. # After this program runs you'll probably still have to go into the file
  11. # and do some cleanup.  It's not perfect.  It just replaces each eval
  12. # and then tries to run it again.
  13. #
  14. # I've noticed on index.php there is an include header.php or something.
  15. # the workaround seems to be to go into VI and cut those lines into a buffer
  16. # then put VI in the bkgroung (^Z) and re-run this tool.
  17. # That will overwrite the index.php.
  18. # AFTER it finishes; return to the VI session in the bkgrnd (fg)
  19. # Replace the yanked lines at the appropriate location (y)
  20. # and things should be mostly peachy.
  21.  
  22. my $filename = shift;
  23.  
  24. # die if this filename doesn't exist
  25. if (not -e $filename) {
  26. die "Please give me a filename";
  27. }
  28. my $file = cat $filename;
  29. #if this file contains and eval let's substitute it with an echo
  30.  
  31. $file =~ s/eval/echo/g;
  32.  
  33. open( FILE, ("+>" . $filename) );
  34. printf FILE "%s\n", $file;
  35. close( FILE );
  36.  
  37. my $continue = 1;
  38. while ($continue) {
  39.    print "continue?";
  40.    my $var = <stdin>;
  41.    my $output = php -q $filename;
  42.  
  43.    ## if we match another eval
  44.    if ($output =~ s/eval/echo/g) {
  45.         open( FILE, ("+>" . $filename) );
  46.         printf FILE "%s\n", $output;
  47.         close( FILE );
  48.         }
  49.  
  50.    ## else it should be clean?!!
  51.    else {
  52.         open( FILE, ("+>" . $filename) );
  53.         printf FILE "%s\n", $output;
  54.         close( FILE );
  55.  
  56.         print "I think we're clean, give it a check!\n";
  57.     $continue = 0;
  58.         }
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement