Skip to content

Instantly share code, notes, and snippets.

@planetahuevo
Forked from CapWebSolutions/sec-scan-root.sh
Created January 30, 2021 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save planetahuevo/5c5a886c064252f64834453488501df2 to your computer and use it in GitHub Desktop.
Save planetahuevo/5c5a886c064252f64834453488501df2 to your computer and use it in GitHub Desktop.
Latest iteration of security scanning script for MainWP instance.
#
# This script is executed from a terminal prompt at the root of your MainWP WordPress website.
# It uses the same services as WP CLI, so if WP CLI runs, this should also.
#
# 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.
rm -f sec-scan-auto.sh
rm -f sec-scan-log.txt
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
cat 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 2>&1 | tee sec-scan-log.txt
./sec-scan-auto.sh
# ./sec-scan-auto.sh > sec-scan-auto-output.txt
# ref: https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file
# Mail it home
#mail -s 'MWP Security Scan Results' info@capwebsolutions.com -A sec-scan-log.txt
# ref: https://www.tecmint.com/send-email-attachment-from-linux-commandline/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment