Jump to content

small script to monitor website changes


Recommended Posts

Matt not sure if this is the right section to post this as it is not directly for use with whmcs. please move it if it's in the wrong section.

 

Anyway here is the script, I have only basic php skills but i wrote this to monitor a few customers sites after they had their pc's infected and leaked their ftp details. Their sites had spam links placed at the bottom of their site.

 

Thought i would post it incase anyone else finds it uselful or can improve on my poor coding skills:)

The script rather than look for keywords as they are not always missing looks at the file size of the page, just adding 1 character is enough to trip the script in to sending an alert.

 

 

<?php

//

//This simple script is used to recover and then check the file size of a file.

//This is an effective method to alert you of any changes to your websites page

//If an hacker defaces your page you will now know about it. Some hackers now try

//to hide links at the bottom of your webpage linking to viagra etc... these links can go

//unnoticed, this script will alert you of even the smallest change.

// The script is simple and I am sure it can be improved by someone who has far better knowledge of php than me :).

//I am not a php coder but thought i would share this script anyway.

//

 

 

 

// STEP ONE enter the name of the file you want to check.

$file = 'index.html';

 

// STEP TWO upload this script to the same folder as the file you want to check or include the path to the file. run in your browser to obtain the size of the file. you will receive an email on the first run as the file size does not yet match.

echo "$file size is currently : ";

echo filesize($file);

$size = filesize($file);

 

 

// STEP 3 once you know the file size enter it below, REPLACE 36066 WITH YOUR FILE SIZE !

if ( $size == 36066 ) {

echo "ok";

} else {

// STEP 4 change the $to email, $subject $from and $message tou your email address etc..

$to = 'you@domain.com';

$subject = 'file size does not match';

$from = 'you@domain.com';

$message = 'file size does not match !!!';

if(mail($to, $subject, $message, "From: $from"))

echo '<BR>';

echo "Mail sent to report file size ($size) does not match current data entered at line 13";

}

// once you are happy the script is working, set a cron job to run say every 4 hours or daily etc... do not use dev null to avoid receiving the cron emails as you would not know if the script is running correctly. It is possible hackers could deface this file too !! if that happens the cron email would alert you of errors.

 

?>

Link to comment
Share on other sites

It was not intended to be used to monitor every website on the server but to monitor sites that had previously leaked their passwords via infected pc's.

 

I guess monitoring 200 sites would not cause any load issues providing the cron was not run for all 200 at the same time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated