Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
find . -name '.htaccess' -print | xargs grep -il 'sound' | xargs -p sh -c ">{}"

Trying to find some .htaccess files on a host that've been compromised, grep them to make sure they are bad .htaccess (not all on server have been ruined) and blank them out.

All is working, except the last part. Tried many variations of echo > etc.

I'm missing a fundamental here and can't seem to grok it out of all the man pages.

Thanks.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted
find . -name '.htaccess' -print | xargs grep -il 'sound' | xargs -I {} sh -c ">{}"

Per usual, I get it minutes after posting a question.

Think it helps sometimes to just spell it out (literally)...

share|improve this answer
add comment

Try it with the : > filename noop.

But would it not make more sense to remove the bad .htaccess files rather than zero them?

share|improve this answer
    
Maybe... they're there as a result of other apps (joomla, etc; hence the hacked htaccess). Interestingly, the original htaccess files seem to be intact in the directory in other forms (e.g. htaccess.txt). Right now, just want them 0'd. Also, I took out the php exec($_GET) backdoor that they were using, so for now... –  stormdrain Aug 23 '12 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.