1

After an exploit on an ASP.NET site, the client was left with a specific string of malware code sprayed across the entire database, multiple columns of multiple tables. The prepended string is consistent and doesn't change from table to table, so theoretically if I could just do a search-and-replace across the whole database, this could be cleared up in a single operation.

I could do this fairly easily in PostgreSQL or MySQL doing something like this:

mysqldump bad_db | sed 's/evilcode//g' | mysql fixed_db

But how would you do such a thing with SQLServer? I'm not certain it's quite so simple under Windows.

tylerl
  • 14,885
  • 7
  • 49
  • 71

1 Answers1

1

The problem that you are going to run into is that the database backup file is binary not plain text like a MySQL dump. Here is a link to a blog post that I wrote a while back that'll scrub the varchar and nvarchar fields. There's no code on it for text and ntext, but this'll probably clean up most of it. Text and Ntext are harder as you can't use things like substring on them.

mrdenny
  • 27,074
  • 4
  • 40
  • 68