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
h1tag 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-nametoadminchanges the text toUser data error.Looking at
/site.jswe see thatcheckUser()is called every second usingsetIntervalat the bottom of the file. The followingifstatement 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-nametoadminand then runhash(document.getElementById("user").dataset['userName'] + "_" + document.getElementById("user").dataset['userId']).split("").reverse().join("")to get thedata-user-refto be1dc3b8bdbf88d16df8a767eacb86f14c. However, pasting this in causes the site to sayInvalid user.The solution is to also change
data-user-idso 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-refafter 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
Was this helpful?