🌐 MatchTheRegex
A detailed write-up of the Web challenge 'MatchTheRegex' from PicoCTF - 2023
📊 Challenge Overview
Category Details Additional Info 🏆 Event PicoGym Event Link 🔰 Category Web 🌐 💎 Points Out of 500 total ⭐ Difficulty 🟡 Medium Personal Rating: 0/10 👤 Author Sunday Jacob Nwanyim Description Profile 🎮 Solves (At the time of flag submission) 18.572 solve rate 📅 Date 12-02-2025 PicoGym 🦾 Solved By mH4ck3r0n3 Team:
📝 Challenge Information
How about trying to match a regular expression
🎯 Challenge Files & Infrastructure
Provided Files
1
Files: None
🔍 Initial Analysis
First Steps
Initially, the website appears as follows:
While inspecting the page source, I found the function
send_request()
:This function makes a request to
/flag
, sending a parameterinput=...
(which is the parameter seen in the input box from the imageSite Presentation
) and extracts the response (which will be the flag, inserting it into an alert). There’s also a comment:
1
// ^p.....F!?
I think it’s pretty clear… Let’s move on to the exploitation.
🎯 Solution Path
Exploitation Steps
Initial setup
In this challenge, we need to match a regex. A regular expression (often abbreviated as regexp, regex, or RE) is a sequence of symbols (a string) that defines a set of strings. Let’s move on to the next phase.
Exploitation
The pattern from the comment seems to resemble the format of picoCTF flags. In fact, by entering
picoCTF
in the input box, it will match the regex and return the flag in analert()
. As we can see, by using https://regex101.com/ (a useful online tool to analyze regex), inserting the regex from the comment and typingpicoCTF
in the section below, we get a match:
Flag capture
🛠️ Exploitation Process
Approach
The exploit simply sends a GET request to
/flag?input=picoCTF
and extracts the flag from the response using a regex.
🚩 Flag Capture
Flag
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit ChromeDevTools Web Testing Regex 101 Regex Testing
💡 Key Learnings
Skills Improved
- Binary Exploitation
- Reverse Engineering
- Web Exploitation
- Cryptography
- Forensics
- OSINT
- Miscellaneous
📚 References & Resources
Learning Resources
- https://en.wikipedia.org/wiki/Regular_expression
- https://regex101.com/ (useful tool for parsing regexes)
📊 Final Statistics
Metric | Value | Notes |
---|---|---|
Time to Solve | 00:00 | From start to flag |
Global Ranking (At the time of flag submission) | Challenge ranking | |
Points Earned | Team contribution |
Created: 12-02-2025 • Last Modified: 12-02-2025 *Author: mH4ck3r0n3 • Team: *