Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
possible SQL injection attack
Old 07-22-2007, 08:41 PM possible SQL injection attack
sandbox's Avatar
Extreme Talker

Posts: 153
Trades: 0
I noticed something odd in my referral data the other day, let me explain:
I have a page that displayes webpages dynamicly from a database like this - www.mysite.com/page.asp?name=255

Each record in my database has a unique variable so the correct page is displayed, the above example is "255" my referral script picks up this data so I know which page has been visited and by which URL. (so whatever someone has typed after the = shows up. OK so I noticed someone had typed this:
www.mysite.com/page.asp?name=0 and ''=''>218' and user>0 and ''='

can anyone tell me what this individual is trying to do? is it a sql injection attack?

My site is not that well coded and any advice about improving security would be much appreciated.
__________________
¦
Please login or register to view this content. Registration is FREE
s ¦
Please login or register to view this content. Registration is FREE
¦
Please login or register to view this content. Registration is FREE
sandbox is offline
Reply With Quote
View Public Profile Visit sandbox's homepage!
 
 
Register now for full access!
Old 07-22-2007, 09:39 PM Re: possible SQL injection attack
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Yep, that's exactly what an SQL injection attack is.
As for improving security, it's a so large field (and almost 4 am here) that I'm sorry to say that either someone else will give you advices, or I'll do later tomorrow...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 07-24-2007, 03:43 PM Re: possible SQL injection attack
sandbox's Avatar
Extreme Talker

Posts: 153
Trades: 0
Thanks for that Tripy, I was wondering what exactly the are trying to do? I keep the content for my website on a database which is readily viewable by anyone who cares to click through my site. I don't keep ANYTHING important on a online database.
__________________
¦
Please login or register to view this content. Registration is FREE
s ¦
Please login or register to view this content. Registration is FREE
¦
Please login or register to view this content. Registration is FREE
sandbox is offline
Reply With Quote
View Public Profile Visit sandbox's homepage!
 
Old 07-24-2007, 04:02 PM Re: possible SQL injection attack
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Maybe they want credit card numbers you might have, or maybe they want to put something malicious in your database.

This is why MySQL sucks. All versions below 5.02 are begging for SQL Injection.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 07-25-2007, 11:05 AM Re: possible SQL injection attack
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
This is why MySQL sucks.

Bad workmen blame the tools.

If you do not know what your doing the perhaps you should not be doing it or you should bheusing something more developer friendly.

If you scrutinize any input (especially if its going to your DB) then you can catch it and make it friendly.

I find the PDO php-mysql API rather good at using the bindParam to get out of jail nicely however you can do it yourself by simply adding quotes to the input.

Even a simple addslashes would turn
www.mysite.com/page.asp?name=0 and ''=''>218' and user>0 and ''='

into
www.mysite.com/page.asp?name=0 and \'\'=\'\'>218\' and user>0 and \'\'=\'

rendering it rather useless for its purpose.

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf

Last edited by ibbo; 07-25-2007 at 11:07 AM..
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 07-25-2007, 12:28 PM Re: possible SQL injection attack
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by ibbo View Post
This is why MySQL sucks.

Bad workmen blame the tools.
Bad workmen choose bad tools.

Quote:
Originally Posted by ibbo View Post
If you scrutinize any input (especially if its going to your DB) then you can catch it and make it friendly.
The type you spend writing code to scrutinize any and all user input (not a small task) adds no value to your clients, it's just plumbing. Choosing a tool that forces you to spend a great deal of time doing something that adds no value to the project when you could simply choose proper tools from the start is the mark of the bad workmen you're bringing up.

There are many situations where some characters like ' or - are valid and appropriate. You can't just block any input of them, O'Leary, in-the-woods, so your "scrutinize user input" module either has to be very smart, or still leaves holes open.

On the other hand, when you can just save and precompile the SQL in the database and pass only parameter values who can't change the meaning of the SQL code, all of a sudden you don't have to spend weeks writing code to scrutinize your user input, you can just let your data rules govern what's acceptable. And charge your client a fair price, instead of charging them to buy a screw driver and forge a hammer out of it.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 07-26-2007, 01:24 AM Re: possible SQL injection attack
Extreme Talker

Posts: 238
Location: United States
Trades: 0
Quote:
Originally Posted by Learning Newbie View Post
This is why MySQL sucks. All versions below 5.02 are begging for SQL Injection.
It is very easy to sanitize values for MySQL queries. Only negligence or ignorance would leave room for SQL injection, and I don't think those are good enough reasons to say that anything sucks.
frost is offline
Reply With Quote
View Public Profile
 
Old 07-26-2007, 08:30 AM Re: possible SQL injection attack
Ultra Talker

Posts: 483
Trades: 0
Quote:
Originally Posted by frost View Post
It is very easy to sanitize values for MySQL queries. Only negligence or ignorance would leave room for SQL injection, and I don't think those are good enough reasons to say that anything sucks.
Exactly. On top of that, MySQL 5.02 didn't do anything magical to stop SQL injection. Now if you want to talk about the PHP interface to MySQL then maybe he has a point but even then, there's nothing that requires the coder to use parameters and so on, right?
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to possible SQL injection attack
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.53886 seconds with 12 queries