1

So I am basically learning SQL injection because I want to be a pen tester. Here is an example of a query I'm running on localhost/phpmyadmin

SELECT *
FROM ipstealer as ipstr
WHERE 'id' = 9
union select 1,2,3,4,5
ORDER BY
ipstr.id ASC
LIMIT 0 , 30

Where I can inject after WHERE ID = $inputhere

So basically, the query works fine if I do this:

SELECT *
FROM ipstealer
WHERE 'id' = 9
union select 1,2,3,4,5
ORDER BY
id ASC
LIMIT 0 , 30

But I want to inject it using aliases ipstr. So my question is, how can I fix this problem with the injection so that it works as wanted in the first query? I can't figure out how to do this only using one query. I've logically tried something like so:

    SELECT *
    FROM ipstealer as ipstr
    WHERE 'id' = 9
    union select 1,2,3,4,5 as ipstr
    ORDER BY
    ipstr.id ASC
    LIMIT 0 , 30

But I get the same error: #1054 - Unknown column 'ipstr.id' in 'order clause'

Jason
  • 1,297
  • 12
  • 24
  • to know more about sql injection, visi this link: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – John Woo Aug 28 '13 at 00:39

0 Answers0