且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有可能快速连续重新加载iframe?

更新时间:2023-02-10 09:55:20

试试这个 b
$ b

 

< iframe id =iframe1>< / iframe>

I'm currently working on a project which includes testing XSS payloads in different browsers. The goal is to find out, if the payloads are still working, or not. The way I'm approaching this problem is by loading each payload in a seperate, or new, iframe. Since I will be testing a ton of payloads, simply specifying one dedicated iframe per payload doesn't seem feasible. Therefore I need to load the payloads into iframes one after another.

I've tried reloading the iframe by setting the src-Attribute of the iframe like the following:

function testing_iframe2(iframe_id,payload)
{
	//Does work one time, though not consecutively
	document.getElementById(iframe_id).src = "data:text/html," + payload;
}

testing_iframe2("frame1",'<button onfocus="alert(1)" autofocus>');
testing_iframe2("frame1",'<svg/onload="alert(4)">');

<html>
<body>
<iframe id="frame1" class="frames"></iframe>
</body>
</html>

As you can see, only the second payload is executed.

So here is my question:

Is it possible to load/reload/create+delete iframes in a quick succession?(Of course, any other solutions to the problem are gladly appreciated)

Try this

var iframe = document.getElementById("iframe1");
var testes = [
 '<svg onload="alert(1);" />',
 '<svg onload="alert(2);" />'
];


iframe.onload = function(){
  if(testes.length > 0){
    iframe.src = "data:text/html," + testes.shift();
  }
}

iframe.onload();

<iframe id="iframe1"></iframe>

上一篇 : :在MySQL数据库的不同字段中查找数字是否在两个数字之间下一篇 : 如果值在两个数字之间

相关阅读

技术问答最新文章