Skip to content

Instantly share code, notes, and snippets.

@laacz
Last active August 29, 2015 13:58
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 laacz/9977745 to your computer and use it in GitHub Desktop.
Save laacz/9977745 to your computer and use it in GitHub Desktop.
Finds primitive PHP backdoor crap in webroot. Each sequential run generates only diff (new or removed suspicious files since last run).
#!/usr/bin/env bash
LASTSCANLOG=/tmp/scanlog.txt
THISSCANLOG=/tmp/scanlog.new.txt
# Paths to search (space delimited)
PATHS="~/ ~/"
# Creates file, if it does not exist
touch $LASTSCANLOG
# Find crap
find $PATHS -name "*.php" -exec grep -niH " \(passthru\|shell_exec\|system\|phpinfo\|base64_decode\|popen\|exec\|proc_open\|pcntl_exec\|python_eval\|readfile\)\s*(" '{}' \; >$THISSCANLOG
# Show new or removed crap since last run
diff $LASTSCANLOG $THISSCANLOG
# Save this run as las turn
mv $THISSCANLOG $LASTSCANLOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment