Post

Hack The Box Armexis Walkthrough

Hack The Box Armexis Walkthrough

Scenario :

In the depths of the Frontier, Armaxis powers the enemy’s dominance, dispatching weapons to crush rebellion. Fortified and hidden, it controls vital supply chains. Yet, a flaw whispers of opportunity, a crack to expose its secrets and disrupt their p

Solution :

So first we are given a ZIP file as well as 2 Hosts :

image

First let’s unzip the file using the password they have given us :

image

We’re given the entire application :

image

But first let’s check the 2 IP addresses that we were given :

  • 00 :

image

The first one is a Login page .

  • 01 :

The second one is the mail box for the email : test@email.htb :

image

I first tried Fuzzig for other directories starting with the first host 00 :

image

We find 2 interesting endpoints /ResetPassword and /Weapons which returns a 404 .

Let’s first check the Reset Password feature :

image

We first need to specify the account , and it will probably send us an OTP , we already have the Mail box for the test@email.htb user so let’s use that one :

First we need to create this account using the register endpoint :

image

Then we can request a Password reset :

image

For this one we need to provide a Token , then the new password , first we need a Valid Token , which we will recieve on our Mail box :

image

Now back to the reset page , we specify this token and the new password :

image

And the password is successfuly changed , now let’s check Burp :

image

We see that in the POST Request we’re sending an email + Token and the new email , what if we send a valid Token and modify the email to the admin email , can we reset the admin password that way ?

First let’s request a new Token :

image

Now using this new Token , let’s try and modify the password for the admin , now back to our Burp request , send it to Repeater :

image

We just replace the token with our new one , and we’re just hoping that the admin email follows the same structure as our given user :

1
2
3
4
5
{
"token":"fdb516f0900d8ba01bb247f7bdde2c4c",
"newPassword":"123456",
"email":"admin@email.htb"
}

image

We get User not found , i tried multiple ones , (eg Admin , Administrator ….) but none of them was correct .

Now let’s go back to our ZIP file :

image

Looking at the folder structure , few files might be useful for us , first the index.js , then route/index.js , email-app/index.js , as all of these might contain the administrator email inside the code :

Let’s navigate the entire codebase recursively using grep and filter for admin :

1
grep -r admin

image

Perfect we found the admin email , we can test with this :

1
admin@armaxis.htb

Now back to Burp :

image

Perfect now let’s login using the administrator account :

image

Once inside we find the weapons endpoint which returned 401 earlier :

image

Checking Burp as well doesn’t return anything useful :

image

Let’s go back to our code base to read the /weapons section :

image

We find this :

1
2
  try {
    const parsedNote = parseMarkdown(note);

Let’s check the codebase for this function :

image

Let’s read the challenge/markdown.js file :

image

This is a huge indicator of a command injection :)

The url comes straight from a markdown image tag “alturl” that a user controls, and it’s being dropped directly into a shell command string with no sanitization or escaping. execSync runs this through /bin/sh, so anything that breaks out of the “URL” context gets executed as a shell command.

This is pretty simple notation tho :

1
[alt](url) :
  • ! : First this tells it that this is an image not a text .
  • alt : this is the message that will get show if the image doesn’t exist .
  • url : this is where it will fetch the resource from .

In our case we will use the file:// protocol to read internal files ( just like a nomral ssrf) .

So back to our Burp Request , inside the field that accepts Markdown which is the Note :

image

Now we just inject :

1
![Non_existing](file:///etc/passwd)

image

Now if we check the Weapons endpoint :

image

We see that we have an image that was imbedded , let’s check the source code , we should get it in a Base64 format like the code indicates :

image

Let’s decode it :

image

Perfect we got the content of the /etc/passwd file , now let’s try to read the flag :

it is usually located at /flag.txt so the payload this time should be :

1
![Non_existing](file:///etc/passwd)

image

Now if we go back to Dashboard we will see a new weapon that got dispached :

image

Now same thing , we just read the source code , decode the base64 value and we should get the flag :

image

Now back to Cyberchef :

image

We got our flag .

That was all for this challenge , see you in the next one :)

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