Пример #1
0
        private void SetProxy(int iPort = 8877)
        {
            //设置别名
            Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreHw");

            //启动方式
            //FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
            Fiddler.CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);


            //启动代理程序,开始监听http请求
            //端口,是否使用windows系统代理(如果为true,系统所有的http访问都会使用该代理)
            Fiddler.FiddlerApplication.Startup(iPort, false, true, true);

            int    iSecureEndpointPort     = 8888;
            string sSecureEndpointHostname = "127.0.0.1";
            Proxy  oSecureEndpoint         = null;

            // 我们还将创建一个HTTPS监听器,当FiddlerCore被伪装成HTTPS服务器有用
            // 而不是作为一个正常的CERN样式代理服务器。
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);

            AddTXT("请将手机和电脑连接在同一网段");
            AddTXT("再设置手机WIFI的代理服务器为电脑IP");
            AddTXT("再设置手机WIFI的代理端口为8877");
            AddTXT("");
            AddTXT("开始监控 下面需要出现 成功链接代理 才能正常获取版本");


            Go();
        }
Пример #2
0
        public void Start(int port)
        {
            if (FiddlerApplication.IsStarted())
            {
                Shutdown();
                FiddlerApplication.BeforeResponse -= FiddlerApplication_BeforeResponse;
            }

            if (!Fiddler.CertMaker.rootCertExists())
            {
                if (!Fiddler.CertMaker.createRootCert())
                {
                    throw new Exception("Unable to create cert for FiddlerCore.");
                }
            }
            if (!Fiddler.CertMaker.rootCertIsTrusted())
            {
                if (!Fiddler.CertMaker.trustRootCert())
                {
                    throw new Exception("Unable to install FiddlerCore's cert.");
                }
            }

            Fiddler.CONFIG.IgnoreServerCertErrors = isIgnoreCertError;
            Fiddler.CONFIG.bMITM_HTTPS            = false;

            this.startPort = port;
            //FiddlerApplication.Startup(startPort, FiddlerCoreStartupFlags.DecryptSSL);//启动侦听
            FiddlerApplication.Startup(startPort, FiddlerCoreStartupFlags.Default | FiddlerCoreStartupFlags.RegisterAsSystemProxy);
            //创建一个https侦听器,用于伪装成https服务器
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            Fiddler.CertMaker.trustRootCert();
            FiddlerApplication.BeforeResponse += FiddlerApplication_BeforeResponse;//注册事件,用于捕获网络流量
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
        }
Пример #3
0
        public void StartFiddler()
        {
            Common.Log("Starting Fiddler Proxy on port " + proxyPort);
            string sSAZInfo = "NoSAZ";

            if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly()))
            {
                DiagnosticLog.WriteLine("This assembly was not compiled with a SAZ-exporter");
            }
            else
            {
                sSAZInfo = SAZFormat.GetZipLibraryInfo();
            }
            CONFIG.IgnoreServerCertErrors = true;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);


            FiddlerCoreStartupFlags oFCSF = (FiddlerCoreStartupFlags.AllowRemoteClients |
                                             FiddlerCoreStartupFlags.DecryptSSL |
                                             FiddlerCoreStartupFlags.MonitorAllConnections |
                                             //            FiddlerCoreStartupFlags.RegisterAsSystemProxy |
                                             FiddlerCoreStartupFlags.ChainToUpstreamGateway |
                                             FiddlerCoreStartupFlags.CaptureLocalhostTraffic);


            FiddlerApplication.Startup(proxyPort, false, true, true);
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
        }
Пример #4
0
        public void Start()
        {
            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

            path = path.Replace("file:\\", "");
            if (!path.EndsWith(@"\"))
            {
                path += @"\";
            }
            path += "FiddlerRoot.cer";


            FiddlerApplication.oDefaultClientCertificate = new X509Certificate(path);
            FiddlerApplication.BeforeRequest            += ProcessBeginRequest;

            FiddlerApplication.AfterSessionComplete += ProcessEndResponse;
            CONFIG.IgnoreServerCertErrors            = true;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);



            _oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(_sslPort, true, _hostName);
            if (null == _oSecureEndpoint)
            {
                throw new Exception("could not start up secure endpoint");
            }
            FiddlerApplication.Startup(_port, false, true, true);
        }
Пример #5
0
        public void Initialize()
        {
            //FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            FiddlerApplication.BeforeRequest        += new SessionStateHandler(BeforeRequestCallback);
            FiddlerApplication.BeforeResponse       += new SessionStateHandler(BeforeResponseCallback);
            FiddlerApplication.AfterSessionComplete += new SessionStateHandler(AfterSessionCompleteCallback);
            CONFIG.IgnoreServerCertErrors            = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // For forward-compatibility with updated FiddlerCore libraries, it is strongly recommended that you
            // start with the DEFAULT options and manually disable specific unwanted options.
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // E.g. uncomment the next line if you don't want FiddlerCore to act as the system proxy
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
            // or uncomment the next line if you don't want to decrypt SSL traffic.
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);
            //
            // NOTE: Because we haven't disabled the option to decrypt HTTPS traffic, makecert.exe
            // must be present in this executable's folder.
            const int listenPort = 8877;

            FiddlerApplication.Startup(listenPort, oFCSF);
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(7777, true, sSecureEndpointHostname);
        }
Пример #6
0
        private void btnstart_Click(object sender, EventArgs e)
        {
            WriteCommandResponse("btnstart_Click");

            btnout.Enabled   = true;
            btnstart.Enabled = false;

            // 启动方式
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // Uncomment the next line if you don't want to decrypt SSL traffic.
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);

            // 启动代理程序,开始监听http请求
            // 参数: 端口,是否使用windows系统代理(如果为true,系统所有的http访问都会使用该代理)
            FiddlerApplication.Startup(iPort, true, true, true);

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }
            else
            {
                log("Start SecureEndpointPort failed!");
            }

            log("启动代理成功");
        }
Пример #7
0
        public Core(int unsecurePort, int securePort)
        {
            FiddlerApplication.SetAppDisplayName("DaX.Core");

            FiddlerApplication.OnNotification           += FiddlerApplication_OnNotification;
            FiddlerApplication.Log.OnLogString          += Log_OnLogString;
            FiddlerApplication.BeforeRequest            += FiddlerApplication_BeforeRequest;
            FiddlerApplication.OnReadResponseBuffer     += FiddlerApplication_OnReadResponseBuffer;
            FiddlerApplication.ResponseHeadersAvailable += FiddlerApplication_ResponseHeadersAvailable;
            FiddlerApplication.BeforeResponse           += FiddlerApplication_BeforeResponse;
            FiddlerApplication.AfterSessionComplete     += FiddlerApplication_AfterSessionComplete;


            Console.WriteLine(String.Format("Starting {0} ...", FiddlerApplication.GetVersionString()));

            CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            oFCSF = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            FiddlerApplication.Startup(unsecurePort, oFCSF);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", unsecurePort);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(securePort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", securePort, sSecureEndpointHostname);
            }
        }
Пример #8
0
        public void Start()
        {
            sessions = new Buffer <Session>(Settings.SessionBufferSize);
            FiddlerApplication.OnValidateServerCertificate += (sender, args) =>
            {
                if (Program.WineCompat)
                {
                    // required, as WineCompat sets ForceHttp = true and invalid certificates significantly impact performance in Wine
                    args.ValidityState = CertificateValidity.ForceValid;
                    return;
                }

                var errors = args.CertificatePolicyErrors;

                // No need to re-verify
                if (errors == SslPolicyErrors.None)
                {
                    return;
                }

                if ((errors & SslPolicyErrors.RemoteCertificateNotAvailable) > 0 ||
                    (errors & SslPolicyErrors.RemoteCertificateNameMismatch) > 0)
                {
                    return;
                }

                var remoteChain = args.ServerCertificateChain;
                var chain       = new X509Chain();
                var policy      = chain.ChainPolicy;
                policy.RevocationMode    = X509RevocationMode.NoCheck;
                policy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
                policy.ExtraStore.AddRange(CertificateStore);

                if (!chain.Build(remoteChain.ChainElements[0].Certificate))
                {
                    return;
                }
                var chainRoot = chain.ChainElements[chain.ChainElements.Count - 1].Certificate;
                foreach (var trusted in CertificateStore)
                {
                    if (!chainRoot.RawData.SequenceEqual(trusted.RawData))
                    {
                        continue;
                    }
                    args.ValidityState = CertificateValidity.ForceValid;
                    break;
                }
            };
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.CleanupServerCertsOnExit", true);
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(port)
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Пример #9
0
        public void Start()
        {
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(8877)
                .RegisterAsSystemProxy()
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Пример #10
0
        public void Start()
        {
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.CleanupServerCertsOnExit", true);
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(port)
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Пример #11
0
        public MainForm()
        {
            InitializeComponent();

            FiddlerApplication.SetAppDisplayName("RemoveAreaLimit");
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            FiddlerApplication.Startup(port, oFCSF);

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);

            FiddlerApplication.BeforeRequest  += OnBeforeRequest;
            FiddlerApplication.BeforeResponse += OnBeforeResponse;
        }
        public HttpMonitor()
        {
            FiddlerApplication.BeforeRequest += (Session oS) =>
            {
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                OnNewSession(this, new EventArgs());
                Monitor.Exit(oAllSessions);
                if ((oS.oRequest.pipeClient.LocalPort == SecureEndpointPort) && (oS.hostname == SecureEndpointHostname))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "Ok");
                    oS.oResponse["Content-Type"]  = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for https://" + SecureEndpointHostname + ":" + SecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };
            FiddlerApplication.AfterSessionComplete += (Session oS) => { };
            Application.ApplicationExit             += (object senser, EventArgs e) => { DoQuit(); };
            CONFIG.IgnoreServerCertErrors            = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            ushort iPort = 8877;
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(iPort)
                .RegisterAsSystemProxy()
                .DecryptSSL()
                //.AllowRemoteClients()
                //.ChainToUpstreamGateway()
                //.MonitorAllConnections()
                //.HookUsingPACFile()
                .CaptureLocalhostTraffic()
                //.CaptureFTP()
                .OptimizeThreadPool()
                //.SetUpstreamGatewayTo("http=CorpProxy:80;https=SecureProxy:443;ftp=ftpGW:20")
                .Build();

            FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());
            SecureEndpoint = FiddlerApplication.CreateProxyEndpoint(SecureEndpointPort, true, SecureEndpointHostname);
            if (null != SecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat($"Created secure endpoint listening on port {SecureEndpointPort}, using a HTTPS certificate for '{SecureEndpointHostname}'");
            }
        }
Пример #13
0
 //开始运行抓取
 public void Start()
 {
     oAllSessions = new List <Fiddler.Session>();
     //在请求发出之前做的操作,可以捕获、修改请求内容
     Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
     {
         oS.bBufferResponse = true;
         //检验链接中是否存在关键词,不用可以注释掉
         if (UrlExistKey(oS.fullUrl))
         {
             Monitor.Enter(oAllSessions);
             oAllSessions.Add(oS);
             Monitor.Exit(oAllSessions);
         }
         oS["X-AutoAuth"] = "(default)";
     };
     //响应结果返回,Fiddler接收到之后,浏览器等接收之前,可以捕获、修改响应内容
     Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS)
     {
         oS.bBufferResponse = true;
         //检验链接中是否存在关键词,不用可以注释掉
         if (UrlExistKey(oS.fullUrl))
         {
             Monitor.Enter(oAllSessions);
             oAllSessions.Add(oS);
             oS.utilDecodeResponse();
             Write(string.Format("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl));
             Write(oS.GetResponseBodyAsString());
             Monitor.Exit(oAllSessions);
         }
         oS["X-AutoAuth"] = "(default)";
     };
     FiddlerApplication.SetAppDisplayName("PPSHUAI");
     //第三个参数为True,要求捕获https
     FiddlerApplication.Startup(port, true, true, true);
     oProxy = FiddlerApplication.CreateProxyEndpoint(port, true, sHostname);
     //此处调用makecert.exe设置证书
     if (Fiddler.CertMaker.trustRootCert() == true)
     {
         MessageBox.Show("证书安装成功", "操作提示");
     }
     else
     {
         MessageBox.Show("证书安装出错", "操作提示");
     }
     ifWork = true;
 }
Пример #14
0
        public static void GetOauthTokens(Action <int, OauthToken> onResult)
        {
            if (FiddlerApplication.IsStarted())
            {
                onResult(0, null);
                return;
            }

            FiddlerApplication.Startup(0, FiddlerCoreStartupFlags.Default);
            Proxy oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(0, true, "localhost");

            SessionStateHandler handler = null;

            handler = (Session oS) => {
                if (oS.fullUrl.StartsWith("https://restapi.ele.me/marketing/promotion/weixin/") && oS.RequestMethod == "POST")
                {
                    OauthToken token = new OauthToken();
                    token.Url         = oS.fullUrl;
                    token.RequestBody = jsSerializer.Deserialize <dynamic>(oS.GetRequestBodyAsString());
                    token.UserName    = token.RequestBody["weixin_username"];

                    FiddlerApplication.BeforeRequest -= handler;
                    if (null != oSecureEndpoint)
                    {
                        oSecureEndpoint.Dispose();
                    }
                    FiddlerApplication.Shutdown();

                    onResult(1, token);
                }
                else if (oS.fullUrl.StartsWith("http://close.local"))
                {
                    FiddlerApplication.BeforeRequest -= handler;
                    if (null != oSecureEndpoint)
                    {
                        oSecureEndpoint.Dispose();
                    }
                    FiddlerApplication.Shutdown();
                }
            };

            FiddlerApplication.BeforeRequest += handler;
        }
Пример #15
0
        public static bool Startup()
        {
            if (!_certificatesValid)
            {
                Log(LogMessageType.Error, "could not start. certificates not ready");
                return(false);
            }

            Log(LogMessageType.Information, "Starting with settings: [{0}]", startupOptions);
            FiddlerApplication.Startup(NORMAL_PORT, startupOptions);
            _SecureEndpoint = FiddlerApplication.CreateProxyEndpoint(SSL_PORT, true, SSL_HOST);
            if (_SecureEndpoint == null)
            {
                Shutdown();
                Log(LogMessageType.Error, "Secure Endpoint could not be created");
                return(false);
            }

            return(true);
        }
Пример #16
0
        private static void InitializeFiddler()
        {
            //Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            Fiddler.FiddlerApplication.BeforeRequest  += new SessionStateHandler(BeforeRequestCallback);
            Fiddler.FiddlerApplication.BeforeResponse += new SessionStateHandler(BeforeResponseCallback);

            Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKeyPressed);
            Fiddler.CONFIG.IgnoreServerCertErrors = true;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // For forward-compatibility with updated FiddlerCore libraries, it is strongly recommended that you
            // start with the DEFAULT options and manually disable specific unwanted options.
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // E.g. uncomment the next line if you don't want FiddlerCore to act as the system proxy
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
            // or uncomment the next line if you don't want to decrypt SSL traffic.
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);
            //
            // NOTE: Because we haven't disabled the option to decrypt HTTPS traffic, makecert.exe
            // must be present in this executable's folder.
            const int listenPort = 8877;

            Fiddler.FiddlerApplication.Startup(listenPort, oFCSF);

            string title = string.Format("Listening on port {0}@{1} [{2}]", listenPort, Util.GetHostIpAddress(), Util.GetLocalhostFQDN());

            Console.Title = title;

            Util.PrintMessage(title);
            Util.PrintMessage("Starting with settings: [" + oFCSF + "]");
            Util.PrintMessage("Using Gateway: " + ((CONFIG.bForwardToGateway) ? "TRUE" : "FALSE"));

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(7777, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                Util.PrintMessage("Created secure end point listening on port 7777, using a HTTPS certificate for '" + sSecureEndpointHostname + "'");
            }
        }
Пример #17
0
        public void Start()
        {
            sessions = new Buffer <Session>(Settings.SessionBufferSize);
            FiddlerApplication.OnValidateServerCertificate += (sender, args) =>
            {
                var errors = args.CertificatePolicyErrors;

                // No need to re-verify
                if (errors == SslPolicyErrors.None)
                {
                    return;
                }

                if ((errors & SslPolicyErrors.RemoteCertificateNotAvailable) > 0 ||
                    (errors & SslPolicyErrors.RemoteCertificateNameMismatch) > 0)
                {
                    return;
                }

                var remoteChain = args.ServerCertificateChain;
                var chain       = new X509Chain();
                var policy      = chain.ChainPolicy;
                policy.RevocationMode    = X509RevocationMode.NoCheck;
                policy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
                policy.ExtraStore.AddRange(CertificateStore);
                if (chain.Build(remoteChain.ChainElements[0].Certificate))
                {
                    args.ValidityState = CertificateValidity.ForceValid;
                }
            };
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.CleanupServerCertsOnExit", true);
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(port)
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Пример #18
0
        public static void Start()
        {
            _provider.WriteMessageEvent("Starting proxy...");
            FiddlerApplication.BeforeRequest        += OnBeforeRequest;
            FiddlerApplication.AfterSessionComplete += OnAfterSessionComplete;

            var startupSettings = new FiddlerCoreStartupSettingsBuilder()
                                  .ListenOnPort(8877)
                                  .RegisterAsSystemProxy()
                                  .DecryptSSL()
                                  .ChainToUpstreamGateway()
                                  .MonitorAllConnections()
                                  //.CaptureLocalhostTraffic()
                                  .OptimizeThreadPool()
                                  .Build();

            FiddlerApplication.Startup(startupSettings);
            _proxyEndpoint = FiddlerApplication.CreateProxyEndpoint(48721, true, "localhost");

            _provider.WriteMessageEvent("Proxy started");
        }
Пример #19
0
        private void initFiddler()
        {
            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates. Change this from the default only
            // if you know EXACTLY what that implies.
            Fiddler.CONFIG.IgnoreServerCertErrors = false;

            // ... but you can allow a specific (even invalid) certificate by implementing and assigning a callback...

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // For forward-compatibility with updated FiddlerCore libraries, it is strongly recommended that you
            // start with the DEFAULT options and manually disable specific unwanted options.
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.AllowRemoteClients | FiddlerCoreStartupFlags.DecryptSSL | FiddlerCoreStartupFlags.ChainToUpstreamGateway | FiddlerCoreStartupFlags.CaptureLocalhostTraffic | FiddlerCoreStartupFlags.MonitorAllConnections | FiddlerCoreStartupFlags.OptimizeThreadPool;

            Fiddler.FiddlerApplication.Startup(iPort, oFCSF);

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            Fiddler.FiddlerApplication.BeforeRequest  += FiddlerApplication_BeforeRequest;
            Fiddler.FiddlerApplication.BeforeResponse += FiddlerApplication_BeforeResponse;
        }
Пример #20
0
        /// <summary>
        /// 启动服务
        /// </summary>
        /// <param name="hostControl"></param>
        /// <returns></returns>
        public bool Start(HostControl hostControl)
        {
            KingProcesser.Init();
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            FiddlerApplication.BeforeRequest += (session) =>
            {
                session.bBufferResponse = true;
                AllSessions.Add(session);

                if ((session.oRequest.pipeClient.LocalPort == sslAddress.Port) && (session.hostname == sslAddress.Host))
                {
                    session.utilCreateResponseAndBypassServer();
                    session.oResponse.headers.SetStatus(200, "Ok");
                    session.utilSetResponseBody("SSL Proxy OK ..");
                }
            };

            // 收到服务端的回复
            FiddlerApplication.BeforeResponse += (session) =>
            {
                KingProcesser.ProcessSessionAsync(session);
            };

            // 配置代理服务器
            CONFIG.IgnoreServerCertErrors = true;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            FiddlerApplication.Startup(proxyPort, FiddlerCoreStartupFlags.AllowRemoteClients | FiddlerCoreStartupFlags.DecryptSSL);

            sslProxyServer = FiddlerApplication.CreateProxyEndpoint(sslAddress.Port, true, sslAddress.Host);
            if (sslProxyServer == null)
            {
                Console.WriteLine("创建SSL监听失败");
            }
            return(true);
        }
Пример #21
0
        public void Start(object url)
        {
            bDone = false;
            FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");
            this.url = url.ToString();
            FiddlerApplication.OnNotification  += (object sender, NotificationEventArgs oNEA) => Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString);

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerApplication.BeforeRequest += FBeforeRequest;

            string sSAZInfo = "NoSAZ";

            Console.WriteLine(String.Format("Starting {0} ({1})...", FiddlerApplication.GetVersionString(), sSAZInfo));

            CONFIG.IgnoreServerCertErrors = true;

            int iPort = 8877;

            FiddlerApplication.Startup(iPort, true, true);

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
        }
Пример #22
0
        static void Main(string[] args)
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");

            #region AttachEventListeners
            //
            // It is important to understand that FiddlerCore calls event handlers on session-handling
            // background threads.  If you need to properly synchronize to the UI-thread (say, because
            // you're adding the sessions to a list view) you must call .Invoke on a delegate on the
            // window handle.
            //
            // If you are writing to a non-threadsafe data structure (e.g. List<t>) you must
            // use a Monitor or other mechanism to ensure safety.
            //

            // Simply echo notifications to the console.  Because Fiddler.CONFIG.QuietMode=true
            // by default, we must handle notifying the user ourselves.
            Fiddler.FiddlerApplication.OnNotification  += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                // Console.WriteLine("Before request for:\t" + oS.fullUrl);
                // In order to enable response tampering, buffering mode MUST
                // be enabled; this allows FiddlerCore to permit modification of
                // the response in the BeforeResponse handler rather than streaming
                // the response to the client as the response comes in.
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                // Set this property if you want FiddlerCore to automatically authenticate by
                // answering Digest/Negotiate/NTLM/Kerberos challenges itself
                // oS["X-AutoAuth"] = "(default)";

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "Ok");
                    oS.oResponse["Content-Type"]  = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };

            /*
             *  // The following event allows you to examine every response buffer read by Fiddler. Note that this isn't useful for the vast majority of
             *  // applications because the raw buffer is nearly useless; it's not decompressed, it includes both headers and body bytes, etc.
             *  //
             *  // This event is only useful for a handful of applications which need access to a raw, unprocessed byte-stream
             *  Fiddler.FiddlerApplication.OnReadResponseBuffer += new EventHandler<RawReadEventArgs>(FiddlerApplication_OnReadResponseBuffer);
             */

            /*
             * Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) {
             *  // Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
             *
             *  // Uncomment the following two statements to decompress/unchunk the
             *  // HTTP response and subsequently modify any HTTP responses to replace
             *  // instances of the word "Microsoft" with "Bayden". You MUST also
             *  // set bBufferResponse = true inside the beforeREQUEST method above.
             *  //
             *  //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
             * };*/

            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                Console.Title = ("Session list contains: " + oAllSessions.Count.ToString() + " sessions");
            };

            // Tell the system console to handle CTRL+C by calling our method that
            // gracefully shuts down the FiddlerCore.
            //
            // Note, this doesn't handle the case where the user closes the window with the close button.
            // See http://geekswithblogs.net/mrnat/archive/2004/09/23/11594.aspx for info on that...
            //
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
            #endregion AttachEventListeners

            string sSAZInfo = "NoSAZ";
#if SAZ_SUPPORT
            sSAZInfo = Assembly.GetAssembly(typeof(Ionic.Zip.ZipFile)).FullName;

            // You can load Transcoders from any different assembly if you'd like, using the ImportTranscoders(string AssemblyPath)
            // overload.
            //
            //if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly()))
            //{
            //    Console.WriteLine("This assembly was not compiled with a SAZ-exporter");
            //}

            DNZSAZProvider.fnObtainPwd = () =>
            {
                Console.WriteLine("Enter the password (or just hit Enter to cancel):");
                string sResult = Console.ReadLine();
                Console.WriteLine();
                return(sResult);
            };

            FiddlerApplication.oSAZProvider = new DNZSAZProvider();
#endif

            Console.WriteLine(String.Format("Starting {0} ({1})...", Fiddler.FiddlerApplication.GetVersionString(), sSAZInfo));

            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates. Change this from the default only
            // if you know EXACTLY what that implies.
            Fiddler.CONFIG.IgnoreServerCertErrors = false;

            // ... but you can allow a specific (even invalid) certificate by implementing and assigning a callback...
            // FiddlerApplication.OnValidateServerCertificate += new System.EventHandler<ValidateServerCertificateEventArgs>(CheckCert);

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // NOTE: In the next line, you can pass 0 for the port (instead of 8877) to have FiddlerCore auto-select an available port
            ushort iPort = 8877;

            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(iPort)
                //.RegisterAsSystemProxy()
                .DecryptSSL()
                //.AllowRemoteClients()
                //.ChainToUpstreamGateway()
                //.MonitorAllConnections()
                //.HookUsingPACFile()
                //.CaptureLocalhostTraffic()
                //.CaptureFTP()
                .OptimizeThreadPool()
                //.SetUpstreamGatewayTo("http=CorpProxy:80;https=SecureProxy:443;ftp=ftpGW:20")
                .Build();

            // *******************************
            // Important HTTPS Decryption Info
            // *******************************
            // When FiddlerCoreStartupSettingsBuilder.DecryptSSL() is called, you must include either
            //
            //     MakeCert.exe
            //
            // *or*
            //
            //     CertMaker.dll
            //     BCMakeCert.dll
            //
            // ... in the folder where your executable and FiddlerCore.dll live. These files
            // are needed to generate the self-signed certificates used to man-in-the-middle
            // secure traffic. MakeCert.exe uses Windows APIs to generate certificates which
            // are stored in the user's \Personal\ Certificates store. These certificates are
            // NOT compatible with iOS devices which require specific fields in the certificate
            // which are not set by MakeCert.exe.
            //
            // In contrast, CertMaker.dll uses the BouncyCastle C# library (BCMakeCert.dll) to
            // generate new certificates from scratch. These certificates are stored in memory
            // only, and are compatible with iOS devices.

            Fiddler.FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);

            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());

            Console.WriteLine("Hit CTRL+C to end session.");

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }

            bool bDone = false;
            do
            {
                Console.WriteLine("\nEnter a command [C=Clear; L=List; G=Collect Garbage; W=write SAZ; R=read SAZ;\n\tS=Toggle Forgetful Streaming; T=Trust Root Certificate; Q=Quit]:");
                Console.Write(">");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (Char.ToLower(cki.KeyChar))
                {
                case 'c':
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Clear();
                    Monitor.Exit(oAllSessions);
                    WriteCommandResponse("Clear...");
                    FiddlerApplication.Log.LogString("Cleared session list.");
                    break;

                case 'd':
                    FiddlerApplication.Log.LogString("FiddlerApplication::Shutdown.");
                    FiddlerApplication.Shutdown();
                    break;

                case 'l':
                    WriteSessionList(oAllSessions);
                    break;

                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'q':
                    bDone = true;
                    DoQuit();
                    break;

                case 'r':
#if SAZ_SUPPORT
                    ReadSessions(oAllSessions);
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 'w':
#if SAZ_SUPPORT
                    if (oAllSessions.Count > 0)
                    {
                        SaveSessionsToDesktop(oAllSessions);
                    }
                    else
                    {
                        WriteCommandResponse("No sessions have been captured");
                    }
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 't':
                    try
                    {
                        WriteCommandResponse("Result: " + Fiddler.CertMaker.trustRootCert().ToString());
                    }
                    catch (Exception eX)
                    {
                        WriteCommandResponse("Failed: " + eX.ToString());
                    }
                    break;

                // Forgetful streaming
                case 's':
                    bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful);
                    Console.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data.");
                    break;
                }
            } while (!bDone);
        }
Пример #23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "华为手机优先推送 v" + Application.ProductVersion.ToString();

            // this.BeginInvoke((MethodInvoker)delegate
            // {
            DialogResult dlsm = MessageBox.Show("本软件的所有包都来自于华为官方,本软件不对升级后导致的任何后果负责!\r\n如果介意,请点击否会自动关闭本软件!!\r\n如果点击是,则认同此本声明!", "声明", MessageBoxButtons.YesNo);

            if (dlsm == DialogResult.No)
            {
                System.Environment.Exit(0);
                return;
            }
            // });

            if (qqinfo == null)
            {
                System.Environment.Exit(0);
            }

            mems myqqinfo = null;

            List <mems> lme = qqinfo.mems;

            if (lme != null)
            {
                myqqinfo = lme.SingleOrDefault();
                qqstring = JsonConvert.SerializeObject(myqqinfo);
                qqnumber = myqqinfo.uin.ToString();
                isqy     = 1;

                svrtime = UnixTimestamp.ConvertIntDateTime(qqinfo.svr_time);
            }
            else
            {
                isqy = 0;
            }

            //if (qqnumber == "119564557" || qqnumber == "891587944" || qqnumber == "289408880" || qqnumber == "834714126" || qqnumber == "591219179")
            //{

            //}
            //else

            //{
            //    MessageBox.Show("没权限使用");
            //    System.Environment.Exit(0);
            //}

            LoadVersion();


            LoadHMD();



            AddTXT("请将手机和电脑连接在同一路由器");
            AddTXT("请设置手机WIFI的代理服务器为电脑IP的8877端口");
            AddTXT("");
            AddTXT("如果不会设置代理服务器,请查看操作说明文档");
            AddTXT("http://note.youdao.com/share/?id=07bf9af8e5e82f536e48a490d3618415&type=note");
            AddTXT("软件更新链接:http://pan.baidu.com/s/1qX0LdeO 密码:rhjx");
            AddTXT("");


            //string card = myqqinfo.card;


            label3.Text = qqnumber;


            //您的手机型号为:" + MyVersion.ModelName + "\n\r
            this.BeginInvoke((MethodInvoker) delegate
            {
                if (myqqinfo != null)
                {
                    label4.Text = "尊敬的:\n\r" + (string.IsNullOrEmpty(myqqinfo.card) ? myqqinfo.nick : myqqinfo.card) + " " + rolestr(myqqinfo.role);
                    // + "您好!\n\r您的群内活跃值为:" + myqqinfo.lv.point;
                    roles = myqqinfo.role;
                }
                else
                {
                    label4.Text = "尊敬的:\n\r游客您好!\n\r需要加入群:577072975 才能使用推送功能\n\r您可以点击底部的\"加群\"按钮申请加入";
                }
            });
            AddTXT("");


            //Mate8List.Mate8Model.ForEach(x =>
            //{
            //    x.UpdateList.ForEach(m =>
            //    {
            //        if (!listBox1.Items.Contains(m.version))
            //        {
            //            if (isnc == 1)
            //            {
            //                listBox1.Items.Insert(0, m.version);
            //            }
            //            else
            //            {
            //                if (Convert.ToDateTime(m.createTime) < UnixTimestamp.ConvertIntDateTime(qqinfo.svr_time))
            //                {
            //                    listBox1.Items.Insert(0, m.version);
            //                }
            //            }
            //        }
            //    });
            //});
            //listBox1.SetSelected(0, true);

            //设置别名
            Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreHw");

            Fiddler.CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);


            //启动方式
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            //定义http代理端口
            int iPort = 8877;

            //启动代理程序,开始监听http请求
            //端口,是否使用windows系统代理(如果为true,系统所有的http访问都会使用该代理)
            Fiddler.FiddlerApplication.Startup(iPort, false, true, true);



            // 我们还将创建一个HTTPS监听器,当FiddlerCore被伪装成HTTPS服务器有用
            // 而不是作为一个正常的CERN样式代理服务器。
            Proxy  oSecureEndpoint         = null;
            int    iSecureEndpointPort     = 8888;
            string sSecureEndpointHostname = "127.0.0.1";

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            AddTXT("");
            AddTXT("开始监控 下面需要出现 成功链接代理 才能正常获取版本");


            try
            {
                Go();
            }
            catch
            {
                Go();
            }
        }
        static void Main(string[] args)
        {
            // Trust All Certificates, very insecure but for testing :)
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            SimpleFakeCC httpServer = new SimpleFakeCC(9080, 9443);
            Client       client     = new Client();

            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            Fiddler.FiddlerApplication.SetAppDisplayName("Redirect Proxy");

            #region AttachEventListeners

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                oS.bBufferResponse = false;

                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                //oS.bypassGateway = true;
                Console.WriteLine("Request {0}:HTTP for Host: {1}", oS.id, oS.host);

                /*
                 *  Proxy Redirection
                 */


                // Redirect HTTP Traffic according to Header Virus
                if (oS.HTTPMethodIs("CONNECT") && oS.oRequest.headers.Exists("Trojan"))
                {
                    oS.PathAndQuery = "127.0.0.1:9080";
                }
                if (oS.oRequest.headers.Exists("Trojan"))
                {
                    filteredHosts.Add(oS.host); oS.host = "127.0.0.1:9080";
                }

                //If already in FilteredHosts redirect Request -> Only HTTP
                if (oS.HTTPMethodIs("CONNECT") && filteredHosts.Contains(oS.host))
                {
                    oS.PathAndQuery = "127.0.0.1:9080";
                }
                if (filteredHosts.Contains(oS.host))
                {
                    oS.host = "127.0.0.1:9080";
                }

                //Redirect HTTPS Traffic
                if (oS.HTTPMethodIs("CONNECT") && oS.oRequest.headers.Exists("TrojanSecure"))
                {
                    oS.PathAndQuery = "127.0.0.1:9443"; oS["X-OverrideCertCN"] = "redProxy";
                }
                if (oS.oRequest.headers.Exists("TrojanSecure"))
                {
                    oS.host = "127.0.0.1:9443";
                }
            };


            Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) {
                Console.WriteLine("Repsonse {0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
            };


            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                Console.Title = ("Session list contains: " + oAllSessions.Count.ToString() + " sessions");
            };

            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
            #endregion AttachEventListeners


            // TODO Make Right Certs to Trust
            Fiddler.CONFIG.IgnoreServerCertErrors = true;

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // NOTE: In the next line, you can pass 0 for the port (instead of 8877) to have FiddlerCore auto-select an available port
            int iPort = 8877;
            Fiddler.FiddlerApplication.Startup(iPort, oFCSF);

            Console.WriteLine("Hit CTRL+C to end session.");

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }
        }
Пример #25
0
        static void Main(string[] args)
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            #region AttachEventListeners
            //
            // It is important to understand that FiddlerCore calls event handlers on session-handling
            // background threads.  If you need to properly synchronize to the UI-thread (say, because
            // you're adding the sessions to a list view) you must call .Invoke on a delegate on the
            // window handle.
            //
            // If you are writing to a non-threadsafe data structure (e.g. List<t>) you must
            // use a Monitor or other mechanism to ensure safety.
            //

            // Simply echo notifications to the console.  Because Fiddler.CONFIG.QuietMode=true
            // by default, we must handle notifying the user ourselves.
            Fiddler.FiddlerApplication.OnNotification  += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                // Console.WriteLine("Before request for:\t" + oS.fullUrl);
                // In order to enable response tampering, buffering mode MUST
                // be enabled; this allows FiddlerCore to permit modification of
                // the response in the BeforeResponse handler rather than streaming
                // the response to the client as the response comes in.
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.HTTPResponseStatus = "200 Ok";
                    oS.oResponse["Content-Type"]            = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"]           = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };

            /*
             *  // The following event allows you to examine every response buffer read by Fiddler. Note that this isn't useful for the vast majority of
             *  // applications because the raw buffer is nearly useless; it's not decompressed, it includes both headers and body bytes, etc.
             *  //
             *  // This event is only useful for a handful of applications which need access to a raw, unprocessed byte-stream
             *  Fiddler.FiddlerApplication.OnReadResponseBuffer += new EventHandler<RawReadEventArgs>(FiddlerApplication_OnReadResponseBuffer);
             */

            /*
             * Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) {
             *  // Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
             *
             *  // Uncomment the following two statements to decompress/unchunk the
             *  // HTTP response and subsequently modify any HTTP responses to replace
             *  // instances of the word "Microsoft" with "Bayden". You MUST also
             *  // set bBufferResponse = true inside the beforeREQUEST method above.
             *  //
             *  //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
             * };*/

            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                if (bUpdateTitle)
                {
                    Console.Title = ("Session list contains: " + oAllSessions.Count.ToString() + " sessions");
                }
            };

            // Tell the system console to handle CTRL+C by calling our method that
            // gracefully shuts down the FiddlerCore.
            //
            // Note, this doesn't handle the case where the user closes the window with the close button.
            // See http://geekswithblogs.net/mrnat/archive/2004/09/23/11594.aspx for info on that...
            //
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
            #endregion AttachEventListeners

            string sSAZInfo = "NoSAZ";
#if SAZ_SUPPORT
            // If this demo was compiled with a SAZ-Transcoder, then the following lines will load the
            // Transcoders into the available transcoders. You can load other types of Transcoders from
            // a different assembly if you'd like, using the ImportTranscoders(string AssemblyPath) overload.
            // See https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip for an example.
            //
            if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly()))
            {
                Console.WriteLine("This assembly was not compiled with a SAZ-exporter");
            }
            else
            {
                sSAZInfo = SAZFormat.GetZipLibraryInfo();
            }
#endif

            Console.WriteLine(String.Format("Starting {0} ({1})...", Fiddler.FiddlerApplication.GetVersionString(), sSAZInfo));

            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates. Change this from the default only
            // if you know EXACTLY what that implies.
            Fiddler.CONFIG.IgnoreServerCertErrors = false;

            // ... but you can allow a specific (even invalid) certificate by implementing and assigning a callback...
            // FiddlerApplication.OnValidateServerCertificate += new System.EventHandler<ValidateServerCertificateEventArgs>(CheckCert);

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // For forward-compatibility with updated FiddlerCore libraries, it is strongly recommended that you
            // start with the DEFAULT options and manually disable specific unwanted options.
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // E.g. If you want to add a flag, start with the Defaults and "or" it in:
            // oFCSF = (oFCSF | FiddlerCoreStartupFlags.CaptureFTP);

            // ... or if you don't want a flag in the defaults, "and not" it out:
            // Uncomment the next line if you don't want FiddlerCore to act as the system proxy
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
            // or uncomment the next line if you don't want to decrypt SSL traffic.
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);
            //
            // NOTE: Unless you disable the option to decrypt HTTPS traffic, makecert.exe
            // must be present in this executable's folder.

            // NOTE: In the next line, you can pass 0 for the port (instead of 8877) to have FiddlerCore auto-select an available port
            Fiddler.FiddlerApplication.Startup(8877, oFCSF);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Using Gateway: {0}", (CONFIG.bForwardToGateway) ? "TRUE" : "FALSE");

            Console.WriteLine("Hit CTRL+C to end session.");

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure end point listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }

            bool bDone = false;
            do
            {
                Console.WriteLine("\nEnter a command [C=Clear; L=List; G=Collect Garbage; W=write SAZ; R=read SAZ;\n\tS=Toggle Forgetful Streaming; T=Toggle Title Counter; Q=Quit]:");
                Console.Write(">");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (cki.KeyChar)
                {
                case 'c':
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Clear();
                    Monitor.Exit(oAllSessions);
                    WriteCommandResponse("Clear...");
                    FiddlerApplication.Log.LogString("Cleared session list.");
                    break;

                case 'l':
                    WriteSessionList(oAllSessions);
                    break;

                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'q':
                    bDone = true;
                    DoQuit();
                    break;

                case 'r':
#if SAZ_SUPPORT
                    ReadSessions(oAllSessions);
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 'w':
#if SAZ_SUPPORT
                    if (oAllSessions.Count > 0)
                    {
                        SaveSessionsToDesktop(oAllSessions);
                    }
                    else
                    {
                        WriteCommandResponse("No sessions have been captured");
                    }
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 't':
                    bUpdateTitle  = !bUpdateTitle;
                    Console.Title = (bUpdateTitle) ? "Title bar will update with request count..." :
                                    "Title bar update suppressed...";
                    break;

                // Forgetful streaming
                case 's':
                    bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful);
                    Console.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data.");
                    break;
                }
            } while (!bDone);
        }
Пример #26
0
        static void Main(string[] args)
        {
            WriteHelp("Current hosts in system is :");
            Config.LoadHosts();//print hosts lists

            //Config.AddHost("211.82.8.7", "c.com", "test", false,false);
            Config.SetConfig();//init to set config

            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            //if (args.Length == 0){
            //Config.DomainFilter =  "renren.com";
            //}
            if (args.Length == 1)
            {
                Application.EnableVisualStyles();
                Application.Run(new Form1());
            }
            if (args.Length == 2)
            {
                Config.Port         = int.Parse(args[0]);
                Config.DomainFilter = args[1];
            }
            #region AttachEventListeners
            //
            // It is important to understand that FiddlerCore calls event handlers on session-handling
            // background threads.  If you need to properly synchronize to the UI-thread (say, because
            // you're adding the sessions to a list view) you must call .Invoke on a delegate on the
            // window handle.
            //
            // If you are writing to a non-threadsafe data structure (e.g. List<t>) you must
            // use a Monitor or other mechanism to ensure safety.
            //

            // Simply echo notifications to the console.  Because Fiddler.CONFIG.QuietMode=true
            // by default, we must handle notifying the user ourselves.

            /*
             * Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA)
             * {
             *  WriteLog("** NotifyUser: "******"** LogString: " + oLEA.LogString);
             * };*/

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                if (oS.host.EndsWith(Config.DomainFilter))
                {
                    //Console.WriteLine("Before request for:\t" + Ellipsize(oS.fullUrl,60));


                    // In order to enable response tampering, buffering mode MUST
                    // be enabled; this allows FiddlerCore to permit modification of
                    // the response in the BeforeResponse handler rather than streaming
                    // the response to the client as the response comes in.
                    //oS.bBufferResponse = true;
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Add(oS);
                    Monitor.Exit(oAllSessions);
                }
                ;

                // All requests for subdomain.example.com should be directed to the development server at 123.125.44.242
                if (oS.host.StartsWith("localhost"))
                {
                    oS.bypassGateway     = true;              // Prevent this request from going through an upstream proxy
                    oS["x-overrideHost"] = "123.125.44.242";  // DNS name or IP address of target server
                }

                if ((oS.hostname == sSecureEndpointHostname) && (oS.port == 7777))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.HTTPResponseStatus = "200 Ok";
                    oS.oResponse["Content-Type"]            = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"]           = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":7777 received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };

            /*
             *  // The following event allows you to examine every response buffer read by Fiddler. Note that this isn't useful for the vast majority of
             *  // applications because the raw buffer is nearly useless; it's not decompressed, it includes both headers and body bytes, etc.
             *  //
             *  // This event is only useful for a handful of applications which need access to a raw, unprocessed byte-stream
             *  Fiddler.FiddlerApplication.OnReadResponseBuffer += new EventHandler<RawReadEventArgs>(FiddlerApplication_OnReadResponseBuffer);
             */


            Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) {
                // Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);

                // Uncomment the following two statements to decompress/unchunk the
                // HTTP response and subsequently modify any HTTP responses to replace
                // instances of the word "Microsoft" with "Bayden". You MUST also
                // set bBufferResponse = true inside the beforeREQUEST method above.
                //
                //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
            };

            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                if (bUpdateTitle)
                {
                    Console.Title = ("Session list contains: " + oAllSessions.Count.ToString() + " sessions");
                }
#if SAZ_SUPPORT
                if (oAllSessions.Count > Config.MaxLogLength)
                {
                    //save log
                    //MySession.SaveSessionsTo(oAllSessions,@"log\");
                    //clear mem
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Clear();
                    Monitor.Exit(oAllSessions);
                }
                ;
#endif
            };

            // Tell the system console to handle CTRL+C by calling our method that
            // gracefully shuts down the FiddlerCore.
            //
            // Note, this doesn't handle the case where the user closes the window with the close button.
            // See http://geekswithblogs.net/mrnat/archive/2004/09/23/11594.aspx for info on that...
            //
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
            #endregion AttachEventListeners

            string sSAZInfo = "NoSAZ";
#if SAZ_SUPPORT
            // If this demo was compiled with a SAZ-Transcoder, then the following lines will load the
            // Transcoders into the available transcoders. You can load other types of Transcoders from
            // a different assembly if you'd like, using the ImportTranscoders(string AssemblyPath) overload.
            // See https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip for an example.
            //
            if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly()))
            {
                Console.WriteLine("This assembly was not compiled with a SAZ-exporter");
            }
            else
            {
                sSAZInfo = SAZFormat.GetZipLibraryInfo();
            }
#endif

            //Console.WriteLine(String.Format("Starting {0} ({1})...", Fiddler.FiddlerApplication.GetVersionString(), sSAZInfo));

            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates
            Fiddler.CONFIG.IgnoreServerCertErrors = true;

            // but we can allow a specific (even invalid) certificate by implementing and assigning a callback...
            // FiddlerApplication.OverrideServerCertificateValidation += new OverrideCertificatePolicyHandler(FiddlerApplication_OverrideServerCertificateValidation);

            // Because we've chosen to decrypt HTTPS traffic, makecert.exe must
            // be present in the Application folder.

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            Fiddler.FiddlerApplication.Startup(Config.Port, FiddlerCoreStartupFlags.Default);
            FiddlerApplication.Log.LogString("Using Gateway: " + ((CONFIG.bForwardToGateway) ? "TRUE" : "FALSE"));

            Console.WriteLine("Hit CTRL+C to end session.");

            oSecureEndpoint = null;
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(7777, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogString("Created secure end point listening on port 7777, using a HTTPS certificate for '" + sSecureEndpointHostname + "'");
            }
            if (Config.DomainFilter == "")
            {
                //WriteTest("Listening in the port "+Port+" for all domains");
                WriteTest("Listening in the port ");
                WriteWarning("\b" + Config.Port);
                WriteTest(" for all domains");
            }
            else
            {
                WriteTest("Listening in the port ");
                WriteWarning("" + Config.Port);
                WriteTest(" for domain:");
                WriteWarning("" + Config.DomainFilter);
            }

            //XNMD.F.Show("test");
            //begin xss detect when start
            ualoader = new UALoader();
            Console.WriteLine("starting xss detect.....\nuse your ie or chrome to browser your web page\n");
            ualoader.OnLoad();
            bool mDone = false;

            do
            {
                WriteHelp("\nCommand:\n[d=Domain config;c=Clear cache; L=List session;  q=Quit;g=Collect Garbage;\nh=Hosts config; w=Write SAZ;r=reload SAZ; s=Toggle Forgetful Streaming; t=Toggle Title Counter;e=encode tool;]:");
                Console.Write("main>");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (cki.KeyChar)
                {
                case 'c':
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Clear();
                    Monitor.Exit(oAllSessions);
                    WriteCommandResponse("Clear...");
                    FiddlerApplication.Log.LogString("Cleared session list.");
                    break;

                case 'd':
                    if (Config.DomainFilter == "")
                    {
                        WriteTest("capture all domain\n");
                    }
                    else
                    {
                        WriteTest("domain is :" + Config.DomainFilter + "\n");
                    }
                    Console.Write("input new domain:\n");
                    Config.DomainFilter = Console.ReadLine();
                    if (Config.DomainFilter == "")
                    {
                        WriteTest("capture all domain\n");
                    }
                    else
                    {
                        WriteTest("domain is :" + Config.DomainFilter + "\n");
                    }
                    Config.Conf["configuration"]["domain"].InnerText = Config.DomainFilter;
                    break;

                case 'l':
                    MySession.WriteSessionList(oAllSessions);
                    break;

                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'h':
                    WriteHelp("set hosts");

                    Application.EnableVisualStyles();
                    //Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1());
                    break;

                case 'q':
                    mDone = true;
                    Config.Conf.Save(Config.strConfFileName);

                    break;

                case 'r':
#if SAZ_SUPPORT
                    MySession.ReadSessions(oAllSessions);
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 'w':
#if SAZ_SUPPORT
                    if (oAllSessions.Count > 0)
                    {
                        MySession.SaveSessionsTo(oAllSessions, @"log\");
                        Monitor.Enter(oAllSessions);
                        oAllSessions.Clear();
                        Monitor.Exit(oAllSessions);
                    }
                    else
                    {
                        WriteCommandResponse("No sessions have been captured");
                    }
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 't':
                    bUpdateTitle  = !bUpdateTitle;
                    Console.Title = (bUpdateTitle) ? "Title bar will update with request count..." :
                                    "Title bar update suppressed...";
                    break;


                // Forgetful streaming
                case 's':
                    bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful);
                    Console.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data.");
                    break;

                case 'e':
                    frmTextWizard wizard = new frmTextWizard();
                    //wizard.Show();
                    Application.Run(wizard);
                    break;

                    //case 'x':

                    //    ualoader = new UALoader();
                    //    Console.WriteLine("starting xss detect.....");
                    //    ualoader.OnLoad();
                    //    //ualoader.OnBeforeUnload();
                    //    break;

                    /*
                     * case 'p':
                     *  bool pDone = false;
                     *  do
                     *  {
                     *      WriteHelp("\nCommand [M|Q=Back to Main;X=XSS detect;#todo:R=Record a login;S=Scan;");
                     *      Console.Write("Penetest>");
                     *      ConsoleKeyInfo pki = Console.ReadKey();
                     *      Console.WriteLine();
                     *      switch(pki.KeyChar)
                     *      {
                     *          case 'm':
                     *              //back to main
                     *              pDone = true;
                     *              break;
                     *          case 'q':
                     *              //back to main
                     *              pDone = true;
                     *              break;
                     *          //case 'r':
                     *          //    string url = Interaction.InputBox("请输入登录入口", "录制登录过程", "http://www.renren.com", 100, 100);
                     *          //    //string html = LoginRecord.browser("http://wap.renren.com");
                     *          //    //WriteWarning("html:"+html);
                     *          //    //LoginRecord.msgbox("hello");
                     *          //    LoginRecord.Browser(url);
                     *          //    break;
                     *
                     *          case 'x':
                     *
                     *              ualoader = new UALoader();
                     *              Console.WriteLine("starting xss detect.....");
                     *              ualoader.OnLoad();
                     *              //ualoader.OnBeforeUnload();
                     *              break;
                     *
                     *
                     *      }
                     *  } while (!pDone);
                     *  break;
                     */
                }//end switch
            } while (!mDone);

            DoQuit();
        }
Пример #27
0
        public static void Main(string[] args)
        {
            // This is a workaround for known issue in .NET Core - https://github.com/dotnet/coreclr/issues/12668
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            //
            // It is important to understand that FiddlerCore calls event handlers on session-handling
            // background threads.  If you need to properly synchronize to the UI-thread (say, because
            // you're adding the sessions to a list view) you must call .Invoke on a delegate on the
            // window handle.
            //
            // If you are writing to a non-threadsafe data structure (e.g. List<>) you must
            // use a lock or other mechanism to ensure safety.
            //

            FiddlerApplication.Log.OnLogString += (object sender, LogEventArgs oLEA) =>
            {
                Console.WriteLine("** LogString: " + oLEA.LogString);
            };

            FiddlerApplication.BeforeRequest += (Session oS) =>
            {
                // In order to enable response tampering, buffering mode MUST
                // be enabled; this allows FiddlerCore to permit modification of
                // the response in the BeforeResponse handler rather than streaming
                // the response to the client as the response comes in.
                oS.bBufferResponse = false;
                lock (oAllSessions)
                {
                    oAllSessions.Add(oS);
                }

                // Set this property if you want FiddlerCore to automatically authenticate by
                // answering Digest/Negotiate/NTLM/Kerberos challenges itself
                // oS["X-AutoAuth"] = "(default)";

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "Ok");
                    oS.oResponse["Content-Type"]  = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };

            // The following event allows you to examine every response buffer read by Fiddler. Note that this isn't useful for the vast majority of
            // applications because the raw buffer is nearly useless; it's not decompressed, it includes both headers and body bytes, etc.
            //
            // This event is only useful for a handful of applications which need access to a raw, unprocessed byte-stream
            // FiddlerApplication.OnReadResponseBuffer += FiddlerApplication_OnReadResponseBuffer;

            /*
             * FiddlerApplication.BeforeResponse += (Session oS) =>
             * {
             *  Console.WriteLine($"{oS.id}:HTTP {oS.responseCode} for {oS.fullUrl}");
             *
             *  // Uncomment the following two statements to decompress/unchunk the
             *  // HTTP response and subsequently modify any HTTP responses to replace
             *  // instances of the word "Microsoft" with "Bayden". You MUST also
             *  // set bBufferResponse = true inside the beforeREQUEST method above.
             *  //
             *  // oS.utilDecodeResponse();
             *  // oS.utilReplaceInResponse("Microsoft", "Bayden");
             * };
             */

            FiddlerApplication.AfterSessionComplete += (Session oS) =>
            {
                int count;
                lock (oAllSessions)
                {
                    count = oAllSessions.Count;
                }

                Console.Title = ($"Session list contains: {count} sessions");
            };

            // Tell the system console to handle CTRL+C by calling our method that
            // gracefully shuts down the FiddlerCore.
            //
            // Note, this doesn't handle the case where the user closes the window with the close button.
            // See http://geekswithblogs.net/mrnat/archive/2004/09/23/11594.aspx for info on that...
            //
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            Console.WriteLine($"Starting {FiddlerApplication.GetVersionString()}...");

            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates. Change this from the default only
            // if you know EXACTLY what that implies.
            CONFIG.IgnoreServerCertErrors = false;

            // ... but you can allow a specific (even invalid) certificate by implementing and assigning a callback...
            // FiddlerApplication.OnValidateServerCertificate += CheckCert;

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // For forward-compatibility with updated FiddlerCore libraries, it is strongly recommended that you
            // start with the DEFAULT options and manually disable specific unwanted options.
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            // E.g. If you want to add a flag, start with the .Default and "OR" the new flag on:
            // oFCSF = (oFCSF | FiddlerCoreStartupFlags.RegisterAsSystemProxy);

            // Uncomment the next line if you don't want to decrypt SSL traffic.
            // oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);

            // NOTE: In the next line, you can pass 0 for the port (instead of 8877) to have FiddlerCore auto-select an available port
            int iPort = 8877;

            FiddlerApplication.Startup(iPort, oFCSF /*, upstreamGateway: "http=CorpProxy:80;https=SecureProxy:443;ftp=ftpGW:20"*/);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());

            Console.WriteLine("Hit CTRL+C to end session.");

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }

            bool bDone = false;

            do
            {
                Console.WriteLine("\nEnter a command [C=Clear; D=Shutdown; E=Export cert to Desktop; L=List;\n\tG=Collect Garbage; T=Trust cert on Windows; S=Toggle Forgetful\n\tStreaming; Q=Quit]:");
                Console.Write(">");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (Char.ToLower(cki.KeyChar))
                {
                case 'c':
                    lock (oAllSessions)
                    {
                        oAllSessions.Clear();
                    }

                    WriteCommandResponse("Clear...");
                    FiddlerApplication.Log.LogString("Cleared session list.");
                    break;

                case 'd':
                    FiddlerApplication.Log.LogString("FiddlerApplication::Shutdown.");
                    FiddlerApplication.Shutdown();
                    break;

                case 'e':
                    X509Certificate2 rootCert = CertMaker.GetRootCertificate();
                    if (rootCert == null)
                    {
                        FiddlerApplication.Log.LogString("Root certificate not found.");
                        break;
                    }

                    byte[] rootCertBytes = rootCert.Export(X509ContentType.Cert);
                    string rootCertPath  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "FiddlerCoreRoot.cer");
                    File.WriteAllBytes(rootCertPath, rootCertBytes);
                    FiddlerApplication.Log.LogString("Root certificate exported successfully.");
                    break;

                case 'l':
                    WriteSessionList();
                    break;

                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'q':
                    bDone = true;
                    DoQuit();
                    break;

                case 't':
                    try
                    {
                        WriteCommandResponse("Result: " + CertMaker.trustRootCert().ToString());
                    }
                    catch (Exception eX)
                    {
                        WriteCommandResponse("Failed: " + eX.ToString());
                    }
                    break;

                // Forgetful streaming
                case 's':
                    bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful);
                    Console.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data.");
                    break;
                }
            } while (!bDone);
        }
Пример #28
0
 // Token: 0x06000011 RID: 17 RVA: 0x000026C0 File Offset: 0x000008C0
 private static void Setup(string user, string pass, string path)
 {
     try
     {
         string key  = Program.GetKey(user, pass);
         bool   flag = !Program.GetData(key);
         if (flag)
         {
             string path2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LazyBuddy.ini");
             bool   flag2 = File.Exists(path2);
             if (flag2)
             {
                 File.Delete(path2);
             }
             Program.Uyarı("There has been error while track data from net");
         }
         byte[] Eb             = Program.RandomizeByte(Convert.FromBase64String(Program.dataKek.Eb));
         byte[] Core           = Program.RandomizeByte(Convert.FromBase64String(Program.dataKek.Core));
         string Dependencies   = Program.SolveData(Program.dataKek.Dependencies);
         string News           = Program.SolveData(Program.dataKek.News);
         string Aka            = Program.SolveData(Program.dataKek.Aka);
         string OKTWAuthSite   = "oktw.me/test1.php";
         string OKTWAuthSite2  = "oktw.hekko24.pl/hekko.php";
         string EvadeAuthSite  = "oktw.me/test5.php";
         string EvadeAuthSite2 = "oktw.hekko24.pl/authEvade.php";
         FiddlerApplication.add_BeforeRequest(delegate(Session oS)
         {
             oS.bBufferResponse = (oS.get_fullUrl().Contains("EloBuddy/EloBuddy.Dependencies") || oS.get_fullUrl().Contains("oktw.me/") || oS.get_fullUrl().Contains("oktw.hekko24.pl/") || oS.get_fullUrl().Contains("akaeb.com/connect.php"));
             Program.CreateLocalServer(oS, "lazybuddy.ca/eb.dll", Eb);
             Program.CreateLocalServer(oS, "lazybuddy.ca/core.dll", Core);
             bool flag4 = oS.get_fullUrl().Contains(OKTWAuthSite) || oS.get_fullUrl().Contains(OKTWAuthSite2);
             if (flag4)
             {
                 string[] array = oS.get_fullUrl().Split(new char[]
                 {
                     '?'
                 });
                 string arg     = array[1];
                 string address = string.Format("https://leakod.com/auth/lazy/oktw.php?{0}&key={1}", arg, key);
                 string kek     = new WebClient().DownloadString(address);
                 Program.Kek    = kek;
             }
             bool flag5 = oS.get_fullUrl().Contains(EvadeAuthSite) || oS.get_fullUrl().Contains(EvadeAuthSite2);
             if (flag5)
             {
                 string[] array2 = oS.get_fullUrl().Split(new char[]
                 {
                     '?'
                 });
                 string arg2     = array2[1];
                 string address2 = string.Format("https://leakod.com/auth/lazy/evade.php?{0}&key={1}", arg2, key);
                 string kek2     = new WebClient().DownloadString(address2);
                 Program.Kek2    = kek2;
             }
         });
         FiddlerApplication.add_BeforeResponse(delegate(Session oS)
         {
             bool flag4 = oS.get_fullUrl().Contains("EloBuddy/EloBuddy.Dependencies");
             if (flag4)
             {
                 oS.utilDecodeResponse();
                 bool flag5 = oS.get_fullUrl().Contains("dependencies.json");
                 if (flag5)
                 {
                     oS.utilSetResponseBody(Dependencies);
                 }
                 bool flag6 = oS.get_fullUrl().Contains("news.json");
                 if (flag6)
                 {
                     oS.utilSetResponseBody(News);
                 }
             }
             bool flag7 = oS.get_fullUrl().Contains("oktw.me/") || oS.get_fullUrl().Contains("oktw.hekko24.pl/");
             if (flag7)
             {
                 oS.utilDecodeResponse();
                 bool flag8 = oS.get_fullUrl().Contains(OKTWAuthSite) || oS.get_fullUrl().Contains(OKTWAuthSite2);
                 if (flag8)
                 {
                     oS.utilSetResponseBody(Program.Kek);
                 }
                 bool flag9 = oS.get_fullUrl().Contains(EvadeAuthSite) || oS.get_fullUrl().Contains(EvadeAuthSite2);
                 if (flag9)
                 {
                     oS.utilSetResponseBody(Program.Kek2);
                 }
             }
             bool flag10 = oS.get_fullUrl().Contains("akaeb.com/connect.php");
             if (flag10)
             {
                 oS.utilDecodeResponse();
                 oS.utilSetResponseBody(Aka);
             }
         });
         CONFIG.set_IgnoreServerCertErrors(true);
         FiddlerApplication.Startup(5216, true, true);
         Program.oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(Program.port, true, Program.host);
         Console.WriteLine("Starting EloBuddy.Loader.exe..");
         Thread.Sleep(2000);
         IntPtr  consoleWindow = Program.GetConsoleWindow();
         Process p             = Process.Start(path);
         Program.ShowWindow(consoleWindow, 0);
         Program.CallbackLoader(p);
         object obj  = new object();
         object obj2 = obj;
         lock (obj2)
         {
             Monitor.Wait(obj);
         }
     }
     catch (Exception ex)
     {
         Program.Uyarı(ex.ToString());
     }
 }
Пример #29
0
        private void button1_Click(object btnsender, EventArgs e)
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            FiddlerApplication.SetAppDisplayName("FiddlerDaX");

            #region AttachEventListeners
            FiddlerApplication.OnNotification += (sender, oNEA) =>
            {
                Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString);
            };

            FiddlerApplication.BeforeRequest += (oS) =>
            {
                oS["X-OverrideGateway"] = "127.0.0.1:8888";
                oS.bBufferResponse      = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                // Set this property if you want FiddlerCore to automatically authenticate by
                // answering Digest/Negotiate/NTLM/Kerberos challenges itself
                // oS["X-AutoAuth"] = "(default)";

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                //if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                //{
                //    oS.utilCreateResponseAndBypassServer();
                //    oS.oResponse.headers.SetStatus(200, "Ok");
                //    oS.oResponse["Content-Type"] = "text/html; charset=UTF-8";
                //    oS.oResponse["Cache-Control"] = "private, max-age=0";
                //    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                //}
            };

            Fiddler.FiddlerApplication.OnReadResponseBuffer += FiddlerApplication_OnReadResponseBuffer;



            FiddlerApplication.ResponseHeadersAvailable += oS =>
            {
                Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
                var contentlength = oS.ResponseHeaders["Content-Length"];
                if (!string.IsNullOrWhiteSpace(contentlength) && int.Parse(contentlength) > 100000)
                {
                    dgv.BeginInvoke((Action)(() =>
                    {
                        sessionDS.SessionTable.AddSessionTableRow(oS.url, int.Parse(contentlength), oS);
                    }));
                }
                else
                {
                    dgv.BeginInvoke((Action)(() =>
                    {
                        sessionDS.SessionTable.AddSessionTableRow(oS.url, -1, oS);
                    }));
                }
            };
            FiddlerApplication.BeforeResponse += (oS) =>
            {
                if (oS.oFlags.ContainsKey("dax_id"))
                {
                    oS.utilDecodeResponse();
                    oS.SaveResponseBody(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DaXCaps", oS.oFlags["dax_id"] + "_DaX_" + oS.RequestHeaders["Range"].Substring("bytes=".Length) + "_XaD_" + oS.SuggestedFilename));
                }
            };

            FiddlerApplication.AfterSessionComplete += (oS) =>
            {
                Console.WriteLine("Finished session:\t" + oS.fullUrl);
            };

            #endregion AttachEventListeners



            string sSAZInfo = "NoSAZ";
            Console.WriteLine(String.Format("Starting {0} ({1})...", FiddlerApplication.GetVersionString(), sSAZInfo));

            CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
            int iPort = 7777;
            oFCSF = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            FiddlerApplication.Startup(iPort, oFCSF);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }
        }
Пример #30
0
        private void Go(int iPort = 8877)
        { //设置别名
            Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreHw");

            Fiddler.CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);


            //启动方式
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            //定义http代理端口

            //启动代理程序,开始监听http请求
            //端口,是否使用windows系统代理(如果为true,系统所有的http访问都会使用该代理)
            Fiddler.FiddlerApplication.Startup(iPort, false, true, true);



            // 我们还将创建一个HTTPS监听器,当FiddlerCore被伪装成HTTPS服务器有用
            // 而不是作为一个正常的CERN样式代理服务器。
            Proxy  oSecureEndpoint         = null;
            int    iSecureEndpointPort     = 8888;
            string sSecureEndpointHostname = "127.0.0.1";

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);

            AddTXT("开始监控 下面需要出现 成功链接代理 才能正常获取版本");

            int isconn = 0; int iscomit = 0;
            //定义会话,每一个请求都将封装成一个会话
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();
            string firmware = ""; string hwconfig = ""; string thisIMEI = "";

            okimei = textBox2.Text;
            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                try
                {
                    oS.bBufferResponse = true;
                    Monitor.Enter(oAllSessions);



                    if (oS.fullUrl.IndexOf("hicloud.com") > -1)
                    {
                        AddTXT(oS.fullUrl);
                        //AddTXT("10%");
                        string v = oS.GetRequestBodyAsString();
                        if (oS.fullUrl.IndexOf("authorize.action") > -1)
                        {
                            AddTXT(v);
                        }
                        //AddTXT(v);
                        if (oS.fullUrl.IndexOf("http://query.hicloud.com:80/sp_ard_common/v2/Check.action") > -1 ||
                            oS.fullUrl.IndexOf("http://query.hicloud.com/sp_ard_common/v2/Check.action") > -1)
                        {
                            //AddTXT("44%");



                            //oS.utilSetRequestBody(v);
                            resqustnum++;
                        }


                        if (oS.fullUrl.IndexOf(".zip") > -1)
                        {
                            oS.bBufferResponse = false;
                        }


                        if (oS.fullUrl.IndexOf("https://updatebeta.hicloud.com/TDS/data/") > -1)
                        {
                            //AddTXT("11%");
                            //v = "{\"rules\":{\"IMEI\":\"869158020296105\"}}";

                            //AddTXT("12%");
                            oS.utilSetRequestBody(v);

                            //AddTXT("13%");
                            if (oS.fullUrl.IndexOf(".zip") > -1)
                            {
                                AddTXT("41%");
                                oS.bBufferResponse = false;
                                AddTXT("正在下载升级包...");
                            }
                            if (oS.fullUrl.IndexOf("changelog.xml") > -1)
                            {
                                AddTXT("21%");
                                AddTXT("加载日志");
                            }
                            if (oS.fullUrl.IndexOf("filelist.xml") > -1)
                            {
                                AddTXT("31%");
                                AddTXT("加载文件列表");
                            }
                        }
                    }


                    //AddTXT("51%");



                    oAllSessions.Add(oS);
                    Monitor.Exit(oAllSessions);
                    oS["X-AutoAuth"] = "(default)";
                    //AddTXT("52%");
                }
                catch (Exception ee)
                {
                    AddTXT("92%");
                    AddTXT(ee.ToString());
                }
            };
            Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS)
            {
                if (isconn == 0)
                {
                    isconn++;
                    AddTXT("成功链接代理");
                }

                oS.utilDecodeResponse();



                if (oS.fullUrl.IndexOf("servicesupport/updateserver/getConfig") > -1)
                {
                    hwconfig = oS.GetRequestBodyAsString();
                    HwConfig hwc = JsonConvert.DeserializeObject <HwConfig>(hwconfig);
                    if (hwc != null)
                    {
                        List <condPara> cpl = hwc.condParaList;
                        if (cpl != null)
                        {
                            condPara cp = cpl.Where(x => x.key == "IMEI").SingleOrDefault();
                            if (cp != null)
                            {
                                thisIMEI = cp.value;
                                AddTXT("串码" + thisIMEI);
                            }
                        }
                    }
                }



                if (oS.fullUrl.IndexOf("authorize.action") > -1)
                {
                    // I6IjEifV19

                    var auta = oS.GetResponseBodyAsString();
                    AddTXT(auta);

                    //oS.utilSetResponseBody(auta.Replace("I6IjEifV19", "I6IjAifV19"));
                }
                if (oS.fullUrl.IndexOf("UpdateReport.action") > -1)
                {
                    // I6IjEifV19

                    var auta1 = oS.GetRequestBodyAsString();
                    AddTXT(auta1);
                    var auta = oS.GetResponseBodyAsString();
                    AddTXT(auta);

                    //oS.utilSetResponseBody(auta.Replace("I6IjEifV19", "I6IjAifV19"));
                }



                if (oS.fullUrl.IndexOf("http://query.hicloud.com:80/sp_ard_common/v2/Check.action") > -1 ||
                    oS.fullUrl.IndexOf("http://query.hicloud.com/sp_ard_common/v2/Check.action") > -1)
                {
                    if (!checkBox1.Checked)
                    {
                        var a = thisIMEI.IndexOf(okimei);
                        if (a < 0)
                        {
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            AddTXT("IMEI不对不能使用");
                            return;
                        }
                    }
                    #region 获取版本
                    AddTXT("0%");
                    if (isconn == 1)
                    {
                        isconn++;
                        if (oS.fullUrl.IndexOf("http://query.hicloud.com:80/sp_ard_common/v2/Check.action") > -1)
                        {
                            //ctype = 1;
                            AddTXT("正在使用WIFI代理获取升级版本");
                        }
                        else
                        if (oS.fullUrl.IndexOf("http://query.hicloud.com/sp_ard_common/v2/Check.action") > -1)
                        {
                            //ctype = 3;
                            AddTXT("正在使用华为手机助手获取升级版本(旧)");
                        }
                        else
                        {
                            AddTXT("路径异常");
                        }
                    }
                    try
                    {
                        AddTXT("1%");

                        string str = oS.GetResponseBodyAsString();

                        string v = oS.GetRequestBodyAsString();

                        Mate8RequestBody rule = JsonConvert.DeserializeObject <Mate8RequestBody>(v);
                        firmware = rule.rules.DeviceName;

                        if (iscomit == 0)
                        {
                            if (firmware == "NXT-AL10" ||
                                firmware == "NXT-CL00" ||
                                firmware == "NXT-TL00" ||
                                firmware == "NXT-DL00")
                            {
                                if (rule.rules.PackageType == "full_back")
                                {
                                    iscomit++;
                                    var vf = firmware + rule.rules.C_version;
                                    str = ("{|status|:|0|,|components|:[{|name|:|[小烈哥]" + vf + "B386|,|version|:|" + vf + "B386|,|versionID|:|65694|,|description|:|386|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1255/g104/v65694/f1/|}]}").Replace("|", "\"");
                                }
                                if (rule.rules.PackageType == "full")
                                {
                                    iscomit++;
                                    var vf = firmware + rule.rules.C_version;
                                    str = ("{|status|:|0|,|components|:[{|name|:|[小烈哥]" + vf + "B550-log|,|version|:|" + vf + "B550-log|,|versionID|:|66474|,|description|:|550-log|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1255/g104/v66474/f1/|}]}").Replace("|", "\"");
                                }
                            }



                            if (1 == 2)
                            {
                                if (firmware == "HUAWEI NXT-AL10" ||
                                    firmware == "HUAWEI NXT-CL00")
                                {
                                    str = "{|status|:|0|,|components|:[{|name|:|[小烈哥]NXT-AL10C00B523|,|version|:|NXT-AL10C00B523|,|versionID|:|65483|,|description|:|523|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1255/g104/v65483/f1/|,|reserveUrl|:|update8.hicloud.com|,|versionType|:|1|}]}".Replace("|", "\"");
                                    if (firmware == "HUAWEI NXT-CL00")
                                    {
                                        str = str.Replace("NXT-AL10C00", "NXT-CL00C00");
                                    }
                                }
                                if (firmware == "HUAWEI NXT-TL00" ||
                                    firmware == "HUAWEI NXT-DL00")
                                {
                                    str = "{|status|:|0|,|components|:[{|name|:|[小烈哥]NXT-TL00C01B523|,|version|:|NXT-TL00C01B523|,|versionID|:|65490|,|description|:|523|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1255/g104/v65490/f1/|,|reserveUrl|:|update8.hicloud.com|,|versionType|:|1|}]}".Replace("|", "\"");
                                    if (firmware == "HUAWEI NXT-DL00")
                                    {
                                        str = str.Replace("NXT-TL00C01", "NXT-DL00C17");
                                    }
                                }


                                if (firmware == "NXT-TL00" ||
                                    firmware == "NXT-DL00")
                                {
                                    str = "{|status|:|0|,|components|:[{|name|:|[小烈哥]NXT-TL00C01B531-log|,|version|:|NXT-TL00C01B531-log|,|versionID|:|65880|,|description|:|531|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1255/g104/v65880/f1/|,|reserveUrl|:|update8.hicloud.com|,|versionType|:|1|}]}".Replace("|", "\"");
                                    if (firmware == "NXT-DL00")
                                    {
                                        str = str.Replace("NXT-TL00C01", "NXT-DL00C17");
                                    }
                                }


                                if (firmware == "EVA-AL00" ||
                                    firmware == "EVA-TL00" ||
                                    firmware == "EVA-UL00" ||
                                    firmware == "EVA-CL00")
                                {
                                    str = "{|status|:|0|,|components|:[{|name|:|[小烈哥]EVA-TL00C01B323|,|version|:|EVA-TL00C01B323|,|versionID|:|65543|,|description|:|323|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1256/g104/v65543/f1/|,|reserveUrl|:|update8.hicloud.com|,|versionType|:|1|}]}".Replace("|", "\"");
                                    if (firmware == "EVA-AL00")
                                    {
                                        str = str.Replace("EVA-TL00C01", "EVA-AL00C00");
                                    }
                                }
                                if (firmware == "EVA-AL10")
                                {
                                    str = "{|status|:|0|,|components|:[{|name|:|[小烈哥]EVA-AL10C00B323|,|version|:|EVA-AL10C00B323|,|versionID|:|65542|,|description|:|323|,|ruleAttr|:||,|createTime|:|2016-09-18T06:55:50+0000|,|url|:|http://update.hicloud.com:8180/TDS/data/files/p3/s15/G1256/g104/v65542/f1/|,|reserveUrl|:|update8.hicloud.com|,|versionType|:|1|}]}".Replace("|", "\"");
                                    //if (firmware == "EVA-AL00")
                                    //{
                                    //    str = str.Replace("EVA-TL00C01", "EVA-AL00C00");
                                    //}
                                }
                            }
                        }
                        //if (iscomit >0)
                        //{
                        //    str = "{\"status\":\"1\"}";
                        //}
                        oS.utilSetResponseBody(str);



                        //if (v2.IndexOf("EVA-AL00C00B193") > -1) {
                        //    v2 = v2.Replace("EVA-AL00C00B193", "EVA-AL10C00B193");
                        //    oS.utilSetResponseBody(v2);
                        //}

                        //AddTXT(str);


                        AddTXT("开始加载升级数据");
                        //string v1 = "{\"status\":\"0\",\"components\":[{\"name\":\"EVA-AL00C00B193\",\"version\":\"EVA-AL00C00B193\",\"versionID\":\"64011\",\"description\":\"【B192-B193差分包】EVA-AL00C00B193\",\"ruleAttr\":\"type_A\",\"createTime\":\"2016-10-18T10:48:42+0000\",\"url\":\"https://updatebeta.hicloud.com/TDS/data/FF38E764923BF183D14E26F58988076A9E4423EC65B51AE3526B4888E05AECC2/1477137653/files/p3/s15/G1434/g1433/v64011/f1/\",\"reserveUrl\":\"\",\"versionType\":\"2\"}]}";
                        AddTXT("2%");
                        //oS.utilSetResponseBody(v1);
                        AddTXT("3%");
                    }
                    catch (Exception ee)
                    {
                        AddTXT("91%");
                        AddTXT(ee.ToString());
                    }
                    #endregion
                }
            };
        }