Solved

How to detect and clean an SQL Injection

Posted on 2008-06-22
2
1,217 Views
Last Modified: 2008-10-27
Hi,

I believe that we have been hit with an SQL injection attack. At the top of our website page it has the following;

<script src=http://www.chinabnr.com/b.js></script>

Can you tell me how to detect and clean if this is the case.??

TIA

Lee
0
Comment
Question by:Lee025_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Expert Comment

by:patrikt
ID: 21844359
If it is realy comming from outside atack you have to fix all hole in your applications.
Every textbox without validataion can be hole to SQL if it is used insorrectly.
I can give you guiodelines for this but you have to do¨cleaning manualy.

As I know there is no automatic test tool, but somone may know about it.

Patrik
0
 
LVL 1

Accepted Solution

by:
rezen earned 500 total points
ID: 21849587
Same thing happened to me. Damn Chinese hackers!

What I did was run the SQL code here: http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/

This allowed me to generate a sql script that parses all my tables and erases all the the injected text in all character storing columns.

NOTE:
The code on the guy's site is not entirely working. I had to erase a smiley tag and fix the comments. Once it ran, it generated all the update statements needed. Make sure you tweak the code to replace the '<script...' with an empty string: ''
Also note that this does not clean NTEXT columns, which are affected by the SQL Injection. What I did was convert all my NTEXT columns to VARCHAR(MAX) [supported in SQL Server 2005].

Good luck, and don't forget to fix your vulnerabilities.
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
EF5 How do I stop pre-compiled views? 8 54
SQL 2012 Report Builder 3.0 query 2 25
Sorting a SQL script 5 41
Creating Scalar Function 3 19
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question