Advertisement
martadinata

cinject

Mar 27th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Cookie Injector
  3. // @namespace BearsWithWings
  4. // @description Inject Cookie String From Wireshark Dump Into Any Webpage
  5. // @include *
  6. // ==/UserScript==
  7.  
  8. //Anonomyous function wrapper
  9. (function (){
  10. //Ensure that there is only one instance of the cookieInjector Object
  11. if(typeof this["cookieInjector"] == "undefined"){
  12. cookieInjector = {};
  13. }
  14.  
  15. //Make a local refrence to the cookie Injector object to save on typing
  16. var cI = cookieInjector;
  17. //Make the cookieInjector object globally viewable
  18. unsafeWindow['cookieInjector'] = cI;
  19.  
  20. /**
  21. * Cookie Injector Onload Function
  22. * Sets up the cookie injector dialogu
  23. */
  24. cI.onLoad = function(){
  25. //Create the DIV to contain the Dialog
  26. cI.dialog = document.createElement('div');
  27. cI.dialog.id = "cookieInjectorDiv";
  28. cI.dialog.innerHTML = "<div align='center'>Wireshark-Cookie eingeben:<br/><input type='text' id='cookieInjectorCookie'/><br/><button onclick='cookieInjector.writeCookie();'>Gib dir</button><button onclick='cookieInjector.hide();'>Abbrechen</button></div>";
  29. cI.dialog.style.display = "none";
  30. cI.dialog.style.position = "fixed";
  31. cI.dialog.style.opacity = "0.9";
  32. cI.dialog.style.top = "40%";
  33. cI.dialog.style.background= "#DDDDDD";
  34. cI.dialog.style.left = "40%";
  35. cI.dialog.style.width = "20%";
  36. cI.dialog.style.zindex = "99999";
  37. document.body.appendChild(cI.dialog);
  38. cI.visible = false;
  39. }
  40.  
  41. /**
  42. * Show the dialog
  43. */
  44. cI.show = function(){
  45. cI.dialog.style.display = "block";
  46. cI.visible = true;
  47. }
  48.  
  49. /**
  50. * Hide the dialog
  51. */
  52. cI.hide = function(){
  53. cI.dialog.style.display = "none";
  54. cI.visible = false;
  55. }
  56.  
  57. /**
  58. * Gets the wireshark dump string and converts it into cookies
  59. */
  60. cI.writeCookie = function(){
  61. //Grab a handle to the text field which contains the string
  62. var cookieNode = document.getElementById('cookieInjectorCookie');
  63. var cookieText = cI.cleanCookie(cookieNode.value);
  64. cookieNode.value = "";
  65.  
  66. //We have to add the cookies one at a time, so split around the colin
  67. var cookieArray = cookieText.split(";");
  68. for(var x=0; x<cookieArray.length; x++){
  69. //We want the path to be the root, the host is filled in automatically
  70. //since we are on the same webpage that we captured the cookies on
  71. document.cookie = cookieArray[x]+"; path=/";
  72. }
  73.  
  74. alert("Ok. Druecke jetzt F5");
  75. cI.hide();
  76. }
  77.  
  78. /**
  79. * Do a little big of cleanup on the cookie string, Mostly we are looking
  80. * To get rid of the "Cookie: " string that Wireshark prepends to the cookie string
  81. */
  82. cI.cleanCookie = function(cookieText){
  83. var cookie = cookieText.replace("Cookie: ","");
  84. return cookie;
  85. }
  86.  
  87. /**
  88. * Handle all keypresses, we are looking for an ALT-C key-combo. Since we can't detect
  89. * Two keys being pressed at the same time, we first make sure the ALT key was pressed
  90. * then we wait to see if the C key is pressed next
  91. */
  92. cI.keyPress = function (e){
  93. //Check to see if "C" is pressed after ALT
  94. if(e.keyCode == 67 && cI.ctrlFire){
  95. if(!cI.visible){
  96. cI.show();
  97. }else{
  98. cI.hide();
  99. }
  100. }
  101.  
  102. //Make sure the Alt key was previously depressed
  103. if(e.keyCode == 18){
  104. cI.ctrlFire = true;
  105. }else{
  106. cI.ctrlFire = false;
  107. }
  108. }
  109.  
  110. //Setup our dialog after the document loads
  111. window.addEventListener('load', cI.onLoad,'false');
  112. //Capture all onkeydown events, so we can filter for our key-combo
  113. window.addEventListener('keydown', cI.keyPress,'false');
  114. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement