javascripthtmlsource-code-protection

Trying to understand this function in javascript from a website sourcecode


OK so I'm doing this wargame challenge and I'm pretty much clueless about HTML and JS. I found this function in the source code stating

"your flag is:"

and then a bunch of gibberish. I assume this function is supposed to make sense in this long string, but I can't understand how it's supposed to do it or how to execute this function independently (if even needed). I do know it's not supposed to be really hard.

this is the function:

function r(){for(var r=0,e=0,a="",l=0;l<n.length;l++)if(n[l].toLowerCase()!=n[l]&&(r+=1),8==++e){if(!t)return;a+=String.fromCharCode(r),r=0,e=0}else r<<=1;return a}var e=!1,t=!1,a=setInterval(function(){e&&(t=!0,alert("Your flag is: "+r()),clearInterval(a));t=!1},1e3),n="xVJvyNQdcLEqIUwenRNdnawBhSNqcVABvERRGlQOiVKlnlwJdINtSRfrxZJnYDsntIzKBOFQzMTBXioIbKGkDJZYoTFWqCzSbWIKsvPxlHaPHEVRiTIiltXqtKEjwzkDkGHEbnMPnFNrnWyLcOlBOVSWtOZxmjdIhRFXugEotQRmyHwZpGnKSDSRaZCrniYgcQVkiFaIgFScWAevgWDkQZALgSWwQDFkkDWlaYOKkDcRGUNSxJlLlRnnfROzNFGSrNcEECFDxZEVeAeVwSEQvxMOxBRGLKlS";

and this is the whole web page:

please help me help myself :)


Solution

  • The js code you are looking into is minified/compressed code That means the actual code is converted by replacing all the real variable names to (a, b, c,...) making it hard to copy for others and to load it faster on the website.