> For the complete documentation index, see [llms.txt](https://simon-6.gitbook.io/simoncyber/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simon-6.gitbook.io/simoncyber/ctf-writeups/picoctf-2024/web-exploitation/bookmarklet-easy.md).

# Bookmarklet (Easy)

<figure><img src="/files/YjKpRB9RCNRqg3AlIwI9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/VomlhiT5pgDr12pgKh0J" alt=""><figcaption></figcaption></figure>

***

The challenge first starts us off with some code. And guessing from the title of the challenge, "Bookmarklet" it has to deal with some kind of bookmarks.

```javascript
        javascript:(function() {
            var encryptedFlag = "àÒÆÞ¦È¬ëÙ£ÖÓÚåÛÑ¢ÕÓÒËÉ§©í";
            var key = "picoctf";
            var decryptedFlag = "";
            for (var i = 0; i < encryptedFlag.length; i++) {
                decryptedFlag += String.fromCharCode((encryptedFlag.charCodeAt(i) - key.charCodeAt(i % key.length) + 256) % 256);
            }
            alert(decryptedFlag);
        })();
    
```

I know you can manually decrypt it since it gave you the key and the flag itself, but let's try to do the bookmarklet thing.&#x20;

{% embed url="<https://www.freecodecamp.org/news/what-are-bookmarklets/>" %}

I intially tried to create like some html or javascript code to import the bookmark, but after researching, there's a much easier way.

<figure><img src="/files/s4Ue21fnegElMxDpGErb" alt=""><figcaption></figcaption></figure>

You would add a bookmark.

<figure><img src="/files/EPkRk2JkdiPRrZrF0VBB" alt=""><figcaption></figcaption></figure>

Then, you would actually put the code in the URL. Since bookmarklets are called "Javascript Bookmarks" this makes sense.

<figure><img src="/files/WJtXDl7ojTFPHjBXMir0" alt=""><figcaption></figcaption></figure>

And once clicking it, you get the flag!
