Skip to content

Instantly share code, notes, and snippets.

@petertoi
Last active August 29, 2015 14:17
Show Gist options
  • Save petertoi/23d072d1d8589d9f5386 to your computer and use it in GitHub Desktop.
Save petertoi/23d072d1d8589d9f5386 to your computer and use it in GitHub Desktop.
Script for searching all .php files for evidence of PHP injections
#!/bin/sh
#
# Author: Peter Toi
# Source: https://gist.github.com/petertoi/23d072d1d8589d9f5386
#
# Usage 1: $ injectionscan.sh
rm -fr injections.txt
touch injections.txt
find . -type f -name '*.php' -print0 |
while read -r -d $'\0' x; do
# Check first line of file for more than 20000 characters
B=$(head -1 "$x")
C=$(echo $B | wc -c)
if [ "$C" -ge "20000" ]; then
echo "Possible Injection: "$x $C
echo $x $C >> injections.txt
fi
# Look for ('$_', pattern
D=$(grep -n "('\$_'," "$x")
if [ -n "$D" ]; then
echo "Mid-File Injection: "$x:$D
echo $x:$D >> injections.txt
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment