Advertisement
Guest User

JS Secure by Dessy Boris

a guest
Feb 6th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.35 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Test JS secure</title>
  6. </head>
  7. <body>
  8.  
  9. <div id='tt'>
  10.     try to get me, my id is "tt"<br/>
  11.     write in address url : <br/>
  12.     javascript:alert(1);<br/>
  13.     javascript:tmp_alert(1);<br/>
  14.     javascript:tmp_alert(document.getElementById('tt'));<br/>
  15.     then click here and you'll see as the "alert" AND the "getElementById" are still working ... only protected from you^^
  16. </div>
  17.  
  18. <script type="text/javascript">
  19.  
  20.  
  21. // secure
  22.  
  23.  
  24. (function(){
  25.    
  26.     // overwrite/protect WINDOW.functions
  27.     var alert = window.alert;
  28.    
  29.     // overwrite/protect DOCUMENT.functions
  30.     var document_getElementById = document.getElementById;
  31.     var d = {};  
  32.     d.getElementById = function(){var r = document_getElementById.apply(document,arguments);return r;};
  33.          
  34.     // sample    
  35.     d.getElementById("tt").onclick=function(){alert(d.getElementById("tt"));this.style.display='none';alert(d.getElementById("tt"));};
  36.          
  37.          
  38. })();
  39.  
  40.     // erase this next line and nobody'll can do "alert" anymore .. execpt you in the previous code^^
  41.     var tmp_alert = alert;
  42.  
  43.     window.alert = null;
  44.     document.getElementById = null;
  45.  
  46.  
  47. </script>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement