🌐 More SQLi
A detailed write-up of the Web challenge 'More SQLi' from PicoCTF - 2023
📊 Challenge Overview
Category Details Additional Info 🏆 Event PicoGym Event Link 🔰 Category Web 🌐 💎 Points Out of 500 total ⭐ Difficulty 🟡 Medium Personal Rating: 1/10 👤 Author Mubarak Mikail Profile 🎮 Solves (At the time of flag submission) 12.878 solve rate 📅 Date 11-02-2025 PicoGym 🦾 Solved By mH4ck3r0n3 Team:
📝 Challenge Information
Can you find the flag on this website.
🎯 Challenge Files & Infrastructure
Provided Files
1Files: None
🔍 Initial Analysis
First Steps
Initially, the website appears as follows:
Given the challenge description, I used the payload
'OR 1=1 --forusernameandpasswordto access the site, and it worked:We are presented with a search box, where it is most likely necessary to perform the
SQL Injection. From thehint, we are told that it isSQLite. I tried a simple injection here as well,'OR 1=1 --, but nothing happened, since I was in the table displaying offices. So, I immediately tried using aUNION Based Injection:
1' UNION SELECT * FROM users;Finding a single
adminuser in the database, I realized it was aUNION Based Injection. So, the first thing I did was retrieve theSQLiteversion:
1' UNION SELECT 1,2,sqlite_version();Since we can only display
3elements at a time, as seen in the table, and theUNION Based Injectionmust have the same number of elements as the main query:Doing so, I was able to obtain the SQLite version
3.31.1. Now that we know how to perform the injection, let’s move on to the exploitation.
🔬 Vulnerability Analysis
Potential Vulnerabilities
- SQL Injection
🎯 Solution Path
Exploitation Steps
Initial setup
Most likely, the flag will be in one of the other tables, so to enumerate them, I can use
sqlite_masteras follows:
1' UNION SELECT 1,2,tbl_name FROM sqlite_master WHERE type='table' --As we can see, the third column of the HTML table returns the tables contained in the database. The table
more_tablelooks quite suspicious. Let’s move on to the exploitation.
Exploitation
To perform the
SELECT, we need to know the column names of the tables, which we can enumerate again usingsqlite_master:
1' UNION SELECT 1,2,sql FROM sqlite_master WHERE tbl_name='more_table' --Indeed, the
more_tabletable contains aflagcolumn. Now, we just need to print it by executing:
1' UNION SELECT 1,2,flag FROM more_table --And as we can see, the flag is displayed.
Flag capture
🛠️ Exploitation Process
Approach
The automatic exploit logs in using the injection
'OR 1=1 --in theusernameandpasswordfields and then performs the injection in the main page’ssearchfield, as previously demonstrated. Finally, it extracts the flag using a regex from the response text.
🚩 Flag Capture
Flag
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit
💡 Key Learnings
Skills Improved
- Binary Exploitation
- Reverse Engineering
- Web Exploitation
- Cryptography
- Forensics
- OSINT
- Miscellaneous
📚 References & Resources
Official Documentation
Learning Resources
📊 Final Statistics
| Metric | Value | Notes |
|---|---|---|
| Time to Solve | 00:03 | From start to flag |
| Global Ranking (At the time of flag submission) | Challenge ranking | |
| Points Earned | Team contribution |
Created: 11-02-2025 • Last Modified: 11-02-2025 *Author: mH4ck3r0n3 • Team: *