Search code examples
mysqlsqlsql-injection

SQL Injection on BadStore


I'm trying to excercise on BadStore, for those who don't know it's a fake online store site which can be run on VM box, and offers a lot of security vulnerabilities.
One thing i'm trying to do is to apply sql injection on the search query. When searching for "book", for instance, we see this:

enter image description here

So, i'm trying to show all the store items trying to search for 1=1' --, which will result with the query of:

SELECT itemnum, sdesc, ldesc, price FROM itemdb WHERE '1=1' --' IN (itemnum,sdesc,ldesc)

however, this not giving the expected outcome as I get the following error: enter image description here

Any suggestions?


Solution

  • You realize that -- in MySQL acts as a comment for the rest of the line?

    If this is what you are trying to do, commenting out the rest of the line, then as per the MySQL documentation, you need a space after the --.

    I understand you are trying out MySQL injection, so try to type your query, and then after the query type ; -- Notice that there IS a trailing space.

    TL;DR

    Change

    '1=1' --' IN
    

    TO

    '1=1' -- ' IN