Contents

🌐 Bookmarklet

A detailed write-up of the Web challenge 'Bookmarklet' from PicoCTF - 2024

/images/PicoGym/PicoCTF-2024/Bookmarklet/challenge_presentation.png
Challenge Presentation

📊 Challenge Overview

Category Details Additional Info
🏆 Event PicoGym Event Link
🔰 Category Web 🌐
💎 Points Out of 500 total
⭐ Difficulty 🟢 Easy Personal Rating: 0/10
👤 Author Jeffery John Profile
🎮 Solves 35.621 solve rate
📅 Date 28-01-2025 PicoGym
🦾 Solved By mH4ck3r0n3 Team:

📝 Challenge Information

Why search for the flag when I can make a bookmarklet to print it for me?

🎯 Challenge Files & Infrastructure

Provided Files

1
Files: None

🔍 Initial Analysis

First Steps

Initially, the website appears as follows:

/images/PicoGym/PicoCTF-2024/Bookmarklet/site_presentation.png
Site Presentation

As we can see, there is a textarea in the center containing some JavaScript code. The first thing I thought of doing was copying it and trying to execute it in the ChromeDevTools console.

🎯 Solution Path

Exploitation Steps

Exploitation

The exploit is very simple: by clicking on the textarea, the code is copied to the clipboard. Then, pasting it into the ChromeDevTools console and pressing enter to execute it, I obtained the flag in an alert, as the code decrypted and displayed it.

Flag capture

/images/PicoGym/PicoCTF-2024/Bookmarklet/manual_flag.png
Manual Flag

🛠️ Exploitation Process

Approach

The automatic exploit is a bit unusual (I had fun with the PyExecJs library). First, you need to install Node.js and the `ExecJS library:

1
2
sudo apt install nodejs
pip install PyExecJs

I used requests and bs4 to extract the JavaScript from the page inside the textarea, and then executed it with execjs to extract the flag.

🚩 Flag Capture

Flag

Proof of Execution

/images/PicoGym/PicoCTF-2024/Bookmarklet/automated_flag.png
Automated Flag
Screenshot of successful exploitation

🔧 Tools Used

Tool Purpose
Python Exploit
ChromeDevTools Web Testing

💡 Key Learnings

New Knowledge

I learned how to use Python’s execjs to execute JavaScript in Python.

Skills Improved

  • Binary Exploitation
  • Reverse Engineering
  • Web Exploitation
  • Cryptography
  • Forensics
  • OSINT
  • Miscellaneous

📊 Final Statistics

Metric Value Notes
Time to Solve 00:00 From start to flag
Global Ranking Challenge ranking
Points Earned Team contribution

Created: 28-01-2025 • Last Modified: 28-01-2025 *Author: mH4ck3r0n3 • Team: *