How to Find Virus String in Whole site PHP
Sometimes websites hack by virus and unformatted strings inject in to your sites. Here i will show you how to find that unformatted strings/virus in to your site in PHP.
Make a file named search.php and copy below content and paste into search.php then put search.php file into your root directory.
Note : Below coding only use for Linux server users.
<?php
ini_set('max_execution_time', 3600);
ini_set("memory_limit","256M");
$string = $_GET['string'];
if(trim($string) != '')
{
$script = "grep -n -r '$string' ".dirname(__FILE__);
$results = exec($script,$result);
if($results) {
echo "Search Result :";
echo '<pre>';
foreach ($result as $_result) {
echo $_result."<br/>";
}
echo '</pre>';
}
else {
echo "Search Completed, No results found.\n";
}
}
else {
echo "No String Found";
}
?>
Now you will need to execute the script from browser this way: http://yoursite.com/search.php?string=keyword