Background information: SQL Injection as a school task. Login bypass. Given two input fields name and password. Confirm via solve button.
Info on what I have and was able to find out:
- it is obviously vulnerable being a task to log in into a system, while having forgotten the password (classic form with to input fields: name:
INPUT
, password:INPUT
) - a hint is provided that my Login-ID for the tasks page is always being accepted, therefore only the password should be missing (form: name: "my ID", password: INPUT (?))
- the server runs/emulates MySQL, I found this due to errors I received while trying different inputs (e.g. "' OR 1=1"-Tricks, Union-Commands, Outcommenting, etc.):
- -> the structure is showed through MySQL syntax errors:
SELECT name,password FROM login WHERE name='xyz' and password='xyz'
- -> Union-commands work due to e.g. column number errors
- Magic quotes are off (?) or I wouldn't be able to evoke SQL-commands, I guess
- Using GBK characters to bypass the manipulation through ' didn't work either, it seems like they are not being recognized
- No PHP code available
- Server returns 'task solved' when the login is successful
Question: What possibilities are left for me to try in order to finally log into the system successfully via sql injection?
Examples for inputs I tried:
name: myID
[which is the ID that the hint suggests]
password: ' OR '1'='1
- server returns 'wrong answer' (login not successful), no mysql errors
name: myID' OR '1'='1' --
password: whatever
- same result
name: myID' AND NOT ('1'='2
password: foo') AND name='myID' LIMIT 1 #
- same result
Errors for example, when:
name: myID' OR 1=1
password: whatever
- server returns 'wrong answer' (login not successful), results in syntax error, because input is put into
' '
(
s and `)'s to ignore just the password condition, but still keep the username condition.myId'; SELECT * FROM [USERS];--
. This doesn't always work, but is a good next move I think. The semicolon splits the command into two statements, allowing you to run arbitrary queries. If you end up being able to do this, you could also do something like inject (INSERT
) a new userId/password for you to use.