Post

SQL Injection — Pink CTF Web Challenge

Screenshot 1

I opened the provided link. The challenge title says “SQL Injection”. So, basically I know that I have to inject malicious SQL queries. I tried with simple bypass payload like admin’; —, admin”; —. Here, I don’t have source code and I don’t know the application uses whether single quote or double quote. Those do not work.

Screenshot 2

I tried also other well-known payloads like ‘ or 1=1 —, ‘ or ‘1’=’1. Here, I don’t include ‘admin’ in payload because it may be admin user does not exist. So, whatever user exists, the payload does not care and it goes to 1=1 (alternatively true). But they do not work.

Next, I thought the reason why my payloads do not work. The source code may escape single quote and it does not execute malicious sql payload. I thought the escape character ‘\’ (%5c) adds to single quote (%27) and it escapes out. Thus, I wanted to try %bf at the start of payload. If I used %bf, it goes to %bf%5c%27. If the challenge source code uses SQL GBK encoding, the server url-decodes the payload and may read bf5c as GBK character. So, single quote (27) works. Then, I used burp to capture and intercept web request.

Screenshot 3

The payload is url-encoded version of ‘ or 1=1. I added “==” at the end and %bf at the start of payload.

Screenshot 4

It still does not work. May be the command marker ( — ) is not ok and I tried with another one (#).

Screenshot 5

PINK{0x5C_is_not_always_a_backslash}

I hope you will learn new thing from me. Happy Hacking !!

This post is licensed under CC BY 4.0 by the author.