Last active
August 29, 2015 14:17
-
-
Save petertoi/23d072d1d8589d9f5386 to your computer and use it in GitHub Desktop.
Script for searching all .php files for evidence of PHP injections
This file contains 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/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