Last active
April 19, 2016 20:56
-
-
Save tlongren/9ac55edf2a7d1b1b27e8 to your computer and use it in GitHub Desktop.
Find base64 inside PHP files, may indicate a hack, usually involving WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script by Kris Chase ( [email protected] ) | |
# http://krischase.com | |
# Source: http://krischase.com/how-to-find-and-clean-up-infected-wordpress-files-over-ssh/ | |
# | |
# Modified by Tyler Longren to include ( [email protected] ) | |
# https://longren.io | |
# Neither of us are responsible for any damage that may occur when running this script. | |
LIST=infectedfiles.txt | |
PATTERN="eval(base64_decode" | |
TARGET="/home/youruser" | |
if [ ! -s $LIST ] ; then | |
grep -l -R --include=*.php $PATTERN $TARGET > $LIST | |
fi | |
for INPUT in `cat $LIST` | |
do | |
echo FIX $INPUT ... | |
TEMP=$INPUT.tmp | |
OLD=$INPUT.bad | |
< $INPUT sed "s/<?php/\n<?php/g" | grep -v $PATT > $TEMP | |
mv $INPUT $OLD | |
mv $TEMP $INPUT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment