Php website Trojan repair methods summary, php Trojan summary _ PHP Tutorial

Source: Internet
Author: User
Tags filetime mysql code
Summary of php website Trojan repair methods, php Trojan summary. Summary of php website Trojan repair methods, php Trojan summary in linux we can use commands to search Trojan files, go to the code installation directory and execute the following command code: Copy the code: summary of the php website infected with Trojans, Summary of php Trojans

In linux, we can use commands to search Trojan files and run the following commands in the code installation directory:

The code is as follows:
Find./-iname "*. php" | xargs grep-H-n "eval (base64_decode"

Nearly 100 results are found. this list of results is very important. all Trojans are in it. you need to open a file one by one to verify whether the results are Trojans. If yes, delete them immediately.

Finally, we found 10 Trojan files and stored them in various directories, all of which are php webshells. the functions are complete and base64-encoded.

If you search for directories in windows and use windows files, you can search for eval or recently modified files. if dedecms is used, check the latest dedecms vulnerability and fix it.


The following is a php Trojan search tool, which is directly placed in the root directory of your site.

The code is as follows:

/************* PHP Web Trojan scanner ********************* ***/

/* [+] By alibaba */

/* [+] QQ: 1499281192 * www.111cn.net/

/* [+] MSN: weeming21@hotmail.com */

/* [+] Initial release: t00ls.net. for details, refer to t00ls */

/* [+] Version: v1.0 */

/* [+] Function: php Trojan scanning tool for the web version */

/* [+] Note: the scanned file is not necessarily a backdoor ,*/

/* Determine, review, and compare the original file by yourself. */

/* If you are not sure whether the scanned file is a backdoor ,*/

/* You are welcome to send this file to me for analysis. */

/*************************************** ****************/

Ob_start ();

Set_time_limit (0 );

$ Username = "t00ls"; // Set the user name

$ Password = "t00ls"; // Set the password

$ Md5 = md5 (md5 ($ username). md5 ($ password ));

$ Version = "PHP Web Trojan scanner v1.0 ";

PHP Web Trojan scanner

$ Realpath = realpath ('./');

$ Selfpath = $ _ SERVER ['php _ SELF '];

$ Selfpath = substr ($ selfpath, 0, strrpos ($ selfpath ,'/'));

Define ('realpath', str_replace ('//', '/', str_replace ('\', '/', substr ($ REALPATH, 0, strlen ($ realpath) -strlen ($ selfpath )))));

Define ('myfile', basename (_ FILE __));

Define ('mypath', str_replace ('\', '/', dirname (_ FILE __)).'/');

Define ('myfullpath', str_replace ('\', '/', (_ FILE __)));

Define ('host', "http: //". $ _ SERVER ['http _ host']);

?>

<? Php echo $ version?>

If (! (Isset ($ _ COOKIE ['t00ls']) & $ _ COOKIE ['t00ls'] = $ md5 )&&! (Isset ($ _ POST ['username']) & isset ($ _ POST ['password']) & (md5 (md5 ($ _ POST ['username']). md5 ($ _ POST ['password']) = $ md5 )))

{

Echo '';

}

Elseif (isset ($ _ POST ['username']) & isset ($ _ POST ['password']) & (md5 (md5 ($ _ POST ['username']). md5 ($ _ POST ['password']) = $ md5 ))

{

Setcookie ("t00ls", $ md5, time () + 60*60*24*365 ,"/");

Echo "login successful! ";

Header ('refresh: 1; url = '. MYFILE .'? Action = scan ');

Exit ();

}

Else

{

Setcookie ("t00ls", $ md5, time () + 60*60*24*365 ,"/");

$ Setting = getSetting ();

$ Action = isset ($ _ GET ['action'])? $ _ GET ['action']: "";

If ($ action = "logout ")

{

Setcookie ("t00ls", "", time ()-3600 );

Header ("Location:". MYFILE );

Exit ();

}

If ($ action = "download" & isset ($ _ GET ['file']) & trim ($ _ GET ['file'])! = "")

{

$ File = $ _ GET ['file'];

Ob_clean ();

If (@ file_exists ($ file )){

Header ("Content-type: application/octet-stream ");

Header ("Content-Disposition: filename =" ". basename ($ file ).""");

Echo file_get_contents ($ file );

}

Exit ();

}

?>

Scan |

Set |

Logout


If ($ action = "setting ")

{

If (isset ($ _ POST ['btnsetting'])

{

$ Ssetting = array ();

$ Ssetting ['user'] = isset ($ _ POST ['checkuser'])? $ _ POST ['checkuser']: "php | php? | Phtml ";

$ Ssetting ['all'] = isset ($ _ POST ['checkall']) & $ _ POST ['checkall'] = "on "? 1:0;

$ Ssetting ['hta'] = isset ($ _ POST ['checkhta']) & $ _ POST ['checkhta'] = "on "? 1:0;

Setcookie ("t00ls_s", base64_encode (serialize ($ Ssetting), time () + 60*60*24*365 ,"/");

Echo "settings complete! ";

Header ('refresh: 1; url = '. MYFILE .'? Action = setting ');

Exit ();

}

?>

}

Else

{

$ Dir = isset ($ _ POST ['path'])? $ _ POST ['path']: MYPATH;

$ Dir = substr ($ dir,-1 )! = "/"? $ Dir. "/": $ dir;

?>

If (isset ($ _ POST ['btnscan'])

{

$ Start = mktime ();

$ Is_user = array ();

$ Is_ext = "";

$ List = "";

If (trim ($ setting ['user'])! = "")

{

$ Is_user = explode ("|", $ setting ['user']);

If (count ($ is_user)> 0)

{

Foreach ($ is_user as $ key => $ value)

$ Is_user [$ key] = trim (str_replace ("? "," (.) ", $ Value ));

$ Is_ext = "(.". implode ("($ |.) | (.", $ is_user). "($ | .))";

}

}

If ($ setting ['hta'] = 1)

{

$ Is_hta = 1;

$ Is_ext = strlen ($ is_ext)> 0? $ Is_ext. "|": $ is_ext;

$ Is_ext. = "(^. htaccess $ )";

}

If ($ setting ['all'] = 1 | (strlen ($ is_ext) = 0 & $ setting ['hta'] = 0 ))

{

$ Is_ext = "(. + )";

}

$ Php_code = getCode ();

If (! Is_readable ($ dir ))

$ Dir = MYPATH;

$ Count = $ scanned = 0;

Scan ($ dir, $ is_ext );

$ End = mktime ();

$ Spent = ($ end-$ start );

?>

Scan: File | found: Suspicious file | time consumed: Seconds

No. File Update Time Cause Features Action

}

}

}

Ob_flush ();

?>

Function scan ($ path = '.', $ is_ext ){

Global $ php_code, $ count, $ scanned, $ list;

$ Ignore = array ('.','..');

$ Replace = array ("", "n", "r", "t ");

$ Dh = @ opendir ($ path );

While (false! ==( $ File = readdir ($ dh ))){

If (! In_array ($ file, $ ignore )){

If (is_dir ("$ path $ file ")){

Scan ("$ path $ file/", $ is_ext );

} Else {

$ Current = $ path. $ file;

If (MYFULLPATH = $ current) continue;

If (! Preg_match ("/$ is_ext/I", $ file) continue;

If (is_readable ($ current ))

{

$ Scanned ++;

$ Content = file_get_contents ($ current );

$ Content = str_replace ($ replace, "", $ content );

Foreach ($ php_code as $ key => $ value)

{

If (preg_match ("/$ value/I", $ content ))

{

$ Count ++;

$ J = $ count % 2 + 1;

$ Filetime = date ('Y-m-d H: I: S', filemtime ($ current ));

$ Reason = explode ("->", $ key );

$ Url = str_replace (REALPATH, HOST, $ current );

Preg_match ("/$ value/I", $ content, $ arr );

$ List. ="

$ Count

$ Current

$ Filetime

$ Reason [0]

$ Reason [1]

Download

";

// Echo $ key. "-". $ path. $ file. "(". $ arr [0]. ")"."
";

// Echo $ path. $ file ."
";

Break;

}

}

}

}

}

}

Closedir ($ dh );

}

Function getSetting ()

{

$ Ssetting = array ();

If (isset ($ _ COOKIE ['t00ls _ s'])

{

$ Ssetting = unserialize (base64_decode ($ _ COOKIE ['t00ls _ s']);

$ Ssetting ['user'] = isset ($ Ssetting ['user'])? $ Ssetting ['user']: "php | php? | Phtml | shtml ";

$ Ssetting ['all'] = isset ($ Ssetting ['all'])? Intval ($ Ssetting ['all']): 0;

$ Ssetting ['hta'] = isset ($ Ssetting ['hta'])? Intval ($ Ssetting ['hta']): 1;

}

Else

{

$ Ssetting ['user'] = "php | php? | Phtml | shtml ";

$ Ssetting ['all'] = 0;

$ Ssetting ['hta'] = 1;

Setcookie ("t00ls_s", base64_encode (serialize ($ Ssetting), time () + 60*60*24*365 ,"/");

}

Return $ Ssetting;

}

Function getCode ()

{

Return array (

'Backdoor features-> cha88.cn' => 'cha88. cn ',

'Backdoor features-> c99shell' => 'c99shell ',

'Backdoor features-> phpspy' => 'phpspy ',

'Backdoor features-> scanners' => 'Scanners ',

'Backdoor features-> cmd. php' => 'cmd. php ',

'Backdoor features-> str_rot13 '=> 'Str _ rot13 ',

'Webshell' => 'webshell ',

'Backdoor features-> EgY_SpIdEr '=> 'egy _ SpIdEr ',

'Backdoor features-> tools88.com '=> 'tools88. com ',

'Backdoor features-> secforce' => 'secforce ',

'Backdoor features-> eval ("?> '=> 'Eval (' | ")?> ',

'Suspicious code features-> system ('=> 'system (',

'Suspicious code features-> passthru ('=> 'passthru (',

'Suspicious code features-> shell_exec ('=> 'shell _ exec (',

'Suspicious code features-> exec ('=> 'exec (',

'Suspicious code features-> popen ('=> 'popen (',

'Suspicious code features-> proc_open '=> 'proc _ open ',

'Suspicious code features-> eval ($ '=> 'eval (' | "| s *) \ $ ',

'Suspicious code features-> assert ($ '=> 'assert (' | "| s *) \ $ ',

'Dangerous MYSQL code-> returns string soname' => 'returnsstringsoname ',

'Dangerous MYSQL code-> into outfile' => 'Invalid outfile ',

'Dangerous MYSQL code-> load_file '=> 'Select (s +) (. *) load_file ',

'Encrypted backdoor features-> eval (gzinflate ('=> 'eval (gzinflate (',

'Encrypted backdoor features-> eval (base64_decode ('=> 'eval (base64_decode (',

'Encrypted backdoor features-> eval (gzuncompress ('=> 'eval (gzuncompress (',

'Encrypted backdoor features-> eval (gzdecode ('=> 'eval (gzdecode (',

'Encrypted backdoor features-> eval (str_rot13 ('=> 'eval (str_rot13 (',

'Encrypted backdoor features-> gzuncompress (base64_decode ('=>' gzuncompress (base64_decode (',

'Encrypted backdoor features-> base64_decode (gzuncompress ('=> 'base64 _ decode (gzuncompress (',

'One-sentence backdoor feature-> eval ($ _ '=> 'eval (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'One-sentence backdoor feature-> assert ($ _ '=> 'assert (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Webshell features in one sentence-> require ($ _ '=> 'Require (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Webshell features in one sentence-> require_once ($ _ '=> 'Require _ once (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Backdoor features in one sentence-> include ($ _ '=>' include ('| "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'One-sentence backdoor feature-> include_once ($ _ '=> 'Include _ once (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Backdoor features in one sentence-> call_user_func ("assert" '=> 'Call _ user_func ("|') assert (" | ')',

'Webshell features in one sentence-> call_user_func ($ _ '=> 'Call _ user_func (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Webshell features in one sentence-> $ _ POST/GET/REQUEST/COOKIE [?] ($ _ POST/GET/REQUEST/COOKIE [?] '=>' $ _ (POST | GET | REQUEST | COOKIE) [([^] +)] ('| "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )[',

'Backdoor features in one sentence-> echo (file_get_contents ($ _ POST/GET/REQUEST/COOKIE '=> 'echo (file_get_contents (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Upload backdoor features-> file_put_contents ($ _ POST/GET/REQUEST/COOKIE, $ _ POST/GET/REQUEST/COOKIE '=> 'File _ put_contents (' | "| s *) \ $ _ (POST | GET | REQUEST | COOKIE) [([^] +)], ('| "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )',

'Upload backdoor features-> fputs (fopen ("? "," W "), $ _ POST/GET/REQUEST/COOKIE ['=> 'fputs (fopen ((. +), ('| ") w (' |"), ('| "| s *) \ $ _ (POST | GET | REQUEST | COOKIE )[',

'. Htaccess plug-in feature-> SetHandler application/x-httpd-php' => 'sethandlerapplication/x-httpd-php ',

'. Htaccess plug-in feature-> php_value auto_prepend_file' => 'php _ valueauto_prepend_file ',

'. Htaccess plug-in feature-> php_value auto_append_file' => 'php _ valueauto_append_file'

);

}

?>

From: http://www.111cn.net/phper/phpanqn/52711.htm


Today, my website is infected with Trojans.

This is a false positive from Kaspersky. I have already gotten rid of it. I did not get it done for a long time after entering the security mode. later I updated Kaspersky's virus database manually.
The following is a notification on this matter:
At 15:20 P.M. on October 10, May 19, CNZZ received a notification from Kaspersky China about the latest update of the virus database. the other party has fixed the issue of false positive alarms on CNZZ statistics, and the CNZZ statistics service has now recovered to normal immediately. If some users still report viruses, manually update the Kaspersky Virus database.

If the website is infected with Trojans, it cannot be opened as long as it is indexphp.

Generally, computer viruses or Trojans or viruses may damage the system. generally, anti-virus software cannot solve these problems, we recommend that you use system repair tools such as Kingsoft Network security or Kingsoft first aid kit to fix the problem.
We recommend that you use the best solution.

Step 1: Download Kingsoft drug overlord 2011 [baidu search Kingsoft drug overlord] Select Official Download

After step 2 is installed, open Kingsoft drug overlord and click "scan all"

In linux, we can use commands to search Trojan files. in the code installation directory, execute the following command code...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.