Thanks for the comments. In fact, this reveals much more like a matter of faith than reason. I agree that if there is a solution that is consensus, maybe itīs not necessary to explore alternatives that may pay their price for the heresy.
But, for we to continue our challenge of investigating if such a simple approach can wipe away the Sql injection fear, let me go on with the polemic. Please donīt take me bad, this can be a challenge for us. Even if is to prove that in fact, the consensus is right - but then weīll at least tried to be heretic!
As Aimi pointed, what if we had this:
The move Aimi suggested is: a backslashed backslash is printed literally in the sql and cancels the backslash my code uses to cancel the backslashed single quote. Wow, īthis is becoming philosophy!$input = "\\'"; # these two backslashes will print a single backslash +in the SQL, but, as I will add one backslash before the single quote, + the result there will be just the same as you can see here.
In fact, cancels. But Iīve been thinking and, no problem. Hereīs the messy solution the backslash trick will put our cracker into. Remember our query:
...wich was cracked by entering this:select username, password from users where sid='$input';
Now, heīd enter:5' or 1='1
...resulting in:(extra spaces to see clearly)5\\' or 1=\\'1
Can you see the problem? The first semicolon (in the variable being interpolated), ok, heīs out there, as the backslash before him lost itīs canceling power, canceled by the backslash before her. The second single quote is out there too, free by the same method. But, and hereīs the point, the second pair of backslash sql has screwed completely any chance of doing any valid sql statement!...where sid=' 5\\' or 1=\\'1 ';
With the first pair the mess is not a problem, as our "5" or whatever is a value that wonīt match anyway. But with the or 1='1 we really needed silence of mess! And now there is a \\ in the middle of the attempt to compose alternative permissive code!
As we have a '; waiting to be matched at the end of the query statement (see after $input), I canīt see any way of delivering any clean syntax that has a \\ in the middle. Any query you may think would have do end as something=' or something<' or something>' or something like ' or any operator, but the end must be a value wich delimitation cleanly started with a single quote. And, about that, we now know, this single quote can be there, but not without his happy new companion \\. Please, find any hack for this if you can.
André
In reply to Re^2: SQL Injection myths under DBI
by Andre_br
in thread SQL Injection myths under DBI?
by Andre_br
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |