Overwrite Existing File Vulnerabilities | Tryhackme

Ikhlasdansantai
3 min read5 days ago

Basic file-upload vulnerabilities in websites parte 1

To make your virtual host (VHOST) accessible, you’ll need to modify your system’s hosts file.

sudo nano /etc/hosts

Add the following entry to your hosts file (replace MACHINE_IP with the IP address provided by TryHackMe.

And then, we able to access the website.

TASKS

Open your web browser and navigate to overwrite.uploadvulns.thm. Your goal is to overwrite a file on the server with an upload of your own.

Let’s Do It

In the tutorial, they show how the attack works. By inspecting the URL of the image, we can see that mountains.jpg is displayed as the background. We can do the same, we just need to find a picture, download it, and rename it to mountains.jpg .

After renaming the image file, we can upload it, and voilaaa, we got the flag ⛳.

as u can c, the background image is updated 😁

How To Prevent It

When uploading files to a server, it’s important to prevent overwriting existing files. Here’s how servers typically handle this:

  1. Renaming Files — The server may give the file a new name (e.g., adding random characters or a timestamp).
  2. Filename Checks — If a file with the same name already exists, the server can reject it and ask the user to pick a different name.
  3. File Permissions — Critical files (like web pages) should have restricted write access to stop attackers from overwriting them.

Thank you for reading this until the end! This write-up serves as my personal journal while working through this room, documenting my journey, challenges, and learnings along the way. I hope it can also be a helpful resource for others exploring similar paths.

Happy Hacking and learning~! 👨‍💻

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ikhlasdansantai
Ikhlasdansantai

No responses yet

Write a response