Posted by & filed under Linux, Server Admin.

For example, if you wanted to scan all files in the current directory, and all sub directories for any calls to base64_decode, you could do something like this:

find . -type f -exec grep -A 2 -B 2 -H -i -n "base64_decode" {} + > resultb64.txt

find all files, then execute grep on them, printing out matching lines, filenames and line numbers, finally write output to resultb64.txt

Another twist on this is to filter the filetypes a bit:

find . -name "*.html" -or -name "*.php" -or -name "*.js" -exec grep -A 2 -B 2 -H -i -n "base64_decode" {} + > resultb64.txt

Lastly, if we wanted to find and replace (with nothing) a string:

find ./ -name "*.html" -or -name "*.php" -exec sed -i 's#STRING TO FIND##g' '{}' \;

Leave a Reply

You must be logged in to post a comment.