Skip to content

Instantly share code, notes, and snippets.

@opt9
Forked from pyguerder/wpscan_batch.sh
Last active May 9, 2018 02:55
Show Gist options
  • Save opt9/02a0231b62a31cbc38b3028b6bf7dd3e to your computer and use it in GitHub Desktop.
Save opt9/02a0231b62a31cbc38b3028b6bf7dd3e to your computer and use it in GitHub Desktop.
A script to run WPScan periodically on a list of websites
#!/bin/bash
source ~/.rvm/gems/ruby-2.5.1@wpscan/environment
WPSCAN_DIR="${HOME}/Projects/wpscan"
DATABASE_PATH="${WPSCAN_DIR}/data/plugins.json"
SYMBOL="[!]"
TMPFILE="${WPSCAN_DIR}/output.tmp"
declare -A WEBSITES
# List your WordPress websites here
WEBSITES['www.website1.dom']='address1@server1.com,address2@server2.com'
WEBSITES['www.website2.dom']='address2@server1.com,address3@server2.com'
# Run an update and compare sha1sum before and after
sha1_before=$(sha1sum 2>&1 $DATABASE_PATH | awk '{print $1}')
${WPSCAN_DIR}/wpscan.rb --no-banner --no-color --update > $TMPFILE
sha1_after=$(sha1sum $DATABASE_PATH 2>&1 | awk '{print $1}')
if [ $sha1_before = $sha1_after ] ; then
echo "Vulnerabilities database has not changed. Exiting."
exit
else
echo "Vulnerabilities database has changed. Will test websites."
fi
for URL in "${!WEBSITES[@]}"
do
EMAIL=${WEBSITES[$URL]}
${WPSCAN_DIR}/wpscan.rb -r --no-banner --no-color --batch --url $URL > $TMPFILE
if grep -q $SYMBOL $TMPFILE
then
echo "$URL is vulnerable! Emailing $EMAIL"
mail -s "$URL is vulnerable" $EMAIL < $TMPFILE
else
echo "$URL is OK"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment