simplybe Posted May 12, 2008 Share Posted May 12, 2008 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. ?> 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted May 13, 2008 Share Posted May 13, 2008 won't this cause a LOT of extra load on a server with a few hundred websites? 0 Quote Link to comment Share on other sites More sharing options...
simplybe Posted May 13, 2008 Author Share Posted May 13, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.