> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/web-exploitation/sql-map-1.md).

# SQL Map 1

first we register a random account and try a classic SQL injection on the login form. using the well-known payload `' OR 1=1 --` immediately bypasses authentication and logs us in. once inside, we notice multiple fake flags being displayed, which is a strong hint that simple bypass isn’t the intended final step.

<img src="https://github.com/user-attachments/assets/6d799a91-acda-4e90-9be4-8ae3172ff4ec" alt="image" height="729" width="1010">

since the app is clearly vulnerable to SQLi, we move to data extraction. instead of just bypassing login, we use a UNION-based payload to dump credentials from the database:

`' UNION SELECT 1, GROUP_CONCAT(username || ': ' || password) FROM users --`

this works because the query structure allows us to align columns and concatenate all usernames and password hashes into a single output. the response gives us a full list of users along with their hashed passwords:

`ctf-player: 7a67ab5872843b22b5e14511867c4e43, noaccess: 83806b490e28a7f8e6662646cbdbff1a, suspicious: eb1f3ba6901c65d9b2e09a38f560758b, malicious: a669d60c31ad3d05b9e453c8576c7aab, ghost: 8d2379c40704bed972e55680be2355e2, admin: 5a9a79d9fa477ed163b89088681672c9, a: 0cc175b9c0f1b6a831c399e269772661`

along with this, the application still throws multiple fake flags to distract us, confirming that the real path involves these hashes.

at this point, the goal is to crack one of the hashes. the hash for `ctf-player` is:

`7a67ab5872843b22b5e14511867c4e43`

after cracking it (using any standard wordlist or online hash cracker), we obtain the plaintext password. with these valid credentials, we log in normally instead of using SQL injection.

once logged in as `ctf-player`, we gain access to the protected area, where the real flag is finally revealed:

`picoCTF{F0uNd_s3cr3T_K3y_f0R_w3_<>}`

this challenge demonstrates that while basic SQL injection can give access, deeper exploitation like database dumping and hash cracking is required to reach the actual flag.
