Contents

๐ŸŒ Web Gauntlet 2

A detailed write-up of the Web challenge 'Web Gauntlet 2' from PicoCTF - 2021

/images/PicoGym/PicoCTF-2021/WebGauntlet2/challenge_presentation.png
Challenge Presentation

๐Ÿ“Š Challenge Overview

Category Details Additional Info
๐Ÿ† Event PicoGym Event Link
๐Ÿ”ฐ Category Web ๐ŸŒ
๐Ÿ’Ž Points 500 Out of 500 total
โญ Difficulty ๐ŸŸก Medium Personal Rating: 2/10
๐Ÿ‘ค Author madStacks Profile
๐ŸŽฎ Solves (At the time of flag submission) 7.331 solve rate
๐Ÿ“… Date 20-02-2025 PicoGym
๐Ÿฆพ Solved By mH4ck3r0n3 Team:

๐Ÿ“ Challenge Information

This website looks familiar… Log in as admin Site: http://mercury.picoctf.net:65261/ Filter: http://mercury.picoctf.net:65261/filter.php

๐ŸŽฏ Challenge Files & Infrastructure

Provided Files

1
Files: None

๐Ÿ” Initial Analysis

First Steps

Initially, the website appears as follows:

/images/PicoGym/PicoCTF-2021/WebGauntlet2/site_presentation.png
Site Presentation

Given the obvious message, we already know it’s an SQL Injection. In the hints, I found that it’s related to SQLite. The first thing I did to test was send username=a and password=a:

/images/PicoGym/PicoCTF-2021/WebGauntlet2/first_try.png
First Try

The query being executed is shown at the top (SELECT username, password FROM users WHERE username='a' AND password='a'), so this is not a form of blind injection. Our goal is to likely log in as admin, given the error message not admin. In the challenge description, there was another link:

/images/PicoGym/PicoCTF-2021/WebGauntlet2/filter.png
Filter

As we can see, filters are applied to the query. I cannot use or, and, true, false, union, like, =, >, <, ;, --, /*, */, or admin. So, I need to come up with another way to access as the admin user. After doing a bit of research, I found a page that was quite helpful: https://www.sqlitetutorial.net/. Let’s proceed with the exploitation.

๐Ÿ”ฌ Vulnerability Analysis

Potential Vulnerabilities

  • SQL Injection

๐ŸŽฏ Solution Path

Exploitation Steps

Initial setup

The first thing we need to figure out is how to form the admin username, since comments are blocked and admin is filtered. So, continuing to search in the Functions->String Functions section (https://www.sqlitetutorial.net/sqlite-string-functions/), I found the string concatenation operator in SQLite, which is ||. Using this operator, we can concatenate two strings to bypass the filter on admin.

1
ad'||'min

This way, by placing || outside the quotes, it is treated as a command and performs the concatenation. Now that we know how to form the word admin for the username, we need a way to validate the password and make the query return True even if we don’t know the actual password. Let’s proceed with the exploitation.

Exploitation

Continuing the search, I found the IS operator, which can also be used with a negation IS NOT. I initially tried:

1
' IS '

to form the final query: SELECT username, password FROM users WHERE username='ad'||'min' AND password='' IS '', but it didn’t work. I thought '' would be equal to '', and therefore it should have returned True. So, I tried the negation instead:

1
' IS NOT 'a

forming the final query: SELECT username, password FROM users WHERE username='ad'||'min' AND password='' IS NOT 'a'. This time, it should definitely return True since '' is not equal to 'a'. Indeed, after testing the injection:

/images/PicoGym/PicoCTF-2021/WebGauntlet2/injection.png
Injection

it succeeded, and as indicated by the message, I then visited the /filter.php route and was able to obtain the flag.

Flag capture

/images/PicoGym/PicoCTF-2021/WebGauntlet2/manual_flag.png
Manual Flag

๐Ÿ› ๏ธ Exploitation Process

Approach

L’exploit invia la payload tramite una richiesta POST per sfruttare la vulnerabilitร  di SQL Injection, quindi esegue una richiesta GET alla rotta /filter.php per ottenere la flag, estraendola utilizzando una regex applicata alla risposta del server.

๐Ÿšฉ Flag Capture

Flag

Proof of Execution

/images/PicoGym/PicoCTF-2021/WebGauntlet2/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

Learning Resources


๐Ÿ“Š Final Statistics

Metric Value Notes
Time to Solve 00:12 From start to flag
Global Ranking (At the time of flag submission) Challenge ranking
Points Earned 500 Team contribution

Created: 20-02-2025 โ€ข Last Modified: 20-02-2025 *Author: mH4ck3r0n3 โ€ข Team: *