我希望能够格式化我的字符串并复制相同的代码(不是用于攻击,而是用于演示):
window.onload = function() {
alert("hello Silly");
var attack = [
'window.onload = function() {',
' alert("hello Silly");',
' var attack = [',
' ];',
' var profile = new String();',
' for (var i = 0; i < attack.length; i++) {',
' profile += attack[i];',
' }',
' console.log(profile);',
'}'
];
var profile = new String();
for (var i = 0; i < 3; i++) {
profile += attack[i];
}
for (var i = 0; i < attack.length; i++) {
profile += attack[i];
}
for (var i = 4; i < attack.length; i++) {
profile += attack[i];
}
console.log(profile);
}
这个想法是让脚本递归地执行自己,例如注入...但是,我担心我错过了复制中的递归步骤...
**编辑**
根据建议,我添加了大部分代码,但是我仍然错过了递归步骤...如何将attack
复制到attack
字符串?