PHP Trojan webshell scanner code_PHP tutorial
/*
+-------- -------------------------------------------------- ----------------+
| Codz by indexphp Version:0.01 |
| (c) 2009 indexphp |
| http://www.indexphp. org |
+-------------------------------------------------- ----------------------------------+
*/
/*========= ============ Program configuration=====================*/
$dir='cms'; //Settings Directory to be scanned
$jumpoff=false; //Set files to skip checking
$jump='safe.php|g'; //Set files or folders to skip checking$jumpoff= This setting is valid when false
$danger='eval|cmd|passthru';//Set the dangerous function to be found to determine whether it is a Trojan file
$suffix='php|inc';//Set to scan File suffix
$dir_num=0;
$file_num=0;
$danger_num=0;
/*================== === End of configuration======================*/
extract (GetHttpVars());
if ($m=="edit" ) Edit();
if ($m=="del") Delete();
if ($check=='check')
{ $safearr = explode("|",$jump );
$start_time=microtime(true);
safe_check($dir);
$end_time=microtime(true);
$total=$end_time-$start_time;
$file_num =$file_num-$dir_num;
$message= "Number of files:".$file_num;
$message.= "Number of folders:".$dir_num;
$message.= "Number of suspicious files : ".$danger_num;
$message.= " Execution time: ".$total;
echo $message;
exit();
}
function GetHttpVars() {// Global variables
$superglobs = array(
'_POST',
'_GET',
'HTTP_POST_VARS',
'HTTP_GET_VARS');
$httpvars = array();
foreach ($superglobs as $glob) {
global $$glob;
if (isset($$glob) && is_array($$glob)) {
$httpvars = $$glob;
}
if (count($httpvars) > 0)
break;
}
return $httpvars;
}
function Safe_Check($dir)//Traverse files
{
global $danger ,$suffix ,$dir_num ,$file_num ,$danger_num;
$hand=@dir($dir) or die('Folder does not exist') ;
while ($file=$hand->read() )
{
$filename=$dir.'/'.$file;
if (!$jumpoff) {
if(Jump( $filename))continue;
}
if(@is_dir($filename) && $file != '.' && $file!= '..'&& $file!='./..')
{ $dir_num++;
Safe_Check($filename);
}
if (preg_match_all ("/.($suffix)/i",$filename,$out))
{
$str='';
$fp = @fopen($filename,'r')or die('no permission');
while(!feof($fp))
{
$str .= fgets($fp,1024);
}
fclose($fp);
if( preg_match_all ("/($danger)[ rnt]{0,}([[ (])/i",$str,$out))
{
echo "Suspicious file: {$filename}< ;/font>
View code
Delete
";
$danger_num++;
}
}
$file_num++;
}
}
function Edit()//View suspicious files
{
global $filename;
$filename = str_replace(".."," ",$filename);
$file = $filename;
$content = "";
if(is_file($file))
{
$fp = fopen($file, "r")or die('no permission');
$content = fread($fp,filesize($file));
fclose($fp);
$content = htmlspecialchars($content );
}
echo "rn";
exit();
}
function Delete()//Delete file
{
global $filename;
(is_file($filename))?($mes=unlink($filename )?'Delete successfully':'Delete failed to view permission'):'';
echo $mes;
exit();
}
function Jump($file)//Skip the file
{
global $jump,$safearr;
if($jump != '')
{
foreach($safearr as $v)
{
if( $v=='') continue;
if( eregi($v,$file) ) return true ;
}
}
return false;
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
