-
-
Save radekk/54583a1f6ca2f6a5f234578f659cb944 to your computer and use it in GitHub Desktop.
PicoCTF 2019 - Java Script Kiddie - Points: 400
This file contains 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> | |
<script src="jquery-3.3.1.min.js"></script> | |
<script> | |
var bytes = []; | |
$.get("bytes", function(resp) { | |
bytes = Array.from(resp.split(" "), x => Number(x)); | |
}); | |
function assemble_png(u_in){ | |
var LEN = 16; | |
var key = "0000000000000000"; | |
var shifter; | |
if(u_in.length == LEN){ | |
key = u_in; | |
} | |
var result = []; | |
for(var i = 0; i < LEN; i++){ | |
shifter = key.charCodeAt(i) - 48; | |
for(var j = 0; j < (bytes.length / LEN); j ++){ | |
result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i] | |
} | |
} | |
while(result[result.length-1] == 0){ | |
result = result.slice(0,result.length-1); | |
} | |
document.getElementById("Area").src = "data:image/png;base64," + btoa(String.fromCharCode.apply(null, new Uint8Array(result))); | |
return false; | |
} | |
</script> | |
</head> | |
<body> | |
<center> | |
<form action="#" onsubmit="assemble_png(document.getElementById('user_in').value)"> | |
<input type="text" id="user_in"> | |
<input type="submit" value="Submit"> | |
</form> | |
<img id="Area" src=""/> | |
</center> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment