Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request.form checking and binaryread

Status
Not open for further replies.

josver

Programmer
Aug 6, 2008
5
DE
Hi,

I have an ASP / VB6 web application, basically a CMS generating web sites with a lot of classic ASP pages and a VB6 COM component.

Recently our servers (like everyone else's) are under so called cross site script attacks, meaning that the attacker tries to gain entry by passing malicious code in the request object (request.querystring and request.form)

Luckily all ASP pages first call an initial function in a VB COM component before doing anything else and pass their request object for use by the com component.

Since this is the ideal place to test for script hacks (invalid malicious request.querystring and request.form strings) I coded a "checkforhack" function.

On the .querystring side there is no problem, but on the .form side, some of the appplication and / or web site forms are standard text forms and some are upload forms with binary data.
I cannot test binary forms for hack attempts (I'll have to do that in a function handling upload, of which there is only one), but I can test standard forms for malicious strings.

My question is this:

Is there a test to detect which type of form I am dealing with, without provoking the message "cannot call binary read after using the forms collection" ?
In other words, can I detect in the request object whether this is a normal text form or a binary data form WITHOUT using the forms colection (which provokes the error)

I cannot use request.TotalBytes, since that is set on standard forms too to a nonzero value, I tried using request.form.count, since that seems to be 0 on binary forms, but then of course I get the infamous message when the form is processed since I use the forms collection.

I would like to acess something like the enctype of the form, since that is set in binary forms to enctype="multipart/form-data"

Our servers are under heavy attack right now, and I would like to close this potential hole, so any suggestions are VERY welcome

Jos Verhoeff
 
In case anyone has this problem, I found the solution in the request.servervariables("CONTENT-TYPE") variable:

Private Function GetFormEncType()
Dim sContType, hCutOff

sContType = request.servervariables("CONTENT_TYPE")
hCutOff = InStr(sContType, ";")
If hCutOff > 0 Then
sContType = UCase(Trim(Left(sContType, hCutOff - 1)))
Else
sContType = UCase(Trim(sContType))
End If
GetFormEncType = sContType
End Function



If UCase(request.servervariables("REQUEST_METHOD"))="POST" then
If UCase(GetFormEncType) = "MULTIPART/FORM-DATA" Then
end if
end if

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top