Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Anti Frame Breaker Code

Anti Frame Breaker Code

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpcomdesignsecurityhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stambekar
    wrote on last edited by
    #1

    Hi all Need help on frame breaker code. i have a page with two frames in it.the pages are built in PHP. the first page displays page from my site whereas the second frame displays page from the other site for which i do not have control on. but for some sites that do have a frame breaker code in them, those pages open in the parent window rather than opening in the frame. have tried the security TAG in Iframe but it works only in IE. for mozilla its of no use. tried a few things but to no effect. tried from this link http://coderrr.wordpress.com/2009/02/13/preventing-frame-busting-and-click-jacking-ui-redressing/[^] is it even possibe to do so. Pls help Thanks in Advance. :) Sandeep

    enhzflepE 1 Reply Last reply
    0
    • S stambekar

      Hi all Need help on frame breaker code. i have a page with two frames in it.the pages are built in PHP. the first page displays page from my site whereas the second frame displays page from the other site for which i do not have control on. but for some sites that do have a frame breaker code in them, those pages open in the parent window rather than opening in the frame. have tried the security TAG in Iframe but it works only in IE. for mozilla its of no use. tried a few things but to no effect. tried from this link http://coderrr.wordpress.com/2009/02/13/preventing-frame-busting-and-click-jacking-ui-redressing/[^] is it even possibe to do so. Pls help Thanks in Advance. :) Sandeep

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      It seems to me, that the way I'd approach it is to do a GET on the desired page, scan the page for any offending code and fix as required. From the 2minute primer i've just had, it looks like a couple of prime strings to be commented out are "top.location= xxxxxxx" and "top.location.replace" I guess I'd just try loading the page into a string, and inserting a pair of '/' characters at the start of any line that contains either of the two strings I mentioned. That way, you've killed the javascript before it ever had a chance.:cool:

      S 1 Reply Last reply
      0
      • enhzflepE enhzflep

        It seems to me, that the way I'd approach it is to do a GET on the desired page, scan the page for any offending code and fix as required. From the 2minute primer i've just had, it looks like a couple of prime strings to be commented out are "top.location= xxxxxxx" and "top.location.replace" I guess I'd just try loading the page into a string, and inserting a pair of '/' characters at the start of any line that contains either of the two strings I mentioned. That way, you've killed the javascript before it ever had a chance.:cool:

        S Offline
        S Offline
        stambekar
        wrote on last edited by
        #3

        hi enhzflep thanks for the reply. can u pls elaborate with the code so that i can understand it. also if we try to get a page in a string and strip of the Javascript(frame breaker code) then what is the way to display the stripped content in a iframe. please have a look at the following link http://www.iframehtml.com/iframe-scripts.html[^] it tells way to strip the JS from the page but how to display that page in a iframe then Regards Sandeep.

        enhzflepE 1 Reply Last reply
        0
        • S stambekar

          hi enhzflep thanks for the reply. can u pls elaborate with the code so that i can understand it. also if we try to get a page in a string and strip of the Javascript(frame breaker code) then what is the way to display the stripped content in a iframe. please have a look at the following link http://www.iframehtml.com/iframe-scripts.html[^] it tells way to strip the JS from the page but how to display that page in a iframe then Regards Sandeep.

          enhzflepE Offline
          enhzflepE Offline
          enhzflep
          wrote on last edited by
          #4

          That's okay Sandeep. Thank-you for introducing me to the whole concept. It's been rather an interesting exercise. I've had a little play around, and come up with some code that will kill the framebuster in a page that I've been playing with. It's a two-file approach. There's the html file that makes the request, and the php file that retrieves the requested file then strips the offending code from it. In my simple example, I simply replace "top.location=self.location;" with "alert('Framebuster busted!');" All you'll have to do is to find, download and compress AjaxRequest.js (EDIT: http://www.ajaxtoolbox.com/request/source.php) [EDIT: No, you don't. I forgot I used a different method. Anyhow, it's still a good library] Here's some code to play with: 1. getPage.php

          .*?<\/script>/i", "", $filter); */

          // if($allowed&4 == 0) // 4

          2. showInIFrame.html

          Untitled Document

          function onGoBtn()
          {
          var url, ifrm, src;
          url = document.getElementById("urlInput").value;
          ifrm = document.getElementById("tgtFrame");
          src = "getPage.php?tgt="+url+"&rand="+parseInt(Math.random()*100);
          ifrm.src = src;
          }

          URL

          Load into IFrame

          Target Frame

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups