๐ Web Gauntlet 2
A detailed write-up of the Web challenge 'Web Gauntlet 2' from PicoCTF - 2021
๐ 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:
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 sendusername=a
andpassword=a
: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 asadmin
, given the error messagenot admin
. In the challenge description, there was another link:As we can see, filters are applied to the query. I cannot use
or
,and
,true
,false
,union
,like
,=
,>
,<
,;
,--
,/*
,*/
, oradmin
. So, I need to come up with another way to access as theadmin
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 andadmin
is filtered. So, continuing to search in theFunctions->String Functions
section (https://www.sqlitetutorial.net/sqlite-string-functions/), I found the string concatenation operator inSQLite
, which is||
. Using this operator, we can concatenate two strings to bypass the filter onadmin
.
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 wordadmin
for theusername
, we need a way to validate the password and make the query returnTrue
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 negationIS 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 returnedTrue
. 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 returnTrue
since''
is not equal to'a'
. Indeed, after testing the 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
๐ ๏ธ 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
๐ง 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: *