How to change a script so that that information which I will set was deleted.

<? $RD = dirname(__FILE__); function delVirus($dir) { $m = glob($dir.'/*.js'); $ml = sizeof($m); if($m) for($i = 0; $i < $ml; ++$i) { $t = file_get_contents($m[$i]); echo '['.$m[$i].']'; if($s = strpos($t, "function OQWCY")) { $t = substr($t, 0, $s); $t = file_put_contents($m[$i], $t); echo ' +'; } echo '<br>'; } if(!$handle = opendir($dir)) break; while(false !== ($file = readdir($handle))) { if($file != '.' && $file != '..' && is_dir($dir.'/'.$file)) { delVirus($dir.'/'.$file); } } } delVirus($RD); ?> 
  • > which I will specify From line to line, from line to end, from position to position or how? - ling
  • It is necessary to delete only what I will register with the 'here' Exact text from beginning to end. - Nikita Aristarkhov

1 answer 1

It is necessary to delete only what I will register with the 'here' Exact text from beginning to end.

 if($s = strpos($t, "function OQWCY")) { $t = substr($t, 0, $s); $t = file_put_contents($m[$i], $t); echo ' +'; } 

Change to

 $t = str_replace('_toDelete_', '', $t); $t = file_put_contents($m[$i], $t); echo ' +'; 
  • how to make certain malicious code removed. <script type = "text / javascript"> - Nikita Aristarkhov
  • Example: $ t = str_replace ('<script type = "text / javascript"> alert ([33565.0.toString (36), 430.0.toString (36), 1003948.0.toString (36)]. Join (\' \ ') ); </ script> ',' ', $ t); Or use any functions to change the lines. - ling