Example #1
0
        internal bool MarkUnhookedConnections(string sLookFor)
        {
            if (CONFIG.bIsViewOnly)
            {
                return(false);
            }
            bool result = false;

            foreach (WinINETConnectoid current in this._oConnectoids.Values)
            {
                if (current.bIsHooked)
                {
                    WinINETProxyInfo winINETProxyInfo = WinINETProxyInfo.CreateFromNamedConnection(current.sConnectionName);
                    bool             flag             = false;
                    if (!winINETProxyInfo.bUseManualProxies)
                    {
                        flag = true;
                    }
                    else
                    {
                        string text = winINETProxyInfo.CalculateProxyString();
                        if (text != sLookFor && !text.Contains("http=" + sLookFor))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        current.bIsHooked = false;
                        result            = true;
                    }
                }
            }
            return(result);
        }
Example #2
0
 internal void CollectConnectoidAndGatewayInfo()
 {
     this.oAllConnectoids = new WinINETConnectoids();
     this.piPrior         = this.oAllConnectoids.GetDefaultConnectionGatewayInfo();
     if (CONFIG.bForwardToGateway && ((this.piPrior.sPACScriptLocation != null) || this.piPrior.bAutoDetect))
     {
         this.oAutoProxy = new WinHTTPAutoProxy(this.piPrior.bAutoDetect, this.piPrior.sPACScriptLocation);
     }
     else if (this.oAutoProxy != null)
     {
         this.oAutoProxy.Dispose();
         this.oAutoProxy = null;
     }
     if (CONFIG.bForwardToGateway && this.piPrior.bUseManualProxies)
     {
         this._DetermineGatewayIPEndPoints();
         if (string.IsNullOrEmpty(this.piPrior.sHostsThatBypass))
         {
             this.oBypassList = null;
         }
         else
         {
             this.oBypassList = new ProxyBypassList(this.piPrior.sHostsThatBypass);
             if (!this.oBypassList.HasEntries)
             {
                 this.oBypassList = null;
             }
         }
     }
     else
     {
         this._ipepFtpGateway = this._ipepHttpGateway = (IPEndPoint)(this._ipepHttpsGateway = null);
         this.oBypassList     = null;
     }
 }
Example #3
0
 public bool Attach()
 {
     if (!this._bIsAttached)
     {
         this.CollectConnectoidAndGatewayInfo();
         WinINETProxyInfo oNewInfo = new WinINETProxyInfo {
             bUseManualProxies = true,
             bAllowDirect      = true,
             sHttpProxy        = CONFIG.sFiddlerListenHostPort
         };
         if (CONFIG.bCaptureCONNECT)
         {
             oNewInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort;
         }
         else
         {
             oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy;
         }
         if (this.piPrior.bUseManualProxies)
         {
             oNewInfo.sFtpProxy   = this.piPrior.sFtpProxy;
             oNewInfo.sSocksProxy = this.piPrior.sSocksProxy;
         }
         if (CONFIG.bCaptureFTP)
         {
             oNewInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort;
         }
         oNewInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler;
         if (CONFIG.bHookWithPAC)
         {
             if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true))
             {
                 oNewInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac");
             }
             else
             {
                 oNewInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac";
             }
         }
         if (!CONFIG.bIsViewOnly)
         {
             if (this.oAllConnectoids.HookConnections(oNewInfo))
             {
                 this._bIsAttached = true;
                 FiddlerApplication.OnFiddlerAttach();
                 this.WriteAutoProxyPACFile(true);
             }
             else
             {
                 FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error");
                 _setDynamicRegistryKey(false);
                 return(false);
             }
             _setDynamicRegistryKey(true);
         }
     }
     return(true);
 }
Example #4
0
 public WinINETConnectoids()
 {
     string[] connectionNames = RASInfo.GetConnectionNames();
     string[] array           = connectionNames;
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         if (CONFIG.bDebugSpew)
         {
             FiddlerApplication.DebugSpew("Collecting information for Connectoid '{0}'", new object[]
             {
                 text
             });
         }
         if (!this._oConnectoids.ContainsKey(text))
         {
             try
             {
                 WinINETProxyInfo winINETProxyInfo = WinINETProxyInfo.CreateFromNamedConnection(text);
                 if (winINETProxyInfo == null)
                 {
                     FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}'.", new object[]
                     {
                         text
                     });
                 }
                 else
                 {
                     WinINETConnectoid winINETConnectoid = new WinINETConnectoid();
                     winINETConnectoid.sConnectionName = text;
                     if (!string.IsNullOrEmpty(winINETProxyInfo.sHttpProxy) && winINETProxyInfo.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort))
                     {
                         FiddlerApplication.Log.LogString("When connecting, upstream proxy settings were already pointed at Fiddler. Clearing upstream proxy.");
                         winINETProxyInfo.sHttpProxy        = (winINETProxyInfo.sHttpsProxy = (winINETProxyInfo.sFtpProxy = null));
                         winINETProxyInfo.bUseManualProxies = false;
                         winINETProxyInfo.bAllowDirect      = true;
                     }
                     if (!string.IsNullOrEmpty(winINETProxyInfo.sPACScriptLocation) && (winINETProxyInfo.sPACScriptLocation == "file://" + CONFIG.GetPath("Pac") || winINETProxyInfo.sPACScriptLocation == "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac"))
                     {
                         FiddlerApplication.Log.LogString("When connecting, upstream proxy script was already pointed at Fiddler. Clearing upstream proxy.");
                         winINETProxyInfo.sPACScriptLocation = null;
                     }
                     winINETConnectoid.oOriginalProxyInfo = winINETProxyInfo;
                     this._oConnectoids.Add(text, winINETConnectoid);
                 }
             }
             catch (Exception eX)
             {
                 FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}' due to {1}", new object[]
                 {
                     text,
                     Utilities.DescribeException(eX)
                 });
             }
         }
     }
 }
        public static WinINETProxyInfo CreateFromNamedConnection(string sConnectionName)
        {
            WinINETProxyInfo info = new WinINETProxyInfo();

            if (info.GetFromWinINET(sConnectionName))
            {
                return(info);
            }
            return(null);
        }
Example #6
0
        public static WinINETProxyInfo CreateFromStrings(string sProxyString, string sBypassList)
        {
            WinINETProxyInfo winINETProxyInfo = new WinINETProxyInfo();
            WinINETProxyInfo arg_0F_0         = winINETProxyInfo;

            winINETProxyInfo._bAutoDetect = false;
            arg_0F_0._bUseConfigScript    = false;
            winINETProxyInfo._bDirect     = true;
            if (!string.IsNullOrEmpty(sProxyString))
            {
                winINETProxyInfo._bProxiesSpecified = true;
                winINETProxyInfo.SetManualProxies(sProxyString);
            }
            winINETProxyInfo.sHostsThatBypass = sBypassList;
            return(winINETProxyInfo);
        }
        internal bool HookConnections(WinINETProxyInfo oNewInfo)
        {
            if (CONFIG.bIsViewOnly)
            {
                return(false);
            }
            bool flag = false;

            foreach (WinINETConnectoid connectoid in this._oConnectoids.Values)
            {
                if ((CONFIG.bHookAllConnections || (connectoid.sConnectionName == CONFIG.sHookConnectionNamed)) && oNewInfo.SetToWinINET(connectoid.sConnectionName))
                {
                    flag = true;
                    connectoid.bIsHooked = true;
                }
            }
            return(flag);
        }
Example #8
0
        internal bool HookConnections(WinINETProxyInfo oNewInfo)
        {
            if (CONFIG.bIsViewOnly)
            {
                return(false);
            }
            bool result = false;

            foreach (WinINETConnectoid current in this._oConnectoids.Values)
            {
                if ((CONFIG.bHookAllConnections || current.sConnectionName == CONFIG.sHookConnectionNamed) && oNewInfo.SetToWinINET(current.sConnectionName))
                {
                    result            = true;
                    current.bIsHooked = true;
                }
            }
            return(result);
        }
Example #9
0
        internal WinINETProxyInfo GetDefaultConnectionGatewayInfo()
        {
            string text = CONFIG.sHookConnectionNamed;

            if (string.IsNullOrEmpty(text))
            {
                text = "DefaultLAN";
            }
            if (!this._oConnectoids.ContainsKey(text))
            {
                text = "DefaultLAN";
                if (!this._oConnectoids.ContainsKey(text))
                {
                    FiddlerApplication.Log.LogString("!WARNING: The DefaultLAN Gateway information could not be obtained.");
                    return(WinINETProxyInfo.CreateFromStrings(string.Empty, string.Empty));
                }
            }
            return(this._oConnectoids[text].oOriginalProxyInfo);
        }
Example #10
0
 private void AssignGateway(WinINETProxyInfo oPI)
 {
     this.piSystemGateway = oPI;
     if (this.piSystemGateway.bAutoDetect || this.piSystemGateway.sPACScriptLocation != null)
     {
         this.oAutoProxy = new WinHTTPAutoProxy(this.piSystemGateway.bAutoDetect, this.piSystemGateway.sPACScriptLocation);
     }
     if (this.piSystemGateway.bUseManualProxies)
     {
         this._DetermineGatewayIPEndPoints();
         if (!string.IsNullOrEmpty(this.piSystemGateway.sHostsThatBypass))
         {
             this.oBypassList = new ProxyBypassList(this.piSystemGateway.sHostsThatBypass);
             if (!this.oBypassList.HasEntries)
             {
                 this.oBypassList = null;
             }
         }
     }
 }
Example #11
0
        internal void RefreshUpstreamGatewayInformation()
        {
            this._ipepFtpGateway = (this._ipepHttpGateway = (this._ipepHttpsGateway = null));
            this.piSystemGateway = null;
            this.oBypassList     = null;
            if (this.oAutoProxy != null)
            {
                this.oAutoProxy.Dispose();
                this.oAutoProxy = null;
            }
            switch (CONFIG.UpstreamGateway)
            {
            case GatewayType.None:
                FiddlerApplication.Log.LogString("Setting upstream gateway to none");
                return;

            case GatewayType.Manual:
            {
                WinINETProxyInfo oPI = WinINETProxyInfo.CreateFromStrings(FiddlerApplication.Prefs.GetStringPref("fiddler.network.gateway.proxies", string.Empty), FiddlerApplication.Prefs.GetStringPref("fiddler.network.gateway.exceptions", string.Empty));
                this.AssignGateway(oPI);
                return;
            }

            case GatewayType.System:
                this.AssignGateway(this.oAllConnectoids.GetDefaultConnectionGatewayInfo());
                return;

            case GatewayType.WPAD:
                FiddlerApplication.Log.LogString("Setting upstream gateway to WPAD");
                this.oAutoProxy = new WinHTTPAutoProxy(true, null);
                return;

            default:
                return;
            }
        }
 public WinINETConnectoids()
 {
     foreach (string str in RASInfo.GetConnectionNames())
     {
         if (!this._oConnectoids.ContainsKey(str))
         {
             WinINETProxyInfo info = WinINETProxyInfo.CreateFromNamedConnection(str);
             if (info != null)
             {
                 WinINETConnectoid connectoid = new WinINETConnectoid {
                     sConnectionName = str
                 };
                 if ((info.sHttpProxy != null) && info.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort))
                 {
                     info.sHttpProxy        = info.sHttpsProxy = (string)(info.sFtpProxy = null);
                     info.bUseManualProxies = false;
                     info.bAllowDirect      = true;
                 }
                 connectoid.oOriginalProxyInfo = info;
                 this._oConnectoids.Add(str, connectoid);
             }
         }
     }
 }
Example #13
0
 private void AssignGateway(WinINETProxyInfo oPI)
 {
     this.piSystemGateway = oPI;
     if (this.piSystemGateway.bAutoDetect || (this.piSystemGateway.sPACScriptLocation != null))
     {
         this.oAutoProxy = new WinHTTPAutoProxy(this.piSystemGateway.bAutoDetect, this.piSystemGateway.sPACScriptLocation);
     }
     if (this.piSystemGateway.bUseManualProxies)
     {
         this._DetermineGatewayIPEndPoints();
         if (!string.IsNullOrEmpty(this.piSystemGateway.sHostsThatBypass))
         {
             this.oBypassList = new ProxyBypassList(this.piSystemGateway.sHostsThatBypass);
             if (!this.oBypassList.HasEntries)
             {
                 this.oBypassList = null;
             }
         }
     }
 }
Example #14
0
        internal bool SetToWinINET(string sConnectionName)
        {
            bool result;

            try
            {
                WinINETProxyInfo.INTERNET_PER_CONN_OPTION_LIST iNTERNET_PER_CONN_OPTION_LIST = default(WinINETProxyInfo.INTERNET_PER_CONN_OPTION_LIST);
                WinINETProxyInfo.INTERNET_PER_CONN_OPTION[]    array = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION[5];
                if (sConnectionName == "DefaultLAN")
                {
                    sConnectionName = null;
                }
                iNTERNET_PER_CONN_OPTION_LIST.Connection  = sConnectionName;
                iNTERNET_PER_CONN_OPTION_LIST.OptionCount = array.Length;
                iNTERNET_PER_CONN_OPTION_LIST.OptionError = 0;
                int num = 0;
                if (this._bDirect)
                {
                    num |= 1;
                }
                if (this._bAutoDetect)
                {
                    num |= 8;
                }
                if (this._bAutoDetectWasUserSet)
                {
                    num |= 8;
                }
                if (this._bUseConfigScript)
                {
                    num |= 4;
                }
                if (this._bProxiesSpecified)
                {
                    num |= 2;
                }
                array[0]                = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[0].dwOption       = 1;
                array[0].Value.dwValue  = num;
                array[1]                = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[1].dwOption       = 2;
                array[1].Value.pszValue = Marshal.StringToHGlobalAnsi(this.CalculateProxyString());
                array[2]                = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[2].dwOption       = 3;
                array[2].Value.pszValue = Marshal.StringToHGlobalAnsi(this._sHostsThatBypass);
                array[3]                = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[3].dwOption       = 4;
                array[3].Value.pszValue = Marshal.StringToHGlobalAnsi(this._sScriptURL);
                array[4]                = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[4].dwOption       = 5;
                array[4].Value.dwValue  = 0;
                if (this._bAutoDetectWasUserSet)
                {
                    array[4].Value.dwValue = 1;
                }
                int num2 = 0;
                for (int i = 0; i < array.Length; i++)
                {
                    num2 += Marshal.SizeOf(array[i]);
                }
                IntPtr intPtr  = Marshal.AllocCoTaskMem(num2);
                IntPtr intPtr2 = intPtr;
                for (int j = 0; j < array.Length; j++)
                {
                    Marshal.StructureToPtr(array[j], intPtr2, false);
                    intPtr2 = (IntPtr)((long)intPtr2 + (long)Marshal.SizeOf(array[j]));
                }
                iNTERNET_PER_CONN_OPTION_LIST.pOptions = intPtr;
                iNTERNET_PER_CONN_OPTION_LIST.Size     = Marshal.SizeOf(iNTERNET_PER_CONN_OPTION_LIST);
                int  size           = iNTERNET_PER_CONN_OPTION_LIST.Size;
                bool flag           = WinINETProxyInfo.InternetSetOption_1(IntPtr.Zero, 75, ref iNTERNET_PER_CONN_OPTION_LIST, size);
                int  lastWin32Error = Marshal.GetLastWin32Error();
                if (flag)
                {
                    WinINETProxyInfo.InternetSetOption(IntPtr.Zero, 95, IntPtr.Zero, 0);
                }
                else
                {
                    Trace.WriteLine("[Fiddler] SetProxy failed. WinINET Error #" + lastWin32Error.ToString("x"));
                }
                Marshal.FreeHGlobal(array[0].Value.pszValue);
                Marshal.FreeHGlobal(array[1].Value.pszValue);
                Marshal.FreeHGlobal(array[2].Value.pszValue);
                Marshal.FreeCoTaskMem(intPtr);
                result = flag;
            }
            catch (Exception ex)
            {
                Trace.WriteLine("[Fiddler] SetProxy failed. " + ex.Message);
                result = false;
            }
            return(result);
        }
Example #15
0
        public bool GetFromWinINET(string sConnectionName)
        {
            this.Clear();
            bool result;

            try
            {
                WinINETProxyInfo.INTERNET_PER_CONN_OPTION_LIST iNTERNET_PER_CONN_OPTION_LIST = default(WinINETProxyInfo.INTERNET_PER_CONN_OPTION_LIST);
                WinINETProxyInfo.INTERNET_PER_CONN_OPTION[]    array = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION[5];
                if (sConnectionName == "DefaultLAN")
                {
                    sConnectionName = null;
                }
                iNTERNET_PER_CONN_OPTION_LIST.Connection  = sConnectionName;
                iNTERNET_PER_CONN_OPTION_LIST.OptionCount = array.Length;
                iNTERNET_PER_CONN_OPTION_LIST.OptionError = 0;
                array[0]          = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[0].dwOption = 1;
                array[1]          = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[1].dwOption = 2;
                array[2]          = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[2].dwOption = 3;
                array[3]          = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[3].dwOption = 4;
                array[4]          = new WinINETProxyInfo.INTERNET_PER_CONN_OPTION();
                array[4].dwOption = 10;
                int num = 0;
                for (int i = 0; i < array.Length; i++)
                {
                    num += Marshal.SizeOf(array[i]);
                }
                IntPtr intPtr  = Marshal.AllocCoTaskMem(num);
                IntPtr intPtr2 = intPtr;
                for (int j = 0; j < array.Length; j++)
                {
                    Marshal.StructureToPtr(array[j], intPtr2, false);
                    intPtr2 = (IntPtr)((long)intPtr2 + (long)Marshal.SizeOf(array[j]));
                }
                iNTERNET_PER_CONN_OPTION_LIST.pOptions = intPtr;
                iNTERNET_PER_CONN_OPTION_LIST.Size     = Marshal.SizeOf(iNTERNET_PER_CONN_OPTION_LIST);
                int  size           = iNTERNET_PER_CONN_OPTION_LIST.Size;
                bool flag           = WinINETProxyInfo.InternetQueryOption(IntPtr.Zero, 75, ref iNTERNET_PER_CONN_OPTION_LIST, ref size);
                int  lastWin32Error = Marshal.GetLastWin32Error();
                if (!flag)
                {
                    if (87 == lastWin32Error)
                    {
                        array[4].dwOption = 5;
                        intPtr2           = intPtr;
                        for (int k = 0; k < array.Length; k++)
                        {
                            Marshal.StructureToPtr(array[k], intPtr2, false);
                            intPtr2 = (IntPtr)((long)intPtr2 + (long)Marshal.SizeOf(array[k]));
                        }
                        iNTERNET_PER_CONN_OPTION_LIST.pOptions = intPtr;
                        iNTERNET_PER_CONN_OPTION_LIST.Size     = Marshal.SizeOf(iNTERNET_PER_CONN_OPTION_LIST);
                        size           = iNTERNET_PER_CONN_OPTION_LIST.Size;
                        flag           = WinINETProxyInfo.InternetQueryOption(IntPtr.Zero, 75, ref iNTERNET_PER_CONN_OPTION_LIST, ref size);
                        lastWin32Error = Marshal.GetLastWin32Error();
                    }
                    if (!flag)
                    {
                        FiddlerApplication.Log.LogFormat("Fiddler was unable to get information about the proxy for '{0}' [0x{1}].\n", new object[]
                        {
                            sConnectionName ?? "DefaultLAN",
                            lastWin32Error.ToString("x")
                        });
                    }
                }
                if (flag)
                {
                    intPtr2 = intPtr;
                    for (int l = 0; l < array.Length; l++)
                    {
                        Marshal.PtrToStructure(intPtr2, array[l]);
                        intPtr2 = (IntPtr)((long)intPtr2 + (long)Marshal.SizeOf(array[l]));
                    }
                    this._bDirect           = (1 == (array[0].Value.dwValue & 1));
                    this._bUseConfigScript  = (4 == (array[0].Value.dwValue & 4));
                    this._bAutoDetect       = (8 == (array[0].Value.dwValue & 8));
                    this._bProxiesSpecified = (2 == (array[0].Value.dwValue & 2));
                    if (array[4].dwOption == 10)
                    {
                        this._bAutoDetectWasUserSet = (8 == (array[4].Value.dwValue & 8));
                    }
                    else
                    {
                        this._bAutoDetectWasUserSet = (this._bAutoDetect && 1 == (array[4].Value.dwValue & 1));
                    }
                    this._sScriptURL = Marshal.PtrToStringAnsi(array[3].Value.pszValue);
                    Utilities.GlobalFree(array[3].Value.pszValue);
                    if (array[1].Value.pszValue != IntPtr.Zero)
                    {
                        string manualProxies = Marshal.PtrToStringAnsi(array[1].Value.pszValue);
                        Utilities.GlobalFree(array[1].Value.pszValue);
                        this.SetManualProxies(manualProxies);
                    }
                    if (array[2].Value.pszValue != IntPtr.Zero)
                    {
                        this._sHostsThatBypass = Marshal.PtrToStringAnsi(array[2].Value.pszValue);
                        Utilities.GlobalFree(array[2].Value.pszValue);
                    }
                }
                Marshal.FreeCoTaskMem(intPtr);
                result = flag;
            }
            catch (Exception eX)
            {
                FiddlerApplication.ReportException(eX, "Unable to get proxy information for " + (sConnectionName ?? "DefaultLAN"));
                result = false;
            }
            return(result);
        }
 internal bool HookConnections(WinINETProxyInfo oNewInfo)
 {
     if (CONFIG.bIsViewOnly)
     {
         return false;
     }
     bool flag = false;
     foreach (WinINETConnectoid connectoid in this._oConnectoids.Values)
     {
         if ((CONFIG.bHookAllConnections || (connectoid.sConnectionName == CONFIG.sHookConnectionNamed)) && oNewInfo.SetToWinINET(connectoid.sConnectionName))
         {
             flag = true;
             connectoid.bIsHooked = true;
         }
     }
     return flag;
 }
 public static WinINETProxyInfo CreateFromStrings(string sProxyString, string sBypassList)
 {
     WinINETProxyInfo info;
     info = new WinINETProxyInfo {
         _bUseConfigScript = false,
         _bAutoDetect = false,
         _bDirect = true
     };
     if (!string.IsNullOrEmpty(sProxyString))
     {
         info._bProxiesSpecified = true;
         info.SetManualProxies(sProxyString);
     }
     info.sHostsThatBypass = sBypassList;
     return info;
 }
Example #18
0
        internal void RefreshUpstreamGatewayInformation()
        {
            this._ipepFtpGateway = this._ipepHttpGateway = (IPEndPoint) (this._ipepHttpsGateway = null);
            this.piSystemGateway = null;
            this.oBypassList = null;
            if (this.oAutoProxy != null)
            {
                this.oAutoProxy.Dispose();
                this.oAutoProxy = null;
            }
            switch (CONFIG.UpstreamGateway)
            {
                case GatewayType.None:
                    FiddlerApplication.Log.LogString("Setting upstream gateway to none");
                    return;

                case GatewayType.Manual:
                {
                    WinINETProxyInfo oPI = WinINETProxyInfo.CreateFromStrings(FiddlerApplication.Prefs.GetStringPref("fiddler.network.gateway.proxies", string.Empty), FiddlerApplication.Prefs.GetStringPref("fiddler.network.gateway.exceptions", string.Empty));
                    this.AssignGateway(oPI);
                    return;
                }
                case GatewayType.System:
                    this.AssignGateway(this.oAllConnectoids.GetDefaultConnectionGatewayInfo());
                    return;

                case GatewayType.WPAD:
                    FiddlerApplication.Log.LogString("Setting upstream gateway to WPAD");
                    this.oAutoProxy = new WinHTTPAutoProxy(true, null);
                    return;
            }
        }
Example #19
0
        internal bool Attach(bool bCollectGWInfo)
        {
            if (this._bIsAttached)
            {
                return(true);
            }
            if (CONFIG.bIsViewOnly)
            {
                return(false);
            }
            if (bCollectGWInfo)
            {
                this.CollectConnectoidAndGatewayInfo();
            }
            WinINETProxyInfo winINETProxyInfo = new WinINETProxyInfo();

            winINETProxyInfo.bUseManualProxies = true;
            winINETProxyInfo.bAllowDirect      = true;
            winINETProxyInfo.sHttpProxy        = CONFIG.sFiddlerListenHostPort;
            if (CONFIG.bCaptureCONNECT)
            {
                winINETProxyInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort;
            }
            else
            {
                if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies)
                {
                    winINETProxyInfo.sHttpsProxy = this.piSystemGateway.sHttpsProxy;
                }
            }
            if (CONFIG.bCaptureFTP)
            {
                winINETProxyInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort;
            }
            else
            {
                if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies)
                {
                    winINETProxyInfo.sFtpProxy = this.piSystemGateway.sFtpProxy;
                }
            }
            if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies)
            {
                winINETProxyInfo.sSocksProxy = this.piSystemGateway.sSocksProxy;
            }
            winINETProxyInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler;
            if (CONFIG.bHookWithPAC)
            {
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true))
                {
                    winINETProxyInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac");
                }
                else
                {
                    winINETProxyInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac";
                }
            }
            if (this.oAllConnectoids == null)
            {
                this.CollectConnectoidAndGatewayInfo();
            }
            if (this.oAllConnectoids.HookConnections(winINETProxyInfo))
            {
                this._bIsAttached = true;
                FiddlerApplication.OnFiddlerAttach();
                this.WriteAutoProxyPACFile(true);
                if (this.oRegistryWatcher == null && FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.WatchRegistry", true))
                {
                    this.oRegistryWatcher = RegistryWatcher.WatchKey(RegistryHive.CurrentUser, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", new EventHandler(this.ProxyRegistryKeysChanged));
                }
                Proxy._setDynamicRegistryKey(true);
                return(true);
            }
            FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error");
            Proxy._setDynamicRegistryKey(false);
            return(false);
        }
 public static WinINETProxyInfo CreateFromNamedConnection(string sConnectionName)
 {
     WinINETProxyInfo info = new WinINETProxyInfo();
     if (info.GetFromWinINET(sConnectionName))
     {
         return info;
     }
     return null;
 }
Example #21
0
 internal bool Attach(bool bCollectGWInfo)
 {
     if (!this._bIsAttached)
     {
         if (CONFIG.bIsViewOnly)
         {
             return false;
         }
         if (bCollectGWInfo)
         {
             this.CollectConnectoidAndGatewayInfo();
         }
         WinINETProxyInfo oNewInfo = new WinINETProxyInfo {
             bUseManualProxies = true,
             bAllowDirect = true,
             sHttpProxy = CONFIG.sFiddlerListenHostPort
         };
         if (CONFIG.bCaptureCONNECT)
         {
             oNewInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort;
         }
         else if ((this.piSystemGateway != null) && this.piSystemGateway.bUseManualProxies)
         {
             oNewInfo.sHttpsProxy = this.piSystemGateway.sHttpsProxy;
         }
         if (CONFIG.bCaptureFTP)
         {
             oNewInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort;
         }
         else if ((this.piSystemGateway != null) && this.piSystemGateway.bUseManualProxies)
         {
             oNewInfo.sFtpProxy = this.piSystemGateway.sFtpProxy;
         }
         if ((this.piSystemGateway != null) && this.piSystemGateway.bUseManualProxies)
         {
             oNewInfo.sSocksProxy = this.piSystemGateway.sSocksProxy;
         }
         oNewInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler;
         if (CONFIG.bHookWithPAC)
         {
             if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true))
             {
                 oNewInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac");
             }
             else
             {
                 oNewInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac";
             }
         }
         if (this.oAllConnectoids == null)
         {
             this.CollectConnectoidAndGatewayInfo();
         }
         if (this.oAllConnectoids.HookConnections(oNewInfo))
         {
             this._bIsAttached = true;
             FiddlerApplication.OnFiddlerAttach();
             this.WriteAutoProxyPACFile(true);
             //if ((this.oRegistryWatcher == null) && FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.WatchRegistry", true))
             //{
                 //this.oRegistryWatcher = RegistryWatcher.WatchKey(RegistryHive.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Internet Settings", new EventHandler(this.ProxyRegistryKeysChanged));
             //}
         }
         else
         {
             FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error");
             _setDynamicRegistryKey(false);
             return false;
         }
         _setDynamicRegistryKey(true);
     }
     return true;
 }