This is an example with a
headline
`
This php script will send you a mail with all the files that have been changed within an interval you specify.
I created this script because someone hacked into my shared hosting account and added some hidden spammy link into my templates. And since most shared hosting accounts do not have any kind of logfiles available, it is almost impossible for you to find out how the hacker got in. I could even be, the hacker got acces to your files by hacking another shared hosting account on that server.
With this script you will at least be notified when someone has changed the files on your server.
settings:
PHP:
-
$from="name@domain.com";
-
$to="name@domain.com";
-
$subject="changes on webhosting";
-
$domain = "yourdomain.com";
-
-
-
wwwname => 'htdocs1',
-
wwwdirectory => '/mounted-storage/home/website1.com'
-
),
-
-
wwwname => 'htdocs2',
-
wwwdirectory => '/mounted-storage/home/website2.com'
-
)
-
);
functions
PHP:
-
function url_remove_lastslash($url){
-
-
-
}else{
-
return $url;
-
}
-
}
-
-
-
function getfiles($path_start) {
-
global $results;
-
-
-
if ($file != "." && $file != "..") {
-
-
$file_path = url_remove_lastslash($path_start) . "/" . $file;
-
-
getfiles ($file_path);
-
}
-
-
-
-
-
-
-
-
-
-
//echo $yr .$mnth . $dy."<br>";
-
-
if (($now <= $newday) ) {
-
//echo $file_path . " " . $date_mod . " " . $now . " " . $newday. $yr .$mnth . $dy."<br>";
-
$results[$file_path][0] = $file_path ;
-
$results[$file_path][1] = $date_mod;
-
}
-
}
-
-
}
-
-
}
-
}
check all hosting accounts & create mailbody
PHP:
-
foreach ($settings as $setting){
-
-
$date_change = "";
-
$filename= "";
-
-
getfiles($setting['wwwdirectory']);
-
-
$mail_body .= "<b>".$setting['wwwname']."</b><br/>";
-
-
//sort by change date
-
foreach ($results as $key => $row) {
-
$date_change[$key] = $row[0];
-
$filename[$key] = $row[1];
-
-
}
-
-
//array_multisort($filename, SORT_DESC, $date_change, SORT_ASC, $results);
-
-
foreach ($results as $result){
-
-
}
-
-
}
mail the changed files
PHP:
-
$headers="";
-
$headers .= "X-Sender: $from <$from>\n"; //
-
$headers .="From: $from <$from>\n";
-
$headers .= "Reply-To: $from <$from>\n";
-
-
-
$headers .= "Subject: $subject\n";
-
$headers .= "Return-Path: $from <$from>\n";
-
$headers .= "Delivered-to: $from <$from>\n";
-
$headers .= "MIME-Version: 1.0\n";
-
$headers .= "Content-type: text/html;charset=ISO-8859-9\n";
-
$headers .= "X-MSMail-Priority: Normal\n";
-
$headers .= "X-Mailer: Mail send from ".$domain."!\n";
-
-
//mail to customer
-
-
echo "job executed succesfully";
-
}else{
-
echo "error executing job";
-
}
You can download a copy of phpHackChecker here. Change the file extension to ".php".
Popularity: 24% [?]
RSS feed for comments on this post · TrackBack URI
Leave a reply