Linux: find files based on a file name and file content pattern


Example: scan PHP shell with content in folder /home:

/*ece25*/

@include "\057home\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\157";

/*ece25*/

Method 1:

grep -zoPRl "\/\*[a-f0-9]*\*\/\n*\@include" --include="*.php" /home

Method 2:

find /home -type f -name "*.php" -exec grep -zoPRl "\/\*[a-f0-9]*\*\/\n*\@include" {} \;

Leave a Reply