从 php 文件中大量删除恶意行 [英] Mass removal of malicious line from php files

查看:25
本文介绍了从 php 文件中大量删除恶意行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处简要说明了这一点:删除PHP 文件中带有 Start 和 End 的字符串,但我正在寻找相同代码的解决方案.服务器上每个 PHP 文件的第一行都以<?php if(!isset($GLOBALS[ and ends with -1; ?>. 中间是一长串不同文件的代码归档.

This was addressed briefly here: Removing a string in a PHP file with Start and End but I'm looking for a solution to the same code. The first line of every PHP file on the server begins with <?php if(!isset($GLOBALS[ and ends with -1; ?>. and in the middle is a long string of code that varies from file to file.

我正在尝试想出一个脚本来从所有文件中删除这一行.我和上一篇文章中的那个人撞到了同一堵墙.

I'm trying to come up with a script to remove this line from all files. I'm running into the same wall as the guy in the previous post.

使用:

sed -e '1 s/^<\?php if(!isset($GLOBALS\[.*-1; \?>//' *.php

在 UNIX 环境中打印没有代码的 PHP 文件,但不保存它.我错过了什么?

in a UNIX environment prints the PHP file without the code, but does not save it. What am I missing?

推荐答案

使用 sed 的 -i 选项,让 sed 修改 PHP 文件.

Use sed's -i option, so that sed modifies the PHP files.

-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)

[SUFFIX] 部分是可选的,但某些 sed 实现要求您提供它.

The [SUFFIX] part is optional but some sed implementations require you to provide it.

在你的情况下,你可以试试这个:

In your case, you could try this:

sed -i.bak 's/^<\?php if(!isset($GLOBALS\[.*-1; \?>//' *.php

阅读man sed了解更多信息.

这篇关于从 php 文件中大量删除恶意行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆