Lost in .NET Code

Developing software in .NET, Security and other ramblings.

SQL Injections ASP

Tuesday, November 4, 2008

http://blogs.technet.com/neilcar/archive/2008/10/31/sql-injection-hijinks.aspx

Neil Capenter shows another example of why ASP and using Black list is a really bad idea.

This is really interesting because it shows
"ASP drops a percent sign from the query string if it isn't followed by two valid hex characters(0-9, A-F) when it actually interprets it via Request.QueryString. "

Neil proves this in a test page it shows that the earlier attacks are again being updated to go past filters. If companies have patched a fix over this type of hole then they will be facing a more complete attack soon.

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1697

The new version of URL scan specifically checks for this and is worth having in your toolkit.

Labels: ,

Sql Injection Prevention Articles

Monday, July 21, 2008

SQL Injection prevention in ASP
http://msdn.microsoft.com/en-us/library/cc676512.aspx

SQL Injection prevention in ASP.Net
http://msdn.microsoft.com/en-us/library/ms998271.aspx

Both excellent articles on preventing SQL injection.

Labels: , ,

Scrawlr announcement - Microsoft / HP Collaborate on SQL Injection tool

Wednesday, June 25, 2008

https://download.spidynamics.com/Products/scrawlr/

Well worth downloading and running it is free and certainly a great tool to start testing for SQL injections on a website.

Labels: , ,

Classic ASP Functions for preventing SQL Injections

Tuesday, June 10, 2008

The big rule of doing any CRUD data jobs in any ASP/ASP.NET app with SQL Server is that you MUST use parameterized queries.

http://msdn.microsoft.com/en-us/library/cc676512.aspx

The article above though also outlines using Regular expressions to protect your web app by validating data before passing it through.

Below are some example functions for testing for int and removing anything other than int information from a string. Both provide a first basic layer to stopping SQL injection attacks in classic ASP, as lot of web apps use int as a key field in a in a database, hence it gets passed through with a querystrings. Hopefully these will prove useful to someone else.

function IsInt(strOriginalString)
dim objRegExp : set objRegExp = new RegExp
with objRegExp
.Pattern = "^\d+$"
.IgnoreCase = True
.Global = True
end with

IsInt = objRegExp.test(strOriginalString)
set objRegExp = nothing
end Function

function OnlyInt(strOriginalString)
Dim regEx, Match, Matches,returnString ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = "\d+" ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strOriginalString) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
returnString = returnString & Match.Value
Next
OnlyInt = returnString
end Function

Labels: ,

"Response Buffer Limit Exceeded" ASP Solution to having to sending a large file

Thursday, April 12, 2007

So lately I have been working in old skool ASP. I hit the problem of sending a large exe file to a client the file size was 30 Meg. A couple of searches all turned to this page.

http://www.fogcreek.com/FogBugz/KB/errors/ResponseBufferLimitExceed.html

So I phoned my hosting company.. who promptly said no to my request to change the AspBufferingLimit . Not suprising this is the limit that stops a infinite loop from consuming the server.

So a few more google pages later and bit of hacking I have hopefully a working solution togther.

Hopefully this might be useful for someone in the future.



Response.AddHeader "Content-Disposition", "attachment; filename=mylargedownload.exe"
Response.AddHeader "Content-Transfer-Encoding","binary"
Response.ContentType = "application/octet-stream"
Const adTypeBinary = 1
Dim strFilePath
strFilePath = Server.Mappath("/download/mylargedownload.exe")
'This is the path to the file on disk.
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
'1 MB
clChunkSize = 1048576
Dim i
For i = 0 To objStream.Size \ clChunkSize
Response.BinaryWrite objStream.Read(clChunkSize)
Response.Flush
Next
objStream.close
Set objStream = Nothing

Labels:


Subscribe in a reader


Blogs I read

Tristan Phillips
Sarah Blow (.Net Mobile)
Mike Taulty (MS DPE)
Ian Griffths (WPF)
Jack Greenfield


Useful Links

Fircroft Trust Ltd
Unwind Software Ltd


Archives

December 2006   January 2007   February 2007   March 2007   April 2007   May 2007   June 2007   October 2007   November 2007   February 2008   April 2008   May 2008   June 2008   July 2008   August 2008   October 2008   November 2008   December 2008   January 2009  


Fun and Games



 

This page is powered by Blogger. Isn't yours?