Bob
Sat Jul 19 09:26:50 CDT 2008
Well, your validation is missing something. We can't really tell what it is
missing without seeing what's in your logs.
When the redirection does not occur, are you using parameters so that they
don't do any damage?
PS. I hope you've coded that e.asp page to load r-e-e-e-a-a-a-l-l-y slowly
... with client-side "please wait" messages to make the hacker think your
site is just experiencing a temporary slowdown ....
Maybe even an infinite progress bar to make him think something is really
happening ...
:-)
shank wrote:
> Per your help below, I'm using the following include on any page that
> has a connection to the database. It's stopped 99% of the attacks. I can
> see this in the logs. However, one page in particular gets pounded a lot.
> And
> it appears, on a hit and miss basis, if the bad guys hit the site
> multiple times consecutively, once every so often it does not get
> redirected
> to the error page. That shows in the logs as well. How can I stop that?
>
> <%
> dim key, keyval
> for each key in Request.QueryString
> keyval = Request.Querystring(key)
> if instr(keyval,"DECLARE") > 0 or instr(keyval,"VARCHAR") > 0 or
> instr(keyval,"CAST") > 0 or instr(keyval,"EXEC") > 0 or
> instr(keyval,"@") > 0 or instr(keyval,";") > 0 or instr(keyval,"--")
> > 0 then Response.Redirect ("e.asp?msg=go away")
> exit for
> end if
> next
> %>
>
> thanks
> ================================
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:u8MrtWp4IHA.4352@TK2MSFTNGP05.phx.gbl...
>> shank wrote:
>>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>>> news:%23tXxDoo4IHA.4916@TK2MSFTNGP06.phx.gbl...
>>>> shank wrote:
>>>>> I've been hit again using DW, parameterized queries and stored
>>>>> procedures. I'm guessing I was not strict enough with character
>>>>> counts and allowing to long of a string to pass.
>>>>>
>>>>> Aside from that, as crude as it may be, is the below enough to
>>>>> stop these attacks? If not, how would they get around this?
>>>>>
>>>>> <%
>>>>> If Instr(Request.QueryString("http")) > 1 or
>>>>> Instr(Request.QueryString("script")) > 1 Then
>>>>> Response.Redirect ("e.asp?msg=go away")
>>>>> End If
>>>>> %>
>>
>>
>> OK, these Instr calls don't seem to be properly formatted. I beleive
>> they should be throwing an error. Are you masking the error using on
>> error
>> resume next?
>> Anyways, Instr should take at least two arguments: the string to be
>> searched, and the string to search for. You are only supplying a
>> single argument to each call.
>> For another thing: your querystring does not have items called
>> "http" or "script" so of course, this routine will never find any
>> problems ... Try this:
>>
>> dim key, keyval
>> for each key in Request.QueryString
>> keyval = Request.Querystring(key)
>> if instr(keyval,"http") > 0 or instr(keyval,"script") > 0 then
>> Response.Redirect ("e.asp?msg=go away")
>> exit for
>> end if
>> next
>> <snip>
>>> This was in my IIS logs... I assumed the script was passed through
>>> the query string
>>>
>>> 2008-07-10 03:47:40 GET /sr.asp
>>> title=In%20My%20Next%20Life&artist=Terri%20Clark&type=%25&category=%25&manuf=%25&status=av&column=title_asc<script%20src=
http://www.xxxxx.mobi/ngg.js></script>
>>> 80 - 75.88.150.195
>>>
>>
>>
>> When you say you've been "hit" do you mean the strings in those
>> querystrings made it to the pages you were serving to your clients?
>> What I'm seeing here is not really sql injection per se, since it does
>> not
>> involve injecting sql commands for your database to execute without
>> your knowledge, it's more like "script injection". Which means you are
>> not
>> being careful to use Server.HTMLEncode when writing data passed from
>> users to Response. So yes, validate as I showed above, but don't assume
>> you have figured out every way for hackers to sneak this crap by you:
>> don't
>> write user-supplied data directly to Response. Encode it so it does not
>> get
>> executed by the client.
>>
>>
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so
>> I don't check it very often. If you must reply off-line, then remove
>> the "NO SPAM"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"