> For the complete documentation index, see [llms.txt](https://blog.yenwai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.yenwai.com/ctf/gctf-2023/pwn/level-4.md).

# Level 4

## Challenge details

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FbOBK4jiFR8CwX4FsQJPa%2Fimage.png?alt=media&amp;token=c05e9ff1-4fc5-4b2c-8bae-a27b3d2ef6c3" alt="" width="362"><figcaption><p>description</p></figcaption></figure>

## Solution

Below shows the source code of the challenge. We can see that `len(inp)>13` code was used, telling us that any input that contains more that 13 characters are prohibited. So our objective for this challenge is pretty clear, we'll need some short payloads.

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FK33ndgp12Z5c8KStSj0U%2Fimage.png?alt=media&amp;token=5b798de3-1bbf-4347-aaca-f2120759b5d6" alt="" width="563"><figcaption></figcaption></figure>

The first thing that came into my mind was `breakpoint()`. But it turned out that this is not working. Again, I was randomly inputting some codes to the server.

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FpG4d50bwVyjnRq1IPgjJ%2Fimage.png?alt=media&amp;token=d40df34d-6f64-48ac-ac6b-048c25f0600b" alt="" width="563"><figcaption></figcaption></figure>

More trial and error were done. Like for real, I was just brute forcing any short codes :)

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FTNpcZwjVoU0hNvllVNUt%2Fimage.png?alt=media&amp;token=f153bcac-c771-4582-b98b-58978f8cef4f" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2Fl9r69BKGveDt0iY2haij%2Fimage.png?alt=media&amp;token=8a1ea2be-883b-47f7-a212-effe106703fa" alt="" width="375"><figcaption></figcaption></figure>

Ended up consulting an old friend of mind once again, Google. If you remember, I clicked on the first link for the previous challenge. Now, let's go with the second link.

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FJCJV9kdREZHXr83EBGVp%2Fimage.png?alt=media&amp;token=0b998f30-e3bb-49af-91b5-a6fc268912c2" alt=""><figcaption></figcaption></figure>

Sweet! Found something interesting. The `input()` function is being wrapped in `eval()` function. The best part? It contains only 13 characters.

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FdItG5ndMalaYkYRRHqhA%2Fimage.png?alt=media&amp;token=6350f116-5c6a-42c3-bf44-ad57ab87d3eb" alt=""><figcaption></figcaption></figure>

The payload was slightly modified so that it matches our flag location. Voila, flag!

<figure><img src="https://3330117967-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6lVP7UgVVHIkHqAlU1O%2Fuploads%2FgesUkBqAOLMs52YhVC8v%2Fimage.png?alt=media&amp;token=a60136af-f0e5-438e-97b3-9d43fd93bcdf" alt="" width="375"><figcaption></figcaption></figure>

## Flag

> `GCTF2023{L3v31_f0ur_K33p_g0inggggg}`
