security - Find and delete everything and between and including two strings with SSH? -


i struggling write ssh command searches every file on server contains

<!--4e530a--> ... malcious code ... <!--/4e530a-->

and deletes tags , javascript inside them.

also curious know how code seems regenerates itself.

firstly, if malicious code being "regenerated," have bigger problem on hands removing malicious code files. have been compromised through means , attacker has persistent access system, or has planted malware (possibly root-kit) molesting server. you need fix problem!

there thousands of possibilities here, easy ones check before call professional (you do need call pro, more info can provide cheaper be), new user accounts, unusual user account activity, failed login attempts, unusual traffic loads/patterns, etc.

as actual question, use find feed files grep, , grep search files. this:

grep --color --line-number "malicious code" $(echo $(eval find / -type f))

if have ton of files on system, may run "too many args" problem. if happens you'll have creative script or else run on subdirectories. if want can use script wrote on github called "findref.sh". script make you're trying easy , compensates "too many args" problem , grep.

as deleting contents, pretty tough (but possible) automagically bash/ssh. may want write python or perl script , scp over, kick off through ssh. careful using scripts modify code, if it's production code.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -