Rev 41 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#! /usr/bin/env perl
# wp core verify-checksums --allow-root
# wp-cli.org
use warnings;
use strict;
use File::Basename;
use Cwd;
sub checkSite {
my $sitename = shift;
# strip off any file name
$sitename = dirname( $sitename );
# remember our current directory
my $oldDir = getcwd();
# move to the WordPress install directory
chdir $sitename;
# run the wp command line tool
my $output = `wp core verify-checksums --allow-root 2>&1`;
# go back to our old directory
chdir $oldDir;
# if we have success, return null, else return the output
return $output =~ m/^success/i ? '' : $output;
}
# find all wites which have wp-config in them
my @sites = `find /var/www/clients/ -type f -name wp-config.php`;
chomp @sites;
# check all of those sites
foreach my $site ( @sites ) {
# only check if they are in the web directory
next unless $site =~ m@client(\d+)/web(\d+)/web@;
# Now, check the site
if ( my $result = &checkSite( $site ) ) { # we have an error
print "Possible Infected WordPress Site $site\n";
}
}
1;