Contents

🌐 More SQLi

A detailed write-up of the Web challenge 'More SQLi' from PicoCTF - 2023

/images/PicoGym/PicoCTF-2023/MoreSQLi/challenge_presentation.png
Challenge Presentation

📊 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

1
Files: None

🔍 Initial Analysis

First Steps

Initially, the website appears as follows:

/images/PicoGym/PicoCTF-2023/MoreSQLi/site_presentation.png
Site Presentation

Given the challenge description, I used the payload 'OR 1=1 -- for username and password to access the site, and it worked:

/images/PicoGym/PicoCTF-2023/MoreSQLi/login.png
Login

We are presented with a search box, where it is most likely necessary to perform the SQL Injection. From the hint, we are told that it is SQLite. 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 a UNION Based Injection:

1
' UNION SELECT * FROM users;  

/images/PicoGym/PicoCTF-2023/MoreSQLi/admin_user.png
Admin User

Finding a single admin user in the database, I realized it was a UNION Based Injection. So, the first thing I did was retrieve the SQLite version:

1
' UNION SELECT 1,2,sqlite_version();  

Since we can only display 3 elements at a time, as seen in the table, and the UNION Based Injection must have the same number of elements as the main query:

/images/PicoGym/PicoCTF-2023/MoreSQLi/version.png
Version

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_master as follows:

1
' UNION SELECT 1,2,tbl_name FROM sqlite_master WHERE type='table' --  

/images/PicoGym/PicoCTF-2023/MoreSQLi/table_enumeration.png
Table Attribute Enumeration

As we can see, the third column of the HTML table returns the tables contained in the database. The table more_table looks 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 using sqlite_master:

1
' UNION SELECT 1,2,sql FROM sqlite_master WHERE tbl_name='more_table' --  

/images/PicoGym/PicoCTF-2023/MoreSQLi/column_enumeration.png
Column Attribute Enumeration

Indeed, the more_table table contains a flag column. 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

/images/PicoGym/PicoCTF-2023/MoreSQLi/manual_flag.png
Manual Flag

🛠️ Exploitation Process

Approach

The automatic exploit logs in using the injection 'OR 1=1 -- in the username and password fields and then performs the injection in the main page’s search field, as previously demonstrated. Finally, it extracts the flag using a regex from the response text.

🚩 Flag Capture

Flag

Proof of Execution

/images/PicoGym/PicoCTF-2023/MoreSQLi/automated_flag.png
Automated Flag
Screenshot of successful exploitation

🔧 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: *