One of our agents recently caught a young hacker with the code name !$criptkiddie. He hid the below piece of javascript on a page which calculates a value but doesn’t output the final result. It’s also embedded on this page - can you find the result?
var string = “2b903102b29299c12d6c1e2ac80169”;
var flag = “”;
for (var i = 0; i < string.length; i++) {
// There is an easier way to find this than calculating by hand!
var number = parseInt("2b903102b29299c12d6c1e2ac80169",16);
console.log(number); // 2.2619331491473775e+35
As a sum,
var string = "2b903102b29299c12d6c1e2ac80169";
var sum = 0;
for (var i = 0; i < string.length; i++) {
sum += parseInt(string[i], 16);
}
console.log(sum); // 179
Is this a trick question? Because this line doesn’t make any sense, overwriting as it does the variable above it. What happens when you comment that line?