Ignacio's solution with find is probably the best way. Here it is with all the details from comments incorporated. I am specifically only searching for files (not directories) then grouping three statements together in a group with or statements to match any of the names:
find /dir/ \
-type f \
\( -name timthumb.php -or -name thumb.php -or -name rt-timthumb.php \) \
-exec grep -q "timthumb" {} \; \
-exec cp filename.php {} \;
However you could also do the finding with just shell glob patterns as well, something like this:
shopt -s extglob
for file in /dir/**{timthumb,thumb,rt-timthumb}.php; do
grep -q 'timthumb' "$file" && cp filename.php "$file"
done
You could also use the grep to do the recursive search instead of globbing. This would be useful if you had a lot of files:
grep -l -R -Z 'timthumb' /dir/**thumb.php | while read -d $'\0' file; do
cp filename.php "$file"
done
In all cases replace "/dir/" with the base path you want to operate on and "filename.php" with the source file you are going to overwrite with. Quote as necessary. Note that in the last example I used a shortcut to match all files whos names match "*thumb.php". You could do this in the other examples too. In the case of find, you could drop the whole set of OR statements in parens and just use -name '*thumb.php'. All of the above examples will only operate on filesthat match those name patterns AND contain the string 'timthumb'.