Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- # A useful command to determine if you need this tool:
- # find . -exec grep -li eval {} \; -print
- # Written to undo the base64 encoding included in wordpress templates and modules.
- # Usage: perl php_cleanup.pl $filename
- #
- # When this runs it will ask "continue?" for each iteration.. just hit enter
- # After this program runs you'll probably still have to go into the file
- # and do some cleanup. It's not perfect. It just replaces each eval
- # and then tries to run it again.
- #
- # I've noticed on index.php there is an include header.php or something.
- # the workaround seems to be to go into VI and cut those lines into a buffer
- # then put VI in the bkgroung (^Z) and re-run this tool.
- # That will overwrite the index.php.
- # AFTER it finishes; return to the VI session in the bkgrnd (fg)
- # Replace the yanked lines at the appropriate location (y)
- # and things should be mostly peachy.
- my $filename = shift;
- # die if this filename doesn't exist
- if (not -e $filename) {
- die "Please give me a filename";
- }
- my $file = cat $filename;
- #if this file contains and eval let's substitute it with an echo
- $file =~ s/eval/echo/g;
- open( FILE, ("+>" . $filename) );
- printf FILE "%s\n", $file;
- close( FILE );
- my $continue = 1;
- while ($continue) {
- print "continue?";
- my $var = <stdin>;
- my $output = php -q $filename;
- ## if we match another eval
- if ($output =~ s/eval/echo/g) {
- open( FILE, ("+>" . $filename) );
- printf FILE "%s\n", $output;
- close( FILE );
- }
- ## else it should be clean?!!
- else {
- open( FILE, ("+>" . $filename) );
- printf FILE "%s\n", $output;
- close( FILE );
- print "I think we're clean, give it a check!\n";
- $continue = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement