Ejemplo n.º 1
0
        //internal object _GetTransportContext()
        //{
        //    if (base._httpsStream != null)
        //    {
        //        return base._httpsStream.get_TransportContext();
        //    }
        //    return null;
        //}

        private X509Certificate AttachClientCertificate(Session oS, object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers)
        {
            if (localCertificates.Count > 0)
            {
                this.MarkAsAuthenticated(oS.LocalProcessID);
                oS.oFlags["x-client-cert"] = localCertificates[0].Subject + " Serial#" + localCertificates[0].GetSerialNumberString();
                return(localCertificates[0]);
            }
            if ((remoteCertificate != null) || (acceptableIssuers.Length >= 1))
            {
                X509Certificate certificate = this._GetDefaultCertificate();
                if (certificate != null)
                {
                    this.MarkAsAuthenticated(oS.LocalProcessID);
                    oS.oFlags["x-client-cert"] = certificate.Subject + " Serial#" + certificate.GetSerialNumberString();
                    return(certificate);
                }
                if (Browser.bShowDefaultClientCertificateNeededPrompt && SDVPApplication.Prefs.GetBoolPref("SDVP.network.https.clientcertificate.ephemeral.prompt-for-missing", true))
                {
                    SDVPApplication.DoNotifyUser("The server [" + targetHost + "] requests a client certificate.\nPlease save a client certificate using the filename:\n\n" + Browser.GetPath("DefaultClientCertificate"), "Client Certificate Requested");
                    SDVPApplication.Prefs.SetBoolPref("SDVP.network.https.clientcertificate.ephemeral.prompt-for-missing", false);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
 internal bool Attach(bool bCollectGWInfo)
 {
     if (!this._bIsAttached)
     {
         if (bCollectGWInfo)
         {
             this.CollectConnectoidAndGatewayInfo();
         }
         WinINETProxyInfo oNewInfo = new WinINETProxyInfo();
         oNewInfo.bUseManualProxies = true;
         oNewInfo.bAllowDirect      = true;
         oNewInfo.sHttpProxy        = Browser.sSDVPListenHostPort;
         if (Browser.bCaptureCONNECT)
         {
             oNewInfo.sHttpsProxy = Browser.sSDVPListenHostPort;
         }
         else if (this.piPrior != null)
         {
             oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy;
         }
         if ((this.piPrior != null) && this.piPrior.bUseManualProxies)
         {
             oNewInfo.sFtpProxy   = this.piPrior.sFtpProxy;
             oNewInfo.sSocksProxy = this.piPrior.sSocksProxy;
         }
         if (Browser.bCaptureFTP)
         {
             oNewInfo.sFtpProxy = Browser.sSDVPListenHostPort;
         }
         oNewInfo.sHostsThatBypass = Browser.sHostsThatBypassSDVP;
         if (Browser.bHookWithPAC)
         {
             if (SDVPApplication.Prefs.GetBoolPref("SDVP.proxy.pacfile.usefileprotocol", true))
             {
                 oNewInfo.sPACScriptLocation = "file://" + Browser.GetPath("Pac");
             }
             else
             {
                 oNewInfo.sPACScriptLocation = "http://" + Browser.sSDVPListenHostPort + "/proxy.pac";
             }
         }
         if (!Browser.bIsViewOnly)
         {
             if (this.oAllConnectoids.HookConnections(oNewInfo))
             {
                 this._bIsAttached = true;
                 SDVPApplication.OnSDVPAttach();
                 this.WriteAutoProxyPACFile(true);
             }
             else
             {
                 SDVPApplication.DoNotifyUser("Failed to register SDVP as the system proxy.", "Error");
                 _setDynamicRegistryKey(false);
                 return(false);
             }
             _setDynamicRegistryKey(true);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
        internal bool SecureClientPipe(string sHostname, HTTPResponseHeaders oHeaders)
        {
            X509Certificate2 certificate;

            try
            {
                certificate = CertMaker.FindCert(sHostname, true);
            }
            catch (Exception exception)
            {
                //SDVPApplication.Log.LogFormat("SDVP.https> Failed to obtain certificate for {0} due to {1}", new object[] { sHostname, exception.Message });
                certificate = null;
            }
            try
            {
                if (certificate == null)
                {
                    SDVPApplication.DoNotifyUser("Unable to find Certificate for " + sHostname, "HTTPS Interception Failure");
                    oHeaders.HTTPResponseCode   = 0x1f6;
                    oHeaders.HTTPResponseStatus = "502 SDVP unable to generate certificate";
                }
                if (Browser.bDebugSpew)
                {
                    SDVPApplication.DebugSpew("SecureClientPipe for: " + this.ToString() + " sending data to client:\n" + Utilities.ByteArrayToHexView(oHeaders.ToByteArray(true, true), 0x20));
                }
                base.Send(oHeaders.ToByteArray(true, true));
                if (oHeaders.HTTPResponseCode != 200)
                {
                    SDVPApplication.DebugSpew("SecureClientPipe returning FALSE because HTTPResponseCode != 200");
                    return(false);
                }
                base._httpsStream = new SslStream(new NetworkStream(base._baseSocket, false), false);
                base._httpsStream.AuthenticateAsServer(certificate, _bWantClientCert, Browser.oAcceptedClientHTTPSProtocols, false);
                return(true);
            }
            catch (Exception exception2)
            {
                //SDVPApplication.Log.LogFormat("Secure client pipe failed: {0}{1}.", new object[] { exception2.Message, (exception2.InnerException == null) ? string.Empty : (" InnerException: " + exception2.InnerException.Message) });
                SDVPApplication.DebugSpew("Secure client pipe failed: " + exception2.Message);
                try
                {
                    base.End();
                }
                catch (Exception)
                {
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
 private void ScanPathForTranscoders(string sPath)
 {
     try
     {
         if (Directory.Exists(sPath))
         {
             Evidence securityEvidence = Assembly.GetExecutingAssembly().Evidence;
             bool     boolPref         = SDVPApplication.Prefs.GetBoolPref("SDVP.debug.extensions.verbose", false);
             if (boolPref)
             {
                 //SDVPApplication.Log.LogFormat("Searching for Transcoders under {0}", new object[] { sPath });
             }
             foreach (FileInfo info in new DirectoryInfo(sPath).GetFiles())
             {
                 if (info.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !info.FullName.StartsWith("_", StringComparison.OrdinalIgnoreCase))
                 {
                     Assembly assembly;
                     if (boolPref)
                     {
                         //SDVPApplication.Log.LogFormat("Looking for Transcoders inside {0}", new object[] { info.FullName.ToString() });
                     }
                     try
                     {
                         if (Browser.bRunningOnCLRv4)
                         {
                             assembly = Assembly.LoadFrom(info.FullName);
                         }
                         else
                         {
                             assembly = Assembly.LoadFrom(info.FullName, securityEvidence);
                         }
                     }
                     catch (Exception exception)
                     {
                         SDVPApplication.LogAddonException(exception, "Failed to load " + info.FullName);
                         continue;
                     }
                     this.ScanAssemblyForTranscoders(assembly);
                 }
             }
         }
     }
     catch (Exception exception2)
     {
         SDVPApplication.DoNotifyUser(string.Format("[Web Browser] Failure loading Transcoders: {0}", exception2.Message), "Transcoders Load Error");
     }
 }
Ejemplo n.º 5
0
        private static void VistaClearTracks(bool bClearFiles, bool bClearCookies)
        {
            int num = 0;

            if (bClearCookies)
            {
                num = 2;
            }
            if (bClearFiles)
            {
                num = 0x100c;
            }
            try
            {
                using (Process.Start("rundll32.exe", "inetcpl.cpl,ClearMyTracksByProcess " + num.ToString()))
                {
                }
            }
            catch (Exception exception)
            {
                SDVPApplication.DoNotifyUser("Failed to launch ClearMyTracksByProcess.\n" + exception.Message, "Error");
            }
        }
Ejemplo n.º 6
0
        private static ICertificateProvider LoadOverrideCertProvider()
        {
            string stringPref = SDVPApplication.Prefs.GetStringPref("SDVP.certmaker.assembly", Browser.GetPath("App") + "CertMaker.dll");

            if (File.Exists(stringPref))
            {
                Assembly assembly;
                try
                {
                    assembly = Assembly.LoadFrom(stringPref);
                    if (!Utilities.SDVPMeetsVersionRequirement(assembly, "Certificate Maker"))
                    {
                        return(null);
                    }
                }
                catch (Exception exception)
                {
                    SDVPApplication.LogAddonException(exception, "Failed to load CertMaker" + stringPref);
                    return(null);
                }
                foreach (Type type in assembly.GetExportedTypes())
                {
                    if ((!type.IsAbstract && type.IsPublic) && (type.IsClass && typeof(ICertificateProvider).IsAssignableFrom(type)))
                    {
                        try
                        {
                            return((ICertificateProvider)Activator.CreateInstance(type));
                        }
                        catch (Exception exception2)
                        {
                            SDVPApplication.DoNotifyUser(string.Format("[Web Browser] Failure loading {0} CertMaker from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assembly.CodeBase, exception2.Message, exception2.StackTrace, exception2.InnerException }), "Load Error");
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
 internal static void EnsureFoldersExist()
 {
     try
     {
         if (!Directory.Exists(GetPath("Captures")))
         {
             Directory.CreateDirectory(GetPath("Captures"));
         }
         if (!Directory.Exists(GetPath("Requests")))
         {
             Directory.CreateDirectory(GetPath("Requests"));
         }
         if (!Directory.Exists(GetPath("Responses")))
         {
             Directory.CreateDirectory(GetPath("Responses"));
         }
         if (!Directory.Exists(GetPath("Scripts")))
         {
             Directory.CreateDirectory(GetPath("Scripts"));
         }
     }
     catch (Exception exception)
     {
         SDVPApplication.DoNotifyUser(exception.ToString(), "Folder Creation Failed");
     }
     try
     {
         if ((!SDVPApplication.Prefs.GetBoolPref("SDVP.script.delaycreate", true) && !File.Exists(GetPath("CustomRules"))) && File.Exists(GetPath("SampleRules")))
         {
             File.Copy(GetPath("SampleRules"), GetPath("CustomRules"));
         }
     }
     catch (Exception exception2)
     {
         SDVPApplication.DoNotifyUser(exception2.ToString(), "Initial file copies failed");
     }
 }
Ejemplo n.º 8
0
        private X509Certificate2 CreateCert(string sHostname, bool isRoot)
        {
            int    num;
            string str;

            if (!isRoot && (this.GetRootCertificate() == null))
            {
                try
                {
                    this.oRWLock.AcquireReaderLock(-1);
                    if ((this.LoadCertificateFromWindowsStore(sMakeCertRootCN, false) == null) && !this.CreateRootCertificate())
                    {
                        SDVPApplication.DoNotifyUser("Creation of the root certificate was not successful.", "Certificate Error");
                        return(null);
                    }
                }
                finally
                {
                    this.oRWLock.ReleaseReaderLock();
                }
            }
            if (sHostname.IndexOfAny(new char[] { '"', '\r', '\n' }) != -1)
            {
                return(null);
            }
            if (!File.Exists(this._sMakeCertLocation))
            {
                SDVPApplication.DoNotifyUser("Cannot locate:\n\t\"" + this._sMakeCertLocation + "\"\n\nPlease move makecert.exe to the Fiddler installation directory.", "MakeCert.exe not found");
                throw new FileNotFoundException("Cannot locate: " + this._sMakeCertLocation + ". Please move makecert.exe to the Fiddler installation directory.");
            }
            X509Certificate2 certificate = null;
            string           sParams     = string.Format(isRoot ? sMakeCertParamsEE : sMakeCertParamsEE, new object[] { sHostname, sMakeCertSubjectO, sMakeCertRootCN, DateTime.Now.AddDays(-7.0).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) });

            try
            {
                this.oRWLock.AcquireWriterLock(-1);
                X509Certificate2 certificate2 = this.LoadCertificateFromWindowsStore(sHostname, false);
                if (certificate2 != null)
                {
                    return(certificate2);
                }
                str = Utilities.GetExecutableOutput(this._sMakeCertLocation, sParams, out num);
                if (num == 0)
                {
                    int num2 = 5;
                    do
                    {
                        certificate = this.LoadCertificateFromWindowsStore(sHostname, false);
                        Thread.Sleep((int)(50 * (5 - num2)));
                        num2--;
                    }while ((certificate == null) && (num2 >= 0));
                }
                if (certificate != null)
                {
                    if (isRoot)
                    {
                        this.certRoot = certificate;
                    }
                    else
                    {
                        this.certServerCache.Add(sHostname, certificate);
                    }
                }
            }
            finally
            {
                this.oRWLock.ReleaseWriterLock();
            }
            if (certificate == null)
            {
                string sMessage = string.Format("Creation of the interception certificate failed.\n\nmakecert.exe returned {0}.\n\n{1}", num, str);
            }
            return(certificate);
        }
Ejemplo n.º 9
0
        private bool ScanAssemblyForTranscoders(Assembly assemblyInput)
        {
            bool flag     = false;
            bool boolPref = SDVPApplication.Prefs.GetBoolPref("SDVP.debug.extensions.verbose", false);

            try
            {
                if (!Utilities.SDVPMeetsVersionRequirement(assemblyInput, "Importers and Exporters"))
                {
                    //SDVPApplication.Log.LogFormat("Assembly {0} did not specify a RequiredVersionAttribute. Aborting load of transcoders.", new object[] { assemblyInput.CodeBase });
                    return(false);
                }
                foreach (Type type in assemblyInput.GetExportedTypes())
                {
                    if ((!type.IsAbstract && type.IsPublic) && type.IsClass)
                    {
                        if (typeof(ISessionImporter).IsAssignableFrom(type))
                        {
                            try
                            {
                                if (!this.AddToImportOrExportCollection(this.m_Importers, type))
                                {
                                    //SDVPApplication.Log.LogFormat("WARNING: SessionImporter {0} from {1} failed to specify any ImportExportFormat attributes.", new object[] { type.Name, assemblyInput.CodeBase });
                                }
                                else
                                {
                                    flag = true;
                                    if (boolPref)
                                    {
                                        //SDVPApplication.Log.LogFormat("    Added SessionImporter {0}", new object[] { type.FullName });
                                    }
                                }
                            }
                            catch (Exception exception)
                            {
                                SDVPApplication.DoNotifyUser(string.Format("[Web Browser] Failure loading {0} SessionImporter from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assemblyInput.CodeBase, exception.Message, exception.StackTrace, exception.InnerException }), "Extension Load Error");
                            }
                        }
                        if (typeof(ISessionExporter).IsAssignableFrom(type))
                        {
                            try
                            {
                                if (!this.AddToImportOrExportCollection(this.m_Exporters, type))
                                {
                                    //SDVPApplication.Log.LogFormat("WARNING: SessionExporter {0} from {1} failed to specify any ImportExportFormat attributes.", new object[] { type.Name, assemblyInput.CodeBase });
                                }
                                else
                                {
                                    flag = true;
                                    if (boolPref)
                                    {
                                        //SDVPApplication.Log.LogFormat("    Added SessionExporter {0}", new object[] { type.FullName });
                                    }
                                }
                            }
                            catch (Exception exception2)
                            {
                                SDVPApplication.DoNotifyUser(string.Format("[Web Browser] Failure loading {0} SessionExporter from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assemblyInput.CodeBase, exception2.Message, exception2.StackTrace, exception2.InnerException }), "Extension Load Error");
                            }
                        }
                    }
                }
            }
            catch (Exception exception3)
            {
                SDVPApplication.DoNotifyUser(string.Format("[Web Browser] Failure loading Importer/Exporter from {0}: {1}", assemblyInput.CodeBase, exception3.Message), "Extension Load Error");
                return(false);
            }
            return(flag);
        }
Ejemplo n.º 10
0
        internal bool Start(int iPort, bool bAllowRemote)
        {
            if (Browser.bIsViewOnly)
            {
                return(false);
            }
            bool flag = false;

            try
            {
                flag = (bAllowRemote && Browser.bEnableIPv6) && Socket.OSSupportsIPv6;
            }
            catch (Exception exception)
            {
                if (exception is ConfigurationErrorsException)
                {
                    SDVPApplication.DoNotifyUser(string.Concat(new object[] { "A Microsoft .NET Configuration file (listed below) is corrupt and contains invalid data. You can often correct this error by installing updates from WindowsUpdate and/or reinstalling the .NET Framework.\n\n", exception.Message, "\nSource: ", exception.Source, "\n", exception.StackTrace, "\n\n", exception.InnerException, "\nSDVP v", Application.ProductVersion, (8 == IntPtr.Size) ? " (x64) " : " (x86) ", " [.NET ", Environment.Version, " on ", Environment.OSVersion.VersionString, "] " }), ".NET Configuration Error", MessageBoxIcon.Hand);
                    this.oAcceptor = null;
                    return(false);
                }
            }
            try
            {
                if (flag)
                {
                    this.oAcceptor = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
                    if (Environment.OSVersion.Version.Major > 5)
                    {
                        this.oAcceptor.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.PacketInformation | SocketOptionName.KeepAlive, 0);
                    }
                }
                else
                {
                    this.oAcceptor = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                }
                if (Browser.ForceExclusivePort)
                {
                    this.oAcceptor.ExclusiveAddressUse = true;
                }
                if (bAllowRemote)
                {
                    if (flag)
                    {
                        this.oAcceptor.Bind(new IPEndPoint(IPAddress.IPv6Any, iPort));
                    }
                    else
                    {
                        this.oAcceptor.Bind(new IPEndPoint(IPAddress.Any, iPort));
                    }
                }
                else
                {
                    this.oAcceptor.Bind(new IPEndPoint(IPAddress.Loopback, iPort));
                }
                this.oAcceptor.Listen(50);
            }
            catch (SocketException exception2)
            {
                string str    = string.Empty;
                string sTitle = "SDVP Cannot Listen";
                switch (exception2.ErrorCode)
                {
                case 0x273f:
                case 0x2741:
                    if (flag)
                    {
                        str = "\nThis often means that you've enabled IPv6 support inside Tools > Web Browser Options, but your computer has IPv6 disabled.";
                    }
                    break;

                case 0x2740:
                case 0x271d:
                    str    = "\nThis is usually due to another service running on this port. Run NETSTAT -A at a command prompt.\nIf you don't want to stop using the other program, simply change the port used by SDVP.\nClick Tools > SDVP Options > Connections, select a new port, and restart SDVP.";
                    sTitle = "Web Browser Port in Use";
                    break;
                }
                this.oAcceptor = null;
                SDVPApplication.DoNotifyUser(string.Format("Unable to bind to port [Localhost:{0}]. ErrorCode: {1}.\n{2}\n\n{3}\n\n{4}", new object[] { Browser.ListenPort, exception2.ErrorCode, str, exception2.ToString(), string.Concat(new object[] { "SDVP v", Application.ProductVersion, " [.NET ", Environment.Version, " on ", Environment.OSVersion.VersionString, "]" }) }), sTitle, MessageBoxIcon.Hand);
                return(false);
            }
            catch (Exception exception3)
            {
                this.oAcceptor = null;
                SDVPApplication.ReportException(exception3);
                return(false);
            }
            try
            {
                this.oAcceptor.BeginAccept(new AsyncCallback(this.AcceptConnection), null);
            }
            catch (Exception exception4)
            {
                this.oAcceptor = null;
                //SDVPApplication.Log.LogFormat("Web Browser BeginAccept() Exception: {0}", new object[] { exception4.Message });
                return(false);
            }
            return(true);
        }
Ejemplo n.º 11
0
        public static string GetPath(string sWhatPath)
        {
            string folderPath;

            switch (sWhatPath)
            {
            case "App":
                return(Path.GetDirectoryName(Application.ExecutablePath) + @"\");

            case "AutoSDVPs_Machine":
                return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Scripts\");

            case "AutoSDVPs_User":
                return(sUserPath + @"Scripts\");

            case "AutoResponderDefaultRules":
                return(sUserPath + @"\AutoResponder.xml");

            case "Captures":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.captures", sUserPath + @"Captures\"));

            case "CustomRules":
                return(sScriptPath);

            case "DefaultClientCertificate":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.defaultclientcert", sUserPath + "ClientCertificate.cer"));

            case "SDVPRootCert":
                return(sUserPath + "Root.cer");

            case "Filters":
                return(sUserPath + @"Filters\");

            case "Inspectors":
                return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Inspectors\");

            case "PerUser-ISA-Browser":
                folderPath = "C:";
                try
                {
                    folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                }
                catch (Exception)
                {
                }
                return(folderPath + @"\microsoft\firewall client 2004\management.ini");

            case "PerMachine-ISA-Browser":
                folderPath = "C:";
                try
                {
                    folderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                }
                catch (Exception)
                {
                }
                return(folderPath + @"\microsoft\firewall client 2004\management.ini");

            case "MakeCert":
                folderPath = SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.makecert", Path.GetDirectoryName(Application.ExecutablePath) + @"\MakeCert.exe");
                if (!File.Exists(folderPath))
                {
                    folderPath = "MakeCert.exe";
                }
                return(folderPath);

            case "MyDocs":
                folderPath = "C:";
                try
                {
                    folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                }
                catch (Exception exception)
                {
                    SDVPApplication.DoNotifyUser("Initialization Error", "Failed to retrieve path to your My Documents folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + exception.Message);
                }
                return(folderPath);

            case "Pac":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.pac", sUserPath + @"Scripts\BrowserPAC.js"));

            case "Requests":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.requests", sUserPath + @"Captures\Requests\"));

            case "Responses":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.responses", sUserPath + @"Captures\Responses\"));

            case "Root":
                return(sUserPath);

            case "SafeTemp":
                folderPath = "C:";
                try
                {
                    folderPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                }
                catch (Exception exception2)
                {
                    SDVPApplication.DoNotifyUser("Failed to retrieve path to your Internet Cache folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + exception2.Message, "GetPath(SafeTemp) Failed");
                }
                return(folderPath);

            case "SampleRules":
                return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Scripts\SampleRules.js");

            case "Scripts":
                return(sUserPath + @"Scripts\");

            case "TemplateResponses":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.templateresponses", Path.GetDirectoryName(Application.ExecutablePath) + @"\ResponseTemplates\"));

            case "TextEditor":
                return(SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.texteditor", m_TextEditor));

            case "Transcoders_Machine":
                return(Path.GetDirectoryName(Application.ExecutablePath) + @"\ImportExport\");

            case "Transcoders_User":
                return(sUserPath + @"ImportExport\");

            case "WINDIFF":
            {
                string stringPref = SDVPApplication.Prefs.GetStringPref("SDVP.Browser.path.comparetool", null);
                if (string.IsNullOrEmpty(stringPref))
                {
                    if (m_CompareTool == "windiff.exe")
                    {
                        if (File.Exists(GetPath("App") + "windiff.exe"))
                        {
                            return(GetPath("App") + "windiff.exe");
                        }
                        RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinMerge.exe", false);
                        if (key != null)
                        {
                            string str3 = (string)key.GetValue(string.Empty, null);
                            key.Close();
                            if (str3 != null)
                            {
                                return(str3);
                            }
                        }
                    }
                    return(m_CompareTool);
                }
                return(stringPref);
            }
            }
            return("C:");
        }