Jump to content

understanding javascript code


hisoka

Recommended Posts

I have trouble understanding this long javascript code :

var p = 0;
var r = '';
var b = new Array();
for(var i=0; i<32768; i++) b[i] = 0;

function main() {
	incPtr(1);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(8);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(5);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(6);
	while(b[p]>0) {
		decPtr(1);
		incVal(5);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(2);
	while(b[p]>0) {
		decPtr(1);
		decVal(7);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(3);
	while(b[p]>0) {
		decPtr(1);
		incVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(1);
	echo(String.fromCharCode(b[p]));
	decVal(4);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(3);
	while(b[p]>0) {
		decPtr(1);
		decVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(1);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(3);
	while(b[p]>0) {
		decPtr(1);
		incVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(2);
	while(b[p]>0) {
		decPtr(1);
		decVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(4);
	while(b[p]>0) {
		decPtr(1);
		decVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(3);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	incVal(4);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(2);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(8);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(1);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(5);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(3);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(7);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(3);
	incPtr(1);
	b[p] = prompt('', '').charCodeAt(0);
	echo(String.fromCharCode(b[p]));
	incVal(2);
	incPtr(1);
	b[p] = prompt('', '').charCodeAt(0);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	b[p] = prompt('', '').charCodeAt(0);
	echo(String.fromCharCode(b[p]));
	incPtr(1);
	b[p] = prompt('', '').charCodeAt(0);
	echo(String.fromCharCode(b[p]));
	decVal(4);
	incPtr(1);
	b[p] = prompt('', '').charCodeAt(0);
	echo(String.fromCharCode(b[p]));
	incPtr(3);
	incVal(8);
	while(b[p]>0) {
		decPtr(1);
		incVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(9);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(3);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(4);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(1);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(3);
	incPtr(2);
	incVal(6);
	while(b[p]>0) {
		decPtr(1);
		incVal(5);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(3);
	incPtr(1);
	incVal(1);
	incPtr(2);
	incVal(8);
	while(b[p]>0) {
		decPtr(1);
		incVal(4);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(7);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(3);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(1);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(4);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(4);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(1);
	incPtr(2);
	incVal(10);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	decVal(1);
	incPtr(2);
	incVal(11);
	while(b[p]>0) {
		decPtr(1);
		incVal(10);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(6);
	incPtr(2);
	incVal(6);
	while(b[p]>0) {
		decPtr(1);
		incVal(5);
		incPtr(1);
		decVal(1);
	}
	decPtr(1);
	incVal(3);
	decPtr(22);
	while(b[p]>0) {
		decPtr(5);
		decVal(1);
		incPtr(5);
		decVal(1);
	}
	decPtr(5);
	while(b[p]>0) {
		incPtr(10);
		incVal(1);
		decPtr(10);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(6);
	decVal(1);
	while(b[p]>0) {
		decPtr(5);
		decVal(1);
		incPtr(5);
		decVal(1);
	}
	decPtr(5);
	while(b[p]>0) {
		incPtr(9);
		incVal(1);
		decPtr(9);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(6);
	incVal(2);
	while(b[p]>0) {
		decPtr(5);
		decVal(1);
		incPtr(5);
		decVal(1);
	}
	decPtr(5);
	while(b[p]>0) {
		incPtr(8);
		incVal(1);
		decPtr(8);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(6);
	while(b[p]>0) {
		decPtr(5);
		decVal(1);
		incPtr(5);
		decVal(1);
	}
	decPtr(5);
	while(b[p]>0) {
		incPtr(7);
		incVal(1);
		decPtr(7);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(6);
	incVal(5);
	while(b[p]>0) {
		decPtr(5);
		decVal(1);
		incPtr(5);
		decVal(1);
	}
	decPtr(5);
	while(b[p]>0) {
		incPtr(6);
		incVal(1);
		decPtr(6);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(6);
	while(b[p]>0) {
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		decVal(1);
		decPtr(8);
		while(b[p]>0) {
			decVal(1);
		}
	}
	incPtr(8);
	while(b[p]>0) {
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		incPtr(1);
		echo(String.fromCharCode(b[p]));
		decPtr(9);
		while(b[p]>0) {
			decVal(1);
		}
	}
}

function incPtr(n) {
	if(p < 32676 - n) p += n; else p = 0;
}

function decPtr(n) {
	if(p > n - 1) p -= n; else p = 255;
}

function incVal(n) {
	if(b[p] < 255 - n) b[p] += n; else b[p] = 0;
}

function decVal(n) {
	if(b[p] > n - 1) b[p] -= n; else b[p] = 255;
}

function echo(c) {
	r += c;
}
var isWS = (typeof(alert)=='undefined');
if(isWS) prompt = function() {WScript.Echo("Unable to run this program.\n'prompt' is not supported under Windows Script Host!");return "";};
main();
if(r!='') if(isWS) WScript.Echo(r); else alert(r);

 

is it obfuscated ? if yes how to get the original code ? so that i could understand what it does

any idea?

 

Link to comment
Share on other sites

It's obfuscated to some degree. There's no way to get the original code without asking the authors, since obfuscation involves renaming variables and functions to something meaningless.

Obfuscated code isn't impossible to understand, you just have read through the code and see what it is doing. It's a time consuming task so I will not be doing that. At a glance, I'd say this code is probably a convoluted way of pulling data out of a string that is mostly comprised of garbage.

Where did you find this code and why is it important to you?

Link to comment
Share on other sites

If my guess is correct, they have a string with a whole lot of useless data and the useful data is scattered within it. The code would be the way that they pull the useful data out.

That's just my guess and it's probably wrong, I haven't carefully analyzed the code. If you want to analyze the code, read it line by line and follow what's happening to each of the variables. Write it down on paper.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...