webhacking.kr - 0ldzombie challenge writeup 7
0ldzombie has a great collection of Webhacking challenges
which ranges from very basic ones to some very advanced attacks. We really enjoyed playing the challenges and here are the writeups.
So here we are, at level 7. One defect with this challenge site is that since this is not in the increasing order of difficulty, we cannot say that challenges will get more difficult as we crack more since that is how usual challenge sites works!
I am putting up the write up so that if you are not able to complete the challenges after trying for awhile, you can refer to the solution to see how I did it. Please don’t look into the solution before you try out the challenges by yourself.
Now let us look into challenge 7. In the source file, you can immediately understand that the challenge is to inject SQL !
You can see clearly see that some common keywords from SQL are filtered and if we use the same, we get the message
Access Denied. But to my surprise the most used keywords in SQL, ie,
union where not filtered. Also from the source code, we can successfully login as admin only if we get the value 2. So we simply have to select the value 2. But the main problem here was that spaces are filtered. Without spaces, its difficult to craft a correct query. So I just looked into some filter evading techniques and I came to know that un-printable characters will be taken as spaces in MYSQL.
So where ever I need space, I used
%0a and this leads to a successful bypass. The payload looks like this:
You might have to refresh the injection several times since this payload will work only if the rand value selected is 1. If you are lucky enough, you will get it at the first shot ;). Hope this helps !