» Programming » JavaScript » Self Replicator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<script>
	var x = 'document.write(\'<form id="jstest" name="jstest"><textarea rows="23" cols="192" name="txt"></textarea></form><h3>Copyright &copy; 2004 Vincent E Milum Jr</h3>\')';
	var y = x.replace(/'/g, "\\\'");
	var z = '<scri' + 'pt>\n' +
'	var x = \'document.write(\\\'<form id="jstest" name="jstest"><textarea rows="23" cols="192" name="txt"></textarea></form><h3>Copyright &copy; 2004 Vincent E Milum Jr</h3>\\\')\';\n' +
'	var y = x.replace(/\'/g, "\\\\\\\'");\n' +
'	var z = \'XXX\';\n' +
'	var z2 = z.replace(/\\\\/g, "\\\\\\\\");\n' +
'	var z2 = z2.replace(/\\\'/g, "\\\\\\\'");\n' +
'	var z2 = z2.replace(/scri' + 'pt/g, "scri\\\' + \\\'pt");\n' +
'	var z2 = z2.replace(/\\n/g, "\\\\n\\\' +\\n\\\'");\n' +
'	z = z.replace(/XXX/, z2);\n' +
'	document.write(\'<scri\' + \'pt>\' + x + \'</scri\' + \'pt>\');\n' +
'	document.jstest.txt.value = z;\n' +
'</scri' + 'pt>';
	var z2 = z.replace(/\\/g, "\\\\");
	var z2 = z2.replace(/\'/g, "\\\'");
	var z2 = z2.replace(/script/g, "scri\' + \'pt");
	var z2 = z2.replace(/\n/g, "\\n\' +\n\'");
	z = z.replace(/XXX/, z2);
	document.write('<scri' + 'pt>' + x + '</scri' + 'pt>');
	document.jstest.txt.value = z;
</script>