Skip to content

Instantly share code, notes, and snippets.

@tlongren
Last active April 19, 2016 20:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlongren/9ac55edf2a7d1b1b27e8 to your computer and use it in GitHub Desktop.
Save tlongren/9ac55edf2a7d1b1b27e8 to your computer and use it in GitHub Desktop.
Find base64 inside PHP files, may indicate a hack, usually involving WordPress
#!/bin/bash
# Script by Kris Chase ( kris@mehh.org )
# http://krischase.com
# Source: http://krischase.com/how-to-find-and-clean-up-infected-wordpress-files-over-ssh/
#
# Modified by Tyler Longren to include ( tyler@longren.io )
# 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