Find php files with strings that have more than 50 characters

久未见 提交于 2019-12-25 02:44:56

问题


I am trying to run a command (find) for example that would allow me to find all the php files in which content there are strings with more than 50 characters.

I have a base that looks like this, but I fail what to write in the grep:

sudo find . -name '.*php' -exec fgrep -q '..' {} \; -print

I assume that a thing that is not a character is a whitespace. Basically I am trying to find PHP files that might have been compromisde with huge chunks of encoded64 strings.


回答1:


Matches lines with 50 or more consecutive non space characters:

grep '[^ ]\{50,\}' *.php

Also, in Perl or PHP preg_match() I think this will match a base64 encoded string (any string that can be base64 decoded):

([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)


来源:https://stackoverflow.com/questions/22206706/find-php-files-with-strings-that-have-more-than-50-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!