RTB技術總結--------神祕的iframe

在某個神祕的代碼技術研究,被老闆罵得狗血兩天。javascript

老闆說,你要縱觀全局,應該對RTB的思路是提出問題想法,比解決一個技術難點更加劇要。css

我只回了一句,沒有強大的技術支持,你的破思想都是浮雲。html

起初這個什麼iframe好奇,來自於tanx的動態廣告投放!java

對於這個神祕的iframe研究,昨天才有告終果,已經研究了一個月之久。我覺得神奇的oschina會有結果,結果,沒有結果的結果。仍是我本身來填補這個空缺。程序員

這RTB的研究博客將持續寫下去,都是一些特別的js,特別的用法。至少對於一個我這個java程序員來講。跑去研究javascript的核心,深深的對於、其餘dsp、dmp、adx 的js代碼感到神奇。app


一個月前的提問dom

http://www.oschina.net/question/1037462_231599 測試



這個我通過大量的測試,大量的js去實現ui

用到了純js去建立document標籤spa

var content = document.createElement("div");
			content.style.cssText="display:inline-block;position:relative;width:"+vlion_main.vlion_width+"px;height:"+vlion_main.vlion_high+"px;*display:inline;*zoom:1;";
			content.setAttribute("id","didi");
			content.innerHTML=data.src;
			var img= document.createElement("img");
			img.style.cssText="width:1px;height:1px;display:none;";
			img.src=data.pm;
			content.appendChild(img);

或者用

var div="<div id=\"vlion_image_div\" style=\"height:"+vlion_main.vlion_high+"px; width:"+vlion_main.vlion_width+"px; overflow:hidden; position:absolute\">" +
			"<a id=\"aw0\" target=\"_blank\" href=\""+data.cm+"\" border=\"0\"  class=\"img_ad\" onload=\"f\">" +
				"<img src=\""+data.src+"\" border=\"0\" width=\"100%\" height=\"100%\" class=\"img_ad\" >" +
			"</a>" +
			"</div>"+
			"<img src=\""+data.pm+"\" style=\"display: none;\">";


這樣的方式去上面連接裏面的提問的去解決這個沒有src 的神祕iframe。或者說去把iframe這個標籤怎麼實現的,去研究了編。。最終無果。。

可是昨天研究品友dsp代碼有告終果。。

固然任何RTB的js都是混淆代碼。對於一個java程序員來講,看這些混淆是多麼的蛋碎。功夫不負有心人!



我截取品友的核心實現代碼。而後本身重寫了一下,來重現這個問題

var r="setTimeout(function() {
var f=document;e = f.createElement('iframe');
e.src='http://cm.ipinyou.com/cma.html';
f.body.insertBefore(e,f.body.firstChild);
e.style.display='none';}, 5000)";

var i="http://stats.ipinyou.com/adv?a=Zs..XfPVEODYYsR1PBs506Sxg0&u=http%3A%2F%2Flocalhost%2Fqitadsp%2F1.html&pi=&p=&e=&rd=1431501551750";
var k=document;
var a = k.createElement("iframe");
 //a.src = "";
 a.style.display = "none";
  if (k.body) {
         k.body.insertBefore(a, k.body.firstChild);
         try {
        	 
			 c = a.contentWindow.document, c.write('<!doctype html><html><body onload="' + r + '"><script src="' + i + '"><\/script></body></html>'), c.close()
        } catch (d) {
            a.contentWindow.location.replace('javascript:void((function(){document.write("<!doctype html><html><body onload=\\"' + r + "\\\"><script>document.domain='" + document.domain + "';var s=document.createElement('script');document.body.insertBefore(s,document.body.firstChild);s.src='" + i + "';<\/script></body></html>\");document.close()})());")
        }
    } else {
       // setTimeout(j, 50)
    }



咱們來看一看效果的展現!

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

</head>
<body>
<script type="text/javascript">
var r="setTimeout(function() {var f=document;e = f.createElement('iframe');e.src='http://cm.ipinyou.com/cma.html';f.body.insertBefore(e,f.body.firstChild);e.style.display='none';}, 5000)";
var i="http://stats.ipinyou.com/adv?a=Zs..XfPVEODYYsR1PBs506Sxg0&u=http%3A%2F%2Flocalhost%2Fqitadsp%2F1.html&pi=&p=&e=&rd=1431501551750";
var k=document;
var a = k.createElement("iframe");
 //a.src = "";
 a.style.display = "none";
  if (k.body) {
         k.body.insertBefore(a, k.body.firstChild);
         try {
        	 
			 c = a.contentWindow.document, c.write('<!doctype html><html><body onload="' + r + '"><script src="' + i + '"><\/script></body></html>'), c.close()
        } catch (d) {
            a.contentWindow.location.replace('javascript:void((function(){document.write("<!doctype html><html><body onload=\\"' + r + "\\\"><script>document.domain='" + document.domain + "';var s=document.createElement('script');document.body.insertBefore(s,document.body.firstChild);s.src='" + i + "';<\/script></body></html>\");document.close()})());")
        }
    } else {
       // setTimeout(j, 50)
    }	


</script>
</body>
</html>






這樣一個神奇的沒有src的iframe就出來。。。。

很犀利很怪誕。。。一個沒有src的iframe說出去,都沒人信。可是事實他出來了。。。


好了這個研究了一個月的神奇現象就講解到這兒

相關文章
相關標籤/搜索