Find php files with strings that have more than 50

2019-09-01 01:51发布

问题:

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}==)