WM02 - 250pts
Briefing
View the page at https://cfta-wm02.allyourbases.co and try to get the flag.
Solution
Looking at the source code we see an
h1
tag with data attributes:<h1 id="user" data-user-name="henrywhite" data-user-id="152874" data-user-ref="c897cd08c105c0eff5ca296f56eaa4ab">Hello henrywhite!</h1>
Changing the
data-user-name
toadmin
changes the text toUser data error
.Looking at
/site.js
we see thatcheckUser()
is called every second usingsetInterval
at the bottom of the file. The followingif
statement contains the logic we can take advantage of:if (get("user").dataset['userRef'] === hash(get("user").dataset['userName'] + "_" + get("user").dataset['userId']).split("").reverse().join("")) {
. We can change thedata-user-name
toadmin
and then runhash(document.getElementById("user").dataset['userName'] + "_" + document.getElementById("user").dataset['userId']).split("").reverse().join("")
to get thedata-user-ref
to be1dc3b8bdbf88d16df8a767eacb86f14c
. However, pasting this in causes the site to sayInvalid user
.The solution is to also change
data-user-id
so it equals"0"
. The final HTML should look this this:<h1 id="user" data-user-id="0" data-user-name="admin" data-user-ref="31f7934415f3d31c64359bd51d378177">Hello admin!</h1>
You can get thedata-user-ref
after changingdata-user-id="0" data-user-name="admin"
and then runninghash(document.getElementById("user").dataset['userName'] + "_" + document.getElementById("user").dataset['userId']).split("").reverse().join("")
.Replacing the HTML as discussed above prints the flag.
Flag
epoch_wizard
Last updated