# Upload Vulnerabilities

**Task 1 :**&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FkZG20IqwBkxzv6xk0Fsf%2Fimage.png?alt=media&#x26;token=c5d2e427-b160-469a-ae7b-d8af90012c33" alt=""><figcaption></figcaption></figure>

**Task 2:**&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FVklfYIRqkoey6XdS4AP0%2Fimage.png?alt=media&#x26;token=d5bb6148-7103-4bb7-b725-15e2398b1b1b" alt=""><figcaption></figcaption></figure>

**Task 3:**

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FmcjY7R7YGdI69Hv3b71L%2Fimage.png?alt=media&#x26;token=33e1c7b9-be1e-4529-99d6-2146239f6336" alt=""><figcaption></figcaption></figure>

**Task 4:**&#x20;

First we need to edit the /etc/hosts so that we can access these domains

{% code overflow="wrap" %}

```
10.10.183.233    overwrite.uploadvulns.thm shell.uploadvulns.thm java.uploadvulns.thm annex.uploadvulns.thm magic.uploadvulns.thm jewel.uploadvulns.thm demo.uploadvulns.thm
```

{% endcode %}

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FT03A0SFLnTNi5uqjQU6T%2Fimage.png?alt=media&#x26;token=5158ee35-5445-4729-a267-a254a8729db0" alt=""><figcaption></figcaption></figure>

First task is that we need to view overwrite.uploadvulns.thm&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FgkoMsxBBBFd2Y4agnn0A%2Fimage.png?alt=media&#x26;token=eea88537-5fc0-43b3-a1a4-7c2e2d39a5f9" alt=""><figcaption></figcaption></figure>

Then as we view the source code for this site we can see we have the images/mountains.jpg

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FTCqqk2USuiEvZyyg55Ee%2Fimage.png?alt=media&#x26;token=a6745491-9392-4229-8902-e1d4ed1d671c" alt=""><figcaption></figcaption></figure>

Then we did download a mountain image from google and change its name similar to website image which is mountains.jpg

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FCNRDApQYR5seNOWZ8moF%2Fimage.png?alt=media&#x26;token=fa32f399-1595-44b7-825c-5b6fc4483a01" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FaVZIwlao8rgcGwW31bDB%2Fimage.png?alt=media&#x26;token=ede1fc9f-4938-424a-ae30-cc990655f2cd" alt=""><figcaption></figcaption></figure>

Then after we upload the file into the webserver we did get the overwrite message

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FPbhboaFFySvjUfxBX5PW%2Fimage.png?alt=media&#x26;token=f10c5060-8e2c-4caf-9b83-3a45a28f587e" alt=""><figcaption></figcaption></figure>

**Task 5:**&#x20;

Second Task

The website also have a upload button&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FJYli3O98DdeWfIYqwFO9%2Fimage.png?alt=media&#x26;token=7f034351-a23f-4b03-8c96-719ae9b016aa" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FUOM1DFrjIjNggWSfT1iy%2Fimage.png?alt=media&#x26;token=97c13249-0808-4862-917d-e59a0be83006" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FYo89vyCsc9H8IOOPUIdu%2Fimage.png?alt=media&#x26;token=27315b3b-9991-435a-9acb-0e390b331dc5" alt=""><figcaption></figcaption></figure>

Now we get the reverse shell as www-data

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FwcpDwtUBgwGVSZ29pasg%2Fimage.png?alt=media&#x26;token=a331216e-7b4a-43ac-8240-9a32921e9791" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FyHnHcnM8dnhHz6o50JXr%2Fimage.png?alt=media&#x26;token=a4893b6e-ebcb-414c-99af-df38c49fa23e" alt=""><figcaption></figcaption></figure>

ORRRRRR we could get shell through webshell

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F0rwK1N2gtc1aajSh7Y1b%2Fimage.png?alt=media&#x26;token=7f352f4c-c613-4cd0-9778-4a2cd21475ed" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FGjKhiIlHt9WUaZ5FysLQ%2Fimage.png?alt=media&#x26;token=834f1ddc-84c4-4345-87f0-8c02e9b7ba6c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FCK1ysGWtbwTdnoSJpFnd%2Fimage.png?alt=media&#x26;token=f292bbdb-a464-4f65-a268-e78cbe769677" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FK3ri7XVFfhvVMHnodA8Y%2Fimage.png?alt=media&#x26;token=511f5df0-9135-412b-b5e2-93d3ae223c6e" alt=""><figcaption></figcaption></figure>

**Task 6:**

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FfBooaIGCYkFYx558xOY3%2Fimage.png?alt=media&#x26;token=7b6184b5-36ff-4ab3-a7c2-baf429680e16" alt=""><figcaption></figcaption></figure>

**Task 7:**

Third task

First we will try a demo png file to see if we can dowload a png

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fu5ggNh1mwMzGUEtAZgtB%2Fimage.png?alt=media&#x26;token=41151003-caab-4fbe-bdb3-bac303e99773" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FgMA150CIXIVG2aUc0Q7b%2Fimage.png?alt=media&#x26;token=07f7a470-d91d-4edd-a7d5-d552da9924d8" alt=""><figcaption></figcaption></figure>

As we can see there is the png that we uploaded but anything other than png is actually being blocked by the filter

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FupUjv11yLN6jC47dB04a%2Fimage.png?alt=media&#x26;token=2cfd193d-ffef-4d90-ba17-9f4b1a5c5a50" alt=""><figcaption></figcaption></figure>

Then we will use burpsuite to intercept the post method that is being used when uploading images

* First way&#x20;

Open the foxyproxy

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FrbfLUId0dS4K0MhIcLze%2Fimage.png?alt=media&#x26;token=3ec6df8b-2530-4765-a3a5-bf63c384f934" alt=""><figcaption></figcaption></figure>

Intercept the page by reloading and turning on the button in the burpsuite

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FZ5Crn93uXbYrnunBQO91%2Fimage.png?alt=media&#x26;token=b7ad42cd-62de-47e0-893e-6eed920fbc92" alt=""><figcaption></figcaption></figure>

Then do response to this request&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F30Mefi0JmkdnPtrviyt4%2Fimage.png?alt=media&#x26;token=b8e47702-f802-48ec-b5de-2ed938c0a0f3" alt=""><figcaption></figcaption></figure>

After that we need to delete the js script that is filtering the files&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FWKHn5IavMTLrnEclsSmQ%2Fimage.png?alt=media&#x26;token=42184001-424f-4f41-9ddd-e49d903e5878" alt=""><figcaption></figcaption></figure>

Then we will navigate to the website once again and upload our php reverse shell since there is no filtering anymore

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F2hHEbk6rchfKKCfCrDvs%2Fimage.png?alt=media&#x26;token=1c53b8aa-303c-4b4a-ac8c-fa3181e17a40" alt=""><figcaption></figcaption></figure>

As you can see there is the php rev shell that we uploaded in the burpsuite

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F6FYJ8hXqgY9YTxhbQaP0%2Fimage.png?alt=media&#x26;token=c0f92b95-def2-4e8c-8650-6c916ea43005" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FB2TGz4jZnBjYbLiSTDg8%2Fimage.png?alt=media&#x26;token=f42c1d6f-f861-46d7-acab-4af26f028fd4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FwRWWqgROfCqUysbxgcuB%2Fimage.png?alt=media&#x26;token=0318b4f3-8407-4df3-b8e9-a4217afac034" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FVUMLlgcGjsiymnLdx0jJ%2Fimage.png?alt=media&#x26;token=b25c94c0-0718-4fc3-be9d-7764ac554d3e" alt=""><figcaption></figcaption></figure>

* Second way

We cp the php rev shell into a png file&#x20;

```
cp ~/THM/php-reverse-shell.php revshell.png
```

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FAvyWIVy7ggujsHeTvgGs%2Fimage.png?alt=media&#x26;token=bed73de0-8235-4ad4-96b9-412acc823c51" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FbyDlzZaVzGzFwSpTK58f%2Fimage.png?alt=media&#x26;token=f19da685-84ba-4761-abe9-0a534de9aaef" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FUnpK2d6rXAQvrhYML861%2Fimage.png?alt=media&#x26;token=b2edbbb3-46a8-4a2d-b036-c9a98540511a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fqgv1b5V3RASNOWPd0v4f%2Fimage.png?alt=media&#x26;token=c8ff5d15-66bd-403f-8677-b2633af44974" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FGuDZXaZj9UkReusPHoSh%2Fimage.png?alt=media&#x26;token=49288f14-8292-4346-b3a3-8cd28bc39c2c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F5Ksnxcjxu4v69ze9ncfG%2Fimage.png?alt=media&#x26;token=0ce36274-30d0-42e4-bb6a-a89fc07f86a1" alt=""><figcaption></figcaption></figure>

**Task 8:**

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FElok2Qmo91p4A52PxZwy%2Fimage.png?alt=media&#x26;token=af961612-4275-482a-937a-9d9027ac2254" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FjtFVuYPaUY19RMl26ZvR%2Fimage.png?alt=media&#x26;token=d2f93dac-43bc-49d4-a5d3-893c39d55cb5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FjZOf0VGnxSyqd0rk2f1u%2Fimage.png?alt=media&#x26;token=6ae6c750-ea1b-4e88-b7f5-d581bbf6b945" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FPF7pf1aaVTkRoBYHQ337%2Fimage.png?alt=media&#x26;token=a874e01e-5975-4179-9034-e6269bd454db" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FA6kNKNIG7JX9cI1OYgaJ%2Fimage.png?alt=media&#x26;token=d479eb74-89b4-4631-aaa8-af45fbbbb81c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F5xgJ9YmUPl6YzWV3R5DC%2Fimage.png?alt=media&#x26;token=765420bf-6e27-4eb9-86f2-cfb722a7b707" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FnMQpbbg4fpGnRGOsnmoM%2Fimage.png?alt=media&#x26;token=b928eebc-5dc0-4eb8-95ba-30c026c7409e" alt=""><figcaption></figcaption></figure>

Task 9:&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FvaPTPYPka5PQ2uTGPGCx%2Fimage.png?alt=media&#x26;token=7efeb271-5bba-4fad-8321-e4b7f46fcb73" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FSkCpioAcvTRuCJIIqHtz%2Fimage.png?alt=media&#x26;token=832efcfd-1c6c-4d07-997c-3457c9a380ab" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FBrBZGvL6eg68yerHzBt3%2Fimage.png?alt=media&#x26;token=bb498921-4f54-4ca6-b9d3-e398a7720746" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FDrsMPpkf1v0IMumGDzo9%2Fimage.png?alt=media&#x26;token=a0ad5719-d0bc-4e50-bd03-d17b7cedae78" alt=""><figcaption></figcaption></figure>

```
https://en.wikipedia.org/wiki/List_of_file_signatures
```

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FbgnxxqsV8ntQWdFV1GSq%2Fimage.png?alt=media&#x26;token=54aaaca9-02b2-4f03-9752-95f0a9758049" alt=""><figcaption></figcaption></figure>

Then we will use hexedit to edit the bytes in the file

from 41 41 41 41 41 41 to 47 49 46 38 37 61

```
hexedit php-reverse-shell-copy.php
```

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F9Fc8XAoXTO5f8SR2foZ9%2Fimage.png?alt=media&#x26;token=d008f4aa-0e36-4c57-bdb6-2b413058b101" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F0NDMVT47zRZv9yugsoot%2Fimage.png?alt=media&#x26;token=95330854-d1d5-4bdd-b251-ff535c8a03dc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F9w8gvCQqGA5ZsEpLHNZ1%2Fimage.png?alt=media&#x26;token=5d1d16bd-9be5-4922-8a7a-ea8d5408237a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FNu8P78jnzP0R7i58BwUR%2Fimage.png?alt=media&#x26;token=50df0577-eaa6-4bdc-a1fc-0320498c7f5f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FkQkLgUArjjEzHtLgYOs7%2Fimage.png?alt=media&#x26;token=946500af-42c7-47c9-bcc6-9f29a8691412" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FpPbCXUyvaTUxg8LQZsWO%2Fimage.png?alt=media&#x26;token=2a3c50d4-9fda-4278-ad41-23521cb60b74" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FoB8QSvEa2JmFSaCsIzir%2Fimage.png?alt=media&#x26;token=1d8a67a5-a77d-4325-82b7-392382aa272f" alt=""><figcaption></figcaption></figure>

**Task 10:**&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FjbWTcK0GzI0oNOCxfywe%2Fimage.png?alt=media&#x26;token=9a0abdee-a299-4bea-8337-c21958131f80" alt=""><figcaption></figcaption></figure>

**Task 11:**

First we will download the file list that was given to us

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fb9QajpfjkJyIwTCKTTUh%2Fimage.png?alt=media&#x26;token=c9dc87ec-c8d0-4214-8e99-3a9bf71199c4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FkrP7yvFUmS4rP9jWQS2G%2Fimage.png?alt=media&#x26;token=bfd38ca8-de97-4ab2-9525-649677c62855" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FZ4f9zzB69ml7ABQjR112%2Fimage.png?alt=media&#x26;token=233616e6-ed55-4fc8-a7f6-42890dd0bbf8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fo0sCSi5XT1m8MIHD1TbW%2Fimage.png?alt=media&#x26;token=25129ce3-a8d6-4497-b5ea-8039055a00b6" alt=""><figcaption></figcaption></figure>

When we are visiting the /content directory we have no access or the page is not found

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FEqSvrYAT4s4tn6dQdymt%2Fimage.png?alt=media&#x26;token=17df8790-5626-4a72-bf38-f63090c78230" alt=""><figcaption></figcaption></figure>

But when we actually inspect the website we can see that the images are being saved into /content directory

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FY8mkcZ5Ja3XmZ4s21bfo%2Fimage.png?alt=media&#x26;token=259b011e-58fb-44f4-bdda-0bbf6c7d4faa" alt=""><figcaption></figcaption></figure>

Visit the js file checks the source code that is filtering the upload function

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FTCWCgAcokehNyPut8HoV%2Fimage.png?alt=media&#x26;token=0421979e-acfd-4d76-92a8-70d9eb17fc23" alt=""><figcaption></figcaption></figure>

Then use burpsuite to intercept the requests

First we will remove the js in interception rule so that we can see the js file intercepted

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F7inWqmgvJWUcezfXlt4c%2Fimage.png?alt=media&#x26;token=d75bb949-243e-4992-ae46-ad7d68ae07c3" alt=""><figcaption></figcaption></figure>

Do intercept reponse to this request for the upload.js&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F4IwAaZfjvF6nPLKTq9hp%2Fimage.png?alt=media&#x26;token=3d1c2019-228f-41c8-a5c0-049790983868" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F5AhAoscwVuRsn3fu0cPM%2Fimage.png?alt=media&#x26;token=04da946c-6a2f-4769-bb5b-18c51bb73971" alt=""><figcaption></figcaption></figure>

Then delete the following lines to remove the filter

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FGsgs10rZmaxQVrFw2Eu6%2Fimage.png?alt=media&#x26;token=7c760ba5-2aba-4f8b-af23-015e11b8d0fb" alt=""><figcaption></figcaption></figure>

We see here that the filter is actually removed&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F7Qj7p2EAWe8VX9WDdkqs%2Fimage.png?alt=media&#x26;token=a6678a24-9e3a-482c-83e6-6c816f3fe7d3" alt=""><figcaption></figcaption></figure>

Once look in the wappalyzer, we can see the webiste uses node.js instead of php programming language.&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FBbrZfSIsW1MHV9TOJMnj%2Fimage.png?alt=media&#x26;token=c5c5dab0-332c-42f3-b48c-355574b329c9" alt=""><figcaption></figcaption></figure>

That's why we are going to use node reverse shell instead of reverse php

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F9ZwAm2FDliVZsCd8J8dX%2Fimage.png?alt=media&#x26;token=842a8689-442c-4edd-9424-84b04c794d58" alt=""><figcaption></figcaption></figure>

As you can see the node rev shell have a jpg file extension but it is still a js file

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fy57DWITJl2j91dtQjW5D%2Fimage.png?alt=media&#x26;token=039eca0f-19df-4dfe-a685-b35d3d89981f" alt=""><figcaption></figcaption></figure>

Then try to upload our payload and intercept it with burp

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FlmSeJPN50z36gvinwllD%2Fimage.png?alt=media&#x26;token=84869f82-8c63-452d-a7cb-eb6c392032cc" alt=""><figcaption></figcaption></figure>

Change the file type of the node file from jpg to js, so that we can execute it as javascript file

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FalPBUH9xcnoM8eQsTljP%2Fimage.png?alt=media&#x26;token=755883b5-e1b3-414a-b467-f68b84c176ff" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F5HT4ZwCuprgkS0Jo73oQ%2Fimage.png?alt=media&#x26;token=4bc95dea-ee97-4fff-a9d6-64efaa846f82" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FrNywx2xXHru08Qvo6tHf%2Fimage.png?alt=media&#x26;token=236842ea-4d7e-46a8-a888-d2073cca39eb" alt=""><figcaption></figcaption></figure>

Then we know that jpg files are located in content directory so we can use the gobuster tool to look for our jpg file using the wordlist that are provided

{% code overflow="wrap" %}

```
gobuster dir -u http://jewel.uploadvulns.thm/content -w UploadVulnsWordlist.txt -x jpg
```

{% endcode %}

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F3F75kuCQ4vvq8cfkwosN%2Fimage.png?alt=media&#x26;token=6ad54dc2-e76d-4054-afb0-82f5b1bd2c1c" alt=""><figcaption></figcaption></figure>

The payload or our reverse shell did actually converted to a random three letters that is in the wordlists that was given to us

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fv07upOcb9Wv9QucxSC57%2Fimage.png?alt=media&#x26;token=2f0fdc84-3e7c-49c7-addf-e38f4ca8a958" alt=""><figcaption></figcaption></figure>

Access or execute the file through tthe admin page by using this command

```
../content/ZBP.jpg
```

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fc0k2a6jFqQQusJqsUAWP%2Fimage.png?alt=media&#x26;token=0bf7c6a9-09bf-4802-9acf-e71bef993b0e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FDKcWbRx8bHNc8hAqLE9N%2Fimage.png?alt=media&#x26;token=778525c2-cc39-4cee-8d5a-de1ceef0fbf8" alt=""><figcaption></figcaption></figure>
