Subversion Repositories sysadmin_scripts

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
39 rodolico 1
#! /usr/bin/env perl
2
 
3
# wp core verify-checksums --allow-root 
4
# wp-cli.org
5
 
6
use warnings;
7
use strict;
8
use File::Basename;
9
use Cwd;
10
 
11
sub checkSite {
12
   my $sitename = shift;
13
   # strip off any file name
14
   $sitename = dirname( $sitename );
15
   # remember our current directory
16
   my $oldDir = getcwd();
17
   # move to the WordPress install directory
18
   chdir $sitename;
19
   # run the wp command line tool
20
   my $output = `wp core verify-checksums --allow-root 2>&1`;
21
   # go back to our old directory
22
   chdir $oldDir;
23
   # if we have success, return null, else return the output
24
   return $output =~ m/^success/i ? '' : $output;
25
}
26
 
27
# find all wites which have wp-config in them
28
my @sites = `find /var/www/clients/ -type f -name wp-config.php`;
29
chomp @sites;
30
# check all of those sites
31
foreach my $site ( @sites ) {
32
   # only check if they are in the web directory
33
   next unless $site =~ m@client(\d+)/web(\d+)/web@;
34
   # Now, check the site
35
   if ( my $result = &checkSite( $site ) ) { # we have an error
36
      print "Possible Infected WordPress Site $site\n";
37
   }
38
}   
39
 
40
 
41
1;