Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0 support forum
 Helicon Tech : ISAPI_Rewrite 3.0 support forum
Subject Topic: SQL Injection Attack Redirect Rule Syntax Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Pedge99
Newbie
Newbie


Joined: 25 August 2008
Location: United States
Online Status: Offline
Posts: 3
Posted: 25 August 2008 at 11:52am | IP Logged Quote Pedge99

I am new to ISAPI_Rewrite and have very limited coding experience. I am trying to write a rule to redirect a SQL Injection attack. The attacking code uses the following url patterns:

According to the IIS log:
(1) GET /overview.aspx ;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST 0x4445434 (shortened)
(2) GET /overview.aspx ';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434 (shortened)

According to the ISAPI_Rewrite.log:
(1)init rewrite engine with requested uri /overview.aspx?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434 (shortened)
(2)init rewrite engine with requested uri /overview.aspx?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434 (shortened)
Note that ISAPI_Rewrite displays the space after overview.aspx as ?.

The Rewrite Rule I'm currently using is:
RewriteRule .*DECLARE.* http://www.mydomain.com/badpage.html [I,R]

If I paste the The above RewriteRule and url format of GET /overview.aspx ;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST 0x4445434 (shortened)
into the Regextest it returns a match and if I test it in my browser it executes the url redirect.

However, based on the Rewrite.log, it appears that ISAPI_Rewrite converts or displays the space after the .aspx to ? and then doesn't recognize or check the query that follows, including the DECLARE statement based on the above rule.

Can someone give me a rewrite rule syntax that will redirect these sql injection attempts and explain how to have it evaluate the query portion following the .aspx?

Thanks in advance for your help.



Edited by Pedge99 - 25 August 2008 at 11:55am
Back to Top View Pedge99's Profile Search for other posts by Pedge99
 
Pedge99
Newbie
Newbie


Joined: 25 August 2008
Location: United States
Online Status: Offline
Posts: 3
Posted: 25 August 2008 at 9:57pm | IP Logged Quote Pedge99

I came across the following RewriteRule that has done the job:

RewriteCond %{QUERY_STRING} .*DECLARE.*
RewriteRule ^(.*)$ http://www.cybercrime.gov/ [nc,L]

It appears that a Rewrite Condition to evaluate the entire query was needed to get past the ?. Anyway its working well now. Any additional comments or suggestions are still welcome.

Back to Top View Pedge99's Profile Search for other posts by Pedge99
 
Vyacheslav
Moderator Group
Moderator Group


Joined: 02 July 2008
Location: Ukraine
Online Status: Offline
Posts: 673
Posted: 26 August 2008 at 9:27am | IP Logged Quote Vyacheslav

Hi.
Sorry for late reply.
Please try these rules:
Code:
RewriteCond %{QUERY_STRING} ^.*DECLARE.*$ [NC]
RewriteRule ^(.*)$ http://www.cybercrime.gov/$1 [NC,L]


__________________
Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
Back to Top View Vyacheslav's Profile Search for other posts by Vyacheslav Visit Vyacheslav's Homepage
 
Anson
Newbie
Newbie


Joined: 30 April 2008
Online Status: Offline
Posts: 2
Posted: 26 August 2008 at 4:35pm | IP Logged Quote Anson

Hi,

That attack is pretty sick.  I have a similar rewrite condition.

RewriteCond %{QUERY_STRING} (?:union%20|select%20|insert%20|declare%20|drop%20|update%20|benchmark%20|sp_password%20|%3b|char\(|'%22) [NC]


Back to Top View Anson's Profile Search for other posts by Anson
 
Pedge99
Newbie
Newbie


Joined: 25 August 2008
Location: United States
Online Status: Offline
Posts: 3
Posted: 26 August 2008 at 6:20pm | IP Logged Quote Pedge99

Vyacheslav and Anson,

Thanks for your posts. ISAPI_Rewrite has proven to be a life saver. We had been infected 3 times but are now successfully blocking the attacks while fixing our programming vulnerablilities. 

Has anyone written a "Coding ISAPI_Rewrite for Dummies". I'd like to get a hold of a basic coding tutorial with lots of examples.

Back to Top View Pedge99's Profile Search for other posts by Pedge99
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4701
Posted: 27 August 2008 at 4:42am | IP Logged Quote Anton

Here's our documentation http://www.helicontech.com/isapi_rewrite/doc/ with examples http://www.helicontech.com/isapi_rewrite/doc/examples.htm
And we are now working on FAQ chapter.


__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
mamin123
Newbie
Newbie


Joined: 27 August 2008
Online Status: Offline
Posts: 16
Posted: 01 September 2008 at 5:21pm | IP Logged Quote mamin123

I think HELOCONTECH should write comprehensive Rule to prevent SQL injection and place it on their example URL so people can use it. This will be worthwhile for every one to use it
Back to Top View mamin123's Profile Search for other posts by mamin123
 
Vyacheslav
Moderator Group
Moderator Group


Joined: 02 July 2008
Location: Ukraine
Online Status: Offline
Posts: 673
Posted: 02 September 2008 at 7:16am | IP Logged Quote Vyacheslav

mamin123 wrote:
I think HELOCONTECH should write comprehensive Rule to prevent SQL injection and place it on their example URL so people can use it. This will be worthwhile for every one to use it


Ok. Now we working over documentation. We will add some articles about SQL-injection, using ISAPI_Rewrite with the popular CMS etc.

Many thanks for your message!

__________________
Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
Back to Top View Vyacheslav's Profile Search for other posts by Vyacheslav Visit Vyacheslav's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum