Skip to content

Instantly share code, notes, and snippets.

@pyguerder
Last active November 26, 2022 15:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save pyguerder/5abe6fed495954615599 to your computer and use it in GitHub Desktop.
Save pyguerder/5abe6fed495954615599 to your computer and use it in GitHub Desktop.
A script to run WPScan periodically on a list of websites
#!/bin/bash
DATABASE_PATH="data/plugins.json"
SYMBOL="[!]"
TMPFILE="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.rb --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.rb -r --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
@tristanlatr
Copy link

Helllo,
I think your script would not work with WPScan v3 because of the WPScan.rb executable, I think it would be something like /usr/local/bin/wpscan or /usr/local/rvm/gems/default/wrappers/wpscan with RVM.

If you like something a bit more advanced and up to date, you can install WPWatcher : a Python wrapper for WPScan that manages scans on multiple sites and reports by email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment