需要Shell脚本找到这个模式 [英] Need Shell Script to find this pattern

查看:84
本文介绍了需要Shell脚本找到这个模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们提供了一个共享的主机,我们的大多数客户都在使用脆弱的插件,这导致许多被攻击的文件越来越上传,现在我想删除这些文件。

如果这种模式 [XX] (X为数字),是在有一行多次。至少它应该在那里的10倍,那么它是一个被攻击/垃圾文件,然后我可以将其删除。我尝试了许多的多重组合,似乎没有任何合作。

  $ GLOBALS ['vtton6'] = $r76[94].$r76[24].$r76[24].$r76[49].$r76[24].$r76[54].$r76[24].$r76[94].$r76[41].$r76[49].$r76[24].$r76[87].$r76[53].$r76[58].$r76[61]; 。。。$ GLOBALS ['jlxru64'] = $ R76 [53] $ R76 [58] $ R76 [53] $ R76 [54] $ R76 [66] $ R76 [94] $ R76 [87]。 。。$ GLOBALS ['vajox38'] = $ R76 [95] $ R76 [94] $ R76 [7] $ R76 [53] $ R76 [58] $ R76 [94]。 。。。$ GLOBALS ['qobdl72'] = $ R76 [36] $ R76 [70] $ R76 [27] ​​$ R76 [45] $ R76 [61] $ R76 [76] $ R76 [31]。 。。。$ GLOBALS ['yhrfr40'] = $ R76 [20] $ R76 [69] $ R76 [36] $ R76 [20] $ R76 [58] $ R76 [15] $ R76 [46]。 。$ GLOBALS ['quzii24'] = $ R76 [78] $ R76 [95] $ R76 [28]。 。$ GLOBALS ['tlyiy12'] = $ R76 [27] ​​$ R76 [49] $ R76 [45] $ R76 [58] $ R76 [87]。


解决方案

如何

  $的grep -E'(\\ [[0-9] + \\]。*){10}INPUTFILE

了RegexDemo

要删除的文件,

  $ grep的-qe'(\\ [[0-9] + \\] *){10}INPUTFILE和放大器;&安培; RM INPUTFILE

有一个漫长的解决方案是像

  $ [$(grep的-oe'\\ [[0-9] + \\]'INPUTFILE |厕所-l)-ge 10]&安培;&安培; RM INPUTFILE

We are providing a shared hosting, most of our clients are using vulnerable plugin, this leads to many hacked files are getting uploaded, Now I want to delete those files.

If this kind of pattern [xx] (x are numbers) is there multiple times in a single line. At least it should be there 10 times , then it is a hacked/spam file, then I can delete them. I tried so many multiple combinations, nothing seems to be working.

$GLOBALS['vtton6'] = $r76[94].$r76[24].$r76[24].$r76[49].$r76[24].$r76[54].$r76[24].$r76[94].$r76[41].$r76[49].$r76[24].$r76[87].$r76[53].$r76[58].$r76[61]; $GLOBALS['jlxru64'] = $r76[53].$r76[58].$r76[53].$r76[54].$r76[66].$r76[94].$r76[87]; $GLOBALS['vajox38'] = $r76[95].$r76[94].$r76[7].$r76[53].$r76[58].$r76[94]; $GLOBALS['qobdl72'] = $r76[36].$r76[70].$r76[27].$r76[45].$r76[61].$r76[76].$r76[31]; $GLOBALS['yhrfr40'] = $r76[20].$r76[69].$r76[36].$r76[20].$r76[58].$r76[15].$r76[46]; $GLOBALS['quzii24'] = $r76[78].$r76[95].$r76[28]; $GLOBALS['tlyiy12'] = $r76[27].$r76[49].$r76[45].$r76[58].$r76[87]; 

解决方案

How about

$ grep -E '(\[[0-9]+\].*){10}' inputFile

RegexDemo

To delete the file,

 $ grep -qE '(\[[0-9]+\].*){10}' inputFile && rm inputFile

OR

A lengthy solution would be like

$ [ $(grep -oE '\[[0-9]+\]'  inputFile | wc -l) -ge 10 ] && rm inputFile

这篇关于需要Shell脚本找到这个模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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