Advertisement

05.17.2008 at 02:36PM PDT, ID: 23411125
[x]
Attachment Details

Cleaning Up SQL Injection Attack - http://www.banner82.com/b.js script

Asked by coloradodude in Networking Security Vulnerabilities, MS SQL Server, SQL Server 2005

Tags: ASP, SQL, MS SQL 2005, www.bestaviation.net & aviationcareerguide.com

I have fallen victim to what appears to be a nefarious SQL Injection attack.  My system is an old ASP applicaiton that requires some protection updates. However I need to clean the database to remove the following text:
<script src=http://www.banner82.com/b.js></script>

This text has been appended to every column that contains Character or Text data. Becuase it has infected ntext and Text fields as well as varchars  I can not use the replace function. So I need something else.

I have modified Narayana Vyas Kondreddi's Search Code to update records that
The following update statement is the one that is not working... Any help woudl be greatly appreciated:

 UPDATE  VendorProducts SET @ColumnName= SUBSTRING(@ColumnName , 0,PATINDEX(@SearchStr2 , @ColumnName)-1)
                         WHERE PATINDEX(@SearchStr2, @ColumnName) > 0

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
CREATE PROC SearchTableStrReplaceg
(
     @SearchStr nvarchar(100),
     @TableStr nvarchar(100)
 
)
AS
BEGIN
 
     -- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
     -- Purpose: To search all columns of all tables for a given search string
     -- Written by: Narayana Vyas Kondreddi
     -- Site: http://vyaskn.tripod.com
     -- Tested on: SQL Server 7.0 and SQL Server 2000
     -- Date modified: 28th July 2002 22:50 GMT
 
 
     CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
 
     SET NOCOUNT ON
 
     DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110), @fieldlen integer
     SET  @TableName = ''
     SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
     SET @fieldlen =LEN(@SearchStr2)
     WHILE @TableName IS NOT NULL
     BEGIN
          SET @ColumnName = ''
          SET @TableName = 
          (
               SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
               FROM      INFORMATION_SCHEMA.TABLES
               WHERE           TABLE_TYPE = 'BASE TABLE' and TABLE_NAME = @TableStr
                    AND     QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                    AND     OBJECTPROPERTY(
                              OBJECT_ID(
                                   QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                                    ), 'IsMSShipped'
                                     ) = 0
          )
 
          WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
          BEGIN
               SET @ColumnName =
               (
                    SELECT MIN(QUOTENAME(COLUMN_NAME))
                    FROM      INFORMATION_SCHEMA.COLUMNS
                    WHERE           TABLE_SCHEMA     = PARSENAME(@TableName, 2)
                         AND     TABLE_NAME     = PARSENAME(@TableName, 1)
                         AND     DATA_TYPE IN ('text', 'ntext')
                         AND     QUOTENAME(COLUMN_NAME) > @ColumnName
               )
     
               IF @ColumnName IS NOT NULL
               BEGIN
                         UPDATE  VendorProducts SET @ColumnName= SUBSTRING(@ColumnName , 0,PATINDEX(@SearchStr2 , @ColumnName)-1)
                         WHERE PATINDEX(@SearchStr2, @ColumnName) > 0
               END
          END     
     END
 
     SELECT ColumnName, ColumnValue FROM #Results
END
[+][-]05.17.2008 at 02:46PM PDT, ID: 21590853

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 02:59PM PDT, ID: 21590873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:08AM PDT, ID: 21592403

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 10:30AM PDT, ID: 21593357

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 11:30AM PDT, ID: 21593525

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Networking Security Vulnerabilities, MS SQL Server, SQL Server 2005
Tags: ASP, SQL, MS SQL 2005, www.bestaviation.net & aviationcareerguide.com
Sign Up Now!
Solution Provided By: hibridassassin
Participating Experts: 15
Solution Grade: A
 
 
[+][-]05.18.2008 at 06:40PM PDT, ID: 21594800

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 09:14PM PDT, ID: 21595193

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 06:27AM PDT, ID: 21597541

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 08:48AM PDT, ID: 21598809

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 08:49AM PDT, ID: 21598817

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 12:37PM PDT, ID: 21600839

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 04:54AM PDT, ID: 21614020

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:49AM PDT, ID: 21616275

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:58AM PDT, ID: 21616362

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 11:23AM PDT, ID: 21617632

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 08:12AM PDT, ID: 21624523

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 06:17AM PDT, ID: 21631806

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 06:21AM PDT, ID: 21631830

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 06:25AM PDT, ID: 21631852

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208