Blog Tools
Edit My Blog
RSS Feed RSS
About Me
Contact Me

< < Jun 2008 > >
S M T W T F S
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 26 27 28
29 30          
You are not signed in.
Sign in

Entries By Topic
·All Topics RSS
·Classic ASP RSS
·CSS RSS
·Databases RSS
·eBay/PayPal RSS
·General RSS
·Hardware RSS
·Web Security RSS
·Windows XP RSS

Search
 
Recent Entries
·Classic ASP Master Pages
·eBay encourage/force you to lose money on postage
·CAPCTHAs and alternatives
·Obtaining Image Properties in ASP Without a Component
·New Microsoft Hotmail good reason not to use Microsoft Explorer
·Why are most real estate agents so bad at selling online
·Classic ASP Title Case
·Does stopfax.com.au really stop junk faxes?
·SQL Injection Protection - b.js
·Unfair eBay fees for used cars

John's Technology Blog

SQL Injection Protection - b.js

Posted at: June 30, 2008
Related Topic(s): Classic ASP, Web Security

Click here for daily freebies, competitions, surveys and the best offers - OUTPOSTOFFERS.COM - Australia

There is a automated SQL injection attack doing the rounds at the moments which injects some html (<script src=http://www.domain.com/b.js></script>) into certain fields in all the tables in a database.

If you have been attacked don't feel bad as an Internet search of "b.js" reveals tens of thousands of hacked sites.

The attack cleverly appends a series of SQL commands onto your querystrings and if your code is unprotected, and you don't use Access databases, the commands may be passed on to your SQL server and the damage done.

Considering the damage that could be done by this sort of attack, I guess we are lucky that they chose only to append their little JavaScript.

However, this attack could render your website as "unsafe" in search engine results.

Reversing the Damage

We are also extremely fortunate that the changes can be easily reversed with a few changes of the attackers original SQL commands.

Simply execute the following to clean up the damage. If you have been attacked multiple times (ie. you have multiple script blocks appended to your SQL data) then you will need to execute the following script for each attack.

Protecting against attacks

There are many methods out there to protect against this sort of attack.

The best method is to ensure that you protect every value that you pass to SQL. Strings should have a function to replace single quotes with two single quotes. Numbers should have a function that forces them to a numeric value.

The following function is a simple method which removes multiple inline SQL commands. If you issue multiple inline SQL commands in one go then obviously it will not be suitable but for everyone else it should stop any attack. This will not protect against all types of attacks however.

Parse your SQL command strings with the following syntax:

SQLCheck(sql-string-here)


View Comments (1) | Add Comment | Permalink

Very useful scripts

Posted by Raja | July 14, 2008

Newer | Latest | Older

Free automotive classifieds, reviews, etc

Car and motorcycle books and repair manuals

ASP Hosting and Domain Names

For cheap asp and asp.net hosting I recommend CrystalTech, for cheap .com domains Cheeky Domains, or for .com.au domains Name Scout.

[Oztion is an Australian auction website which offers no listing fees]