Ant hacking techniques: bash wp-cli command to validate wp core

The idea of this post is to create a script that validates the wp core integrity to be run by a cron job when ever you want

I am using 3 different tools:

– bash script that runs a wp-cli command call by a cron job

– php script the phpushbullet librery

– Pushbullet account with API to send the messages to the webmaster

 

You will need to have wp-cli installed in your server outside the public folder.

 

Wp-Cli it is an amazing console tool you should be using if you develop or maintain wp sites.

The command we will be using is:

https://wp-cli.org/commands/core/verify-checksums/

So first you will create a bash file that will:
– run the wp-cli command and save the output in a text file
– compare the output with a previous saved output file renamed wpcore-master.txt
– in case it is different it will push a message to a selected device or pushbullet user.

Now we need to install the PHPushbullet application in the folder you are running the scripts

https://github.com/joetannenbaum/phpushbullet

I just git clone the repo and added my little php script inside the folder as follows:

 

So every time the cron job runs the bash script will compare the checksum of the server core wp files against the official wp repo and replace the output file.

The bash code will also compare the output with the previous saved correct output and then trigger the php file with the pushbullet functionality.

 

enjoy,

Eduardo

About the author
Eduardo Silva was born in Buenos Aires, Argentina, and has being living in London for the past 15 years. With a background in psychology he is a IT developer and the co-founder of open-ecommerce.org, a digital content social enterprise. His passion is digital story-telling and has created short films and documentaries to help people promote there ideas.