0

I am trying to write a website with Django that could display SQL injection for classroom purposes.However when i try to exploit the query nothing is getting returned. I am using a MYSQL database

peopledata = people.objects.raw("select * from people where name = \"%s\" "%input
result = list(peopledata)

I tried using "; show tables; -- and "; --, in the input field and nothing showed up. Is there a way to display the exploited data?

7
  • 1
    Try " and 1 = 1; -- Commented Jun 14, 2013 at 17:04
  • @climbage Thanks. I am getting <RawQuerySet u'select * from people where name ="" and 1=1; --";'>. When i return result i am getting an empty list [] Commented Jun 14, 2013 at 17:09
  • Oops I'm sorry, I meant to say OR 1=1. " or 1 = 1; -- Commented Jun 14, 2013 at 17:10
  • Still getting the <RawQuerySet> and not returning the data in the table. Commented Jun 14, 2013 at 17:11
  • Could be that ; isn't allowed in the statement. Try getting rid of that Commented Jun 14, 2013 at 17:12

1 Answer 1

0

Your input should be any_name OR'x'='x' or any_name OR name IS NOT NULL

The first input would guarantee the clause to be true no matter what the first clause is.

The second query will then return every record in the database, instead of returning the name you searched for. This is demonstrates a big security risk. If the data being returned is confidential (id SSN) the user has now received access to data he/she should not be viewing.

Another example would be:

any_name; DROP TABLE people; --

And:

any_name; INSERT INTO people('email','passwd','login_id','full_name') 
        VALUES ('[email protected]','hello','steve','Steve LastName'); --

NOTE: Apply these queries appropriately to your DB. Using single/double quotes when necessary etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.