Skip to content

Instantly share code, notes, and snippets.

@CapWebSolutions
Created January 3, 2020 01:07
Show Gist options
  • Save CapWebSolutions/fca7ecb353d0256c6f79f501b35ed5bd to your computer and use it in GitHub Desktop.
Save CapWebSolutions/fca7ecb353d0256c6f79f501b35ed5bd to your computer and use it in GitHub Desktop.
Perform MainWP Security scan on all configured sites from terminal
#
# This script is executed from a terminal prompt at the root of your MainWP WordPress website
#
# Execute MainWP CLI command to generate a list of all configured sites in MainWP
# Pipe output through filter to remove columns 3 and 4 of output. These columns hold the 2 digit site number. Adjust if more than 99 sites.
# Pipe that output to get rid of the comment lines in the site listing.
# Pipe that output through the SED editor inserting the security scan command at the beginning of the line
# Send everything to a shell script to be executed.
wp mainwp sites | cut -c3-4 | grep -E '([0-9]|[0-9][0-9])' | sed 's/^/wp mainwp-sucuri scan /' > sec-scan-auto.sh
#
# Make the newly created shell script executable.
chmod +x sec-scan-auto.sh
#
# Run the schell script and watch the progress. Could pipe the output to a text file to keep track of results.
./sec-scan-auto.sh
@CapWebSolutions
Copy link
Author

  • Work on running this using a cpanel based cron job once a week.
  • Output all results to text file.
  • Email text file to self for review and verification.
  • Grep for error messages to add appropriate ATTENTION GRABBING notation on email subject line.
    ./sec-scan-v5.sh > scan-results.txt

@Mediatros
Copy link

Mediatros commented Jan 24, 2021

Really nice job ;)

@CapWebSolutions
Copy link
Author

Hey there BillyB0y,

Make sure you are running the script in the root of your WordPress install that has MainWP activated. It runs on WP CLI. If you can run CLI in the folder where this script lives, you should be good to go.

Here is the latest version I have been using for a few months. Still a work in progress.

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