CTF_Site/docs/js/verify.js

28 lines
983 B
JavaScript
Raw Normal View History

2019-06-13 18:06:08 +02:00
function httpGet(theUrl, elem) {
function reqListener() {
let res = this.responseText
if(res === "wrong"){
alert("Nope, sorry. This is the wrong key!")
}else if(res === "nope" || res === "missing"){
alert(`Could you send a message to J00LZ##9386 on Discord with the challenge name, he apparently misconfigured this... (${res})`)
}else if(res === "ok"){
alert("Good job! You solved the challenge!")
}
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", theUrl);
oReq.send();
}
function check(challenge, elem) {
flag = document.querySelector(`input#${elem}`).value
flagExp = flag.match(/(?:flag)\{([\w]+)\}/i)
if(flagExp == null || flagExp == undefined){
alert("That isn't even a flag?")
return
}
console.log(flagExp)
httpGet(`https://challengeverify.voidcorp.nl/${challenge}/${flagExp[1]}`, elem)
}