Contents

🌐 Postbook

A detailed write-up of the Web challenge 'Postbook' from Hacker101 CTF

/images/Hacker101CTF/Postbook/challenge_presentation.png
Challenge Presentation

📊 Challenge Overview

Category Details Additional Info
🏆 Event Hacker101 CTF Event Link
🔰 Category Web 🌐
💎 Points 28 Out of 28 total
⭐ Difficulty 🟢 Easy Personal Rating: 2/10
👤 Author Unknown Profile
🎮 Solves (At the time of flag submission) Unknown solve rate
📅 Date 05-03-2025 Hacker101 CTF
🦾 Solved By mH4ck3r0n3 Team:

🎯 Challenge Files & Infrastructure

Provided Files

1
Files: None

🔍 Initial Analysis

First Steps

Initially, the website appears as follows:

/images/Hacker101CTF/Postbook/site_presentation.png
Site Presentation

You can register an account by clicking on Sign up. I registered an account with username=mhackerone&password=mhackerone and then logged in.

/images/Hacker101CTF/Postbook/homepage.png
HomePage

It is a web application where you can create both private and public posts, with the ability to edit and delete them once created. At first, the URL made me think of an LFI (Local File Inclusion) due to the page= parameter, as we can see in: https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=home.php.However, after a few attempts, I realized that LFI was not present. While inspecting the pages, I found an IDOR.

/images/Hacker101CTF/Postbook/post_view.png
Post View

As we can see in the URL https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=view.php&id=3, there is the id parameter that indicates which post we are currently viewing. By changing it, it is possible to see posts from other accounts (even private ones!). Let’s proceed to the exploitation phase, explaining the other vulnerabilities along the way.

🔬 Vulnerability Analysis

Potential Vulnerabilities

  • IDOR (Insecure Direct Object Reference)
  • IDOM (Insecure Direct Object Manipulation)
  • Predictable Cookie
  • Brute-force attack

🎯 Solution Path

Exploitation Steps

Initial setup

After inspecting the pages a bit more, I decided to try exploiting the IDOR. Let’s move on to the next phase.

Exploitation

As we can see from the image of the homepage, when we log in, only two posts are visible, but the ID of the second post is 3. I therefore assume that there is a hidden second post. In fact, by trying to change the ID to 2:https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=view.php&id=2, I was able to find the first flag.

Continuing to inspect the page, I found some session cookies:

/images/Hacker101CTF/Postbook/cookies.png
Cookies

Which, at first glance, appear to be a hash. When I tried to analyze them using https://www.dcode.fr/cipher-identifier, the result that came out was indeed an MD5 hash:

/images/Hacker101CTF/Postbook/cipher_identifier.png
Cipher Identifier

I then tried to crack it with https://crackstation.net/.

/images/Hacker101CTF/Postbook/hash_result.png
Crackstation

Obtaining the result 3. Since the cookie name is id, I immediately thought it was the ID associated with my account. In fact, by closely examining the homepage image, you can notice that there are two posts, one with the username user and the other with the username admin (which are the two default accounts created each time a session for the challenge starts), so mine is the third one… With this, I didn’t waste any more time and immediately generated the MD5 of 1 (since the admin is usually the first account).

1
2
import hashlib
print(hashlib.md5(b'1').hexdigest())

/images/Hacker101CTF/Postbook/2hash.png
MD5 '2'

And by inserting the freshly generated hash in place of the previous value in the cookies and refreshing the page with F5, I was able to find the second flag (it was also possible to use an online tool like https://www.md5.cz/). Then, I did the same for ID 2 and found another flag associated with the user account. (By reading the post-solution writeups, I discovered that it was also possible to brute-force the password, so I applied this method in the automated exploit).

Later, I logged in again with my account and tried to create posts, noticing that during creation, a user_id parameter was specified, which assigned the post to the account that created it. I immediately thought that this id could also be manipulated.

/images/Hacker101CTF/Postbook/user_id.png
User_id

I then tried to change the value of the parameter directly in the form’s HTML:

/images/Hacker101CTF/Postbook/user_id_modified.png
Modified User_id

By creating a new post, I was able to obtain the flag. I then checked if it was possible to do the same during the deletion and modification of posts, and indeed, it was possible, allowing me to obtain two more flags. For the modification, in the URL https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=edit.php&id=4, the id of the post being modified was specified, but by changing it, I could modify other posts. By modifying a post of another user, I was able to get the flag. As for the delete:

/images/Hacker101CTF/Postbook/delete.png
Delete

Inspecting the page, I noticed that clicking on delete triggers a request with href= index.php?page=delete.php&id=a87ff679a2f3e71d9181a67b7542122c. The id is very similar to the one previously seen in MD5, so using the MD5 of 1 that I generated earlier, I made a request specifying the new id, since post 1 does not belong to me. By visiting https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=delete.php&id=c4ca4238a0b923820dcc509a6f75849b, I obtained the new flag associated with the deletion of someone else’s post, as I was able to delete a post that was not associated with my account.

The last flag I found by running a tool while fuzzing the possible posts, setting a range from 1 to 1000. I was able to find it at ID 945, exploiting the first IDOR found (https://b9ad151edc833e1a2b2833e7c6a11041.ctf.hacker101.com/index.php?page=view.php&id=945).

Flag capture

/images/Hacker101CTF/Postbook/manual_flag1.png
Manual Flag 1
/images/Hacker101CTF/Postbook/manual_flag2.png
Manual Flag 2
/images/Hacker101CTF/Postbook/manual_flag3.png
Manual Flag 3
/images/Hacker101CTF/Postbook/manual_flag4.png
Manual Flag 4
/images/Hacker101CTF/Postbook/manual_flag5.png
Manual Flag 5
/images/Hacker101CTF/Postbook/manual_flag6.png
Manual Flag 6
/images/Hacker101CTF/Postbook/manual_flag7.png
Manual Flag 7

🛠️ Exploitation Process

Approach

The automated exploit performs the steps previously done manually, extracting the flags via regex.

🚩 Flag Capture

Flag 1

Flag 2

Flag 3

Flag 4

Flag 5

Flag 6

Flag 7

Proof of Execution

/images/Hacker101CTF/Postbook/automated_flag.png
Automated Flag
Screenshot of successful exploitation

🔧 Tools Used

Tool Purpose
Python Exploit

📈 Technical Deep Dive

Vulnerability Details

Mitigation Strategies

  • Verify that the authenticated user has permission to access the requested data before returning it, and always check if the authenticated user is the author of the post before allowing modifications.
  • Avoid storing the user ID directly in the cookies and use secure sessions with randomized tokens.
  • Block IPs with too many failed attempts or, after 3-5 failed attempts, require a CAPTCHA (e.g., Google’s reCAPTCHA).

💡 Key Learnings

Skills Improved

  • Binary Exploitation
  • Reverse Engineering
  • Web Exploitation
  • Cryptography
  • Forensics
  • OSINT
  • Miscellaneous

📚 References & Resources

Learning Resources


📊 Final Statistics

Metric Value Notes
Time to Solve 00:48 From start to flag
Global Ranking (At the time of flag submission) Challenge ranking
Points Earned 7 Team contribution

Created: 05-03-2025 • Last Modified: 05-03-2025 *Author: mH4ck3r0n3 • Team: *