Ejemplo n.º 1
0
        public static void Startup(int iListenPort, bool bRegisterAsSystemProxy, bool bDecryptSSL, bool bAllowRemote)
        {
            FiddlerCoreStartupFlags fiddlerCoreStartupFlags = FiddlerCoreStartupFlags.Default;

            if (bRegisterAsSystemProxy)
            {
                fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            }
            else
            {
                fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            }
            if (bDecryptSSL)
            {
                fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.DecryptSSL;
            }
            else
            {
                fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.DecryptSSL;
            }
            if (bAllowRemote)
            {
                fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.AllowRemoteClients;
            }
            else
            {
                fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.AllowRemoteClients;
            }
            FiddlerApplication.Startup(iListenPort, fiddlerCoreStartupFlags);
        }
Ejemplo n.º 2
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("启动代理成功");
        }
Ejemplo n.º 3
0
        public static void Start()
        {
            LogEntry("Starting proxy...");
            FiddlerCoreStartupFlags fcsf = FiddlerCoreStartupFlags.None;

            FiddlerApplication.Startup((int)Config.Port, fcsf);

            FiddlerApplication.BeforeRequest += NeedBufferResponse;
            if (Config.UseProxy)
            {
                FiddlerApplication.BeforeRequest += NeedSetProxy;
            }
            if (Config.ForceIp)
            {
                FiddlerApplication.BeforeRequest += NeedSetIp;
            }
            FiddlerApplication.BeforeResponse += OnResponse;
            LogEntry($"Proxy started, listening at port {Config.Port}");

            if (Config.UsePac)
            {
                LogEntry("Starting PAC Server...");
                string pacUrl = $"http://localhost:{Config.PacPort}/pac/";
                _ws = new WebServer(WebServer.SendResponse, pacUrl);
                _ws.Run();
                LogEntry($"PAC Server started. Please set system proxy to {pacUrl}");
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        public void startup()
        {
            FiddlerApplication.AfterSessionComplete += delegate(Session http)
            {
                if (http.fullUrl.Contains("banner") && http.fullUrl.Contains("habbo"))
                {
                    // Download?
                    string token = http.fullUrl.Split('=')[1];

                    string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\banner.png";

                    http.SaveResponseBody(dir);
                    FiddlerApplication.Shutdown();

                    LemonEnvironment.proxiedBanner = true;
                }
            };

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            FiddlerCoreStartupFlags oFlags = FiddlerCoreStartupFlags.Default;

            oFlags = (oFlags & ~FiddlerCoreStartupFlags.DecryptSSL);

            FiddlerApplication.Startup(12345, oFlags);
        }
Ejemplo n.º 7
0
        //Starting fiddler, Called by Webdriver during initialization, accepts any valid ports and returns
        //the port fiddler runs on.
        //The same port has to be passed for webdriver to use, so that fiddler can start sniffing the traffic.

        public static int StartFiddlerProxy(int desiredPort)
        {
            //Setting up flags for fiddler


            FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default &
                                            ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;

            //If the desiredPort is 0, fiddler will randomly choose any of the port and register it.

            FiddlerApplication.Startup(desiredPort, flags);

            //pick the proxyport used by fiddler
            proxyPort = FiddlerApplication.oProxy.ListenPort;

            // a simple debugger to see if the Fiddlerapplication is actually started
            bool fid = FiddlerApplication.IsStarted();

            int iProcCount        = Environment.ProcessorCount;
            int iMinWorkerThreads = Math.Max(16, 6 * iProcCount);
            int iMinIOThreads     = iProcCount;

            if ((iMinWorkerThreads > 0) && (iMinIOThreads > 0))
            {
                System.Threading.ThreadPool.SetMinThreads(iMinWorkerThreads, iMinIOThreads);
            }


            return(proxyPort);
        }
Ejemplo n.º 8
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);
            }
        }
    private static void SetupInternalProxy()
    {
        // My requirement is to get response content, so I use this event.
        // You may use other handlers if you have to tamper data.
        FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
        FiddlerApplication.Log.OnLogString      += (o, s) => Debug.WriteLine(s);
        FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

        //this line is important as it will avoid changing the proxy for the whole system.
        oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
        FiddlerApplication.Startup(0, oFCSF);
    }
Ejemplo n.º 10
0
        protected virtual int StartFiddlerProxy(int desiredPort)
        {
            // We explicitly do *NOT* want to register this running Fiddler instance as the system proxy.
            // This lets us keep isolation.
            FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;

            FiddlerApplication.Startup(desiredPort, flags);

            int proxyPort = FiddlerApplication.oProxy.ListenPort;

            return(proxyPort);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Starts the Fiddler proxy using the desired port.
        /// </summary>
        /// <param name="desiredPort">The port on which the proxy is to listen.
        /// Use zero (0) to have Fiddler select a port.</param>
        /// <returns>The port on which the Fiddler proxy is listening.</returns>
        private static int StartFiddlerProxy(int desiredPort)
        {
            // We explicitly do *NOT* want to register this running Fiddler
            // instance as the system proxy. This lets us keep isolation.
            Console.WriteLine("Starting Fiddler proxy");
            FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;

            FiddlerApplication.Startup(desiredPort, flags);
            int proxyPort = FiddlerApplication.oProxy.ListenPort;

            Console.WriteLine("Fiddler proxy listening on port {0}", proxyPort);
            return(proxyPort);
        }
Ejemplo n.º 12
0
    private void SetupInternalProxy()
    {
        FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
        FiddlerApplication.Log.OnLogString      += (o, s) => Debug.WriteLine(s);
        FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

        //this line is important as it will avoid changing the proxy for the whole system.
        oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
        FiddlerApplication.Startup(
            0,
            oFCSF
            );
    }
Ejemplo n.º 13
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;
        }
Ejemplo n.º 14
0
        public void Start(FiddlerCoreStartupFlags Flag, int ProxyPort = 8877)
        {
            if (!Running)
            {
                try
                {
                    //
                    // NOTE: Because we haven't disabled 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, Flag);
                    Fiddler.FiddlerApplication.Startup(ProxyPort, Flag);
                    WriteCommandResponse(MainWindow.InfoTag + " Proxy Port: " + ProxyPort);
                    WriteCommandResponse(MainWindow.InfoTag + " Response File: " + CurrentResponseFile);
                    WriteCommandResponse(MainWindow.InfoTag + " URI Filter active: " + URIFilterListAsString);

                    if (fiddlermessages)
                    {
                        FiddlerApplication.Log.LogString("Starting with settings: [" + Flag + "]");
                    }
                    if (fiddlermessages)
                    {
                        FiddlerApplication.Log.LogString("Using Gateway: " + ((CONFIG.bForwardToGateway) ? "TRUE" : "FALSE"));
                    }

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

                    // oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
                    if (null != PSecureEndpoint)
                    {
                        if (fiddlermessages)
                        {
                            FiddlerApplication.Log.LogString("Created secure end point listening on port " + iSecureEndpointPort.ToString() + ", using a HTTPS certificate for '" + sSecureEndpointHostname + "'");
                        }
                    }

                    Running = true;
                }
                catch (Exception ex)
                {
                    WriteCommandResponse("Error: " + ex.ToString());
                }
            }
            else
            {
                WriteCommandResponse("Error: already running");
            }
        }
Ejemplo n.º 15
0
        void Start()
        {
            if (tbIgnoreResources.Checked)
            {
                CaptureConfiguration.IgnoreResources = true;
            }
            else
            {
                CaptureConfiguration.IgnoreResources = false;
            }

            string strProcId = txtProcessId.Text;

            if (strProcId.Contains('-'))
            {
                strProcId = strProcId.Substring(strProcId.IndexOf('-') + 1).Trim();
            }

            strProcId = strProcId.Trim();

            int procId = 0;

            if (!string.IsNullOrEmpty(strProcId))
            {
                if (!int.TryParse(strProcId, out procId))
                {
                    procId = 0;
                }
            }
            CaptureConfiguration.ProcessId     = procId;
            CaptureConfiguration.CaptureDomain = txtCaptureDomain.Text;


            FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
            FiddlerApplication.BeforeResponse       += FiddlerApplication_BeforeResponse;
            //FiddlerApplication.BeforeReturningError += FiddlerApplication_BeforeReturningError;
            FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;

            const FiddlerCoreStartupFlags flags =
                FiddlerCoreStartupFlags.AllowRemoteClients |
                FiddlerCoreStartupFlags.CaptureLocalhostTraffic |
                FiddlerCoreStartupFlags.DecryptSSL |
                FiddlerCoreStartupFlags.MonitorAllConnections |
                FiddlerCoreStartupFlags.RegisterAsSystemProxy;

            Fiddler.CONFIG.IgnoreServerCertErrors = true;

            FiddlerApplication.Startup(8888, flags);
        }
Ejemplo n.º 16
0
            /// <summary>
            /// Initializes a new instance of the FiddlerOneTimeInitializer class.
            /// </summary>
            public FiddlerOneTimeInitializer()
            {
                FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // We'd like all default values, but we don't want to muck with system settings or
                // SSL connections.
                FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default
                                                & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy
                                                & ~FiddlerCoreStartupFlags.DecryptSSL;

                // For now, hardcoding 8877 for the proxy port seems appropriate.
                FiddlerApplication.Startup(8877, flags);

                this.oldProxy = WebRequest.DefaultWebProxy;
                this.newProxy = new WebProxy("http://localhost:8877", true);
            }
Ejemplo n.º 17
0
        public void Connect()
        {
            if (Port == 0)
            {
                throw new ConfigurationErrorsException("Port not set");
            }

            const FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.CaptureLocalhostTraffic
                                                  | FiddlerCoreStartupFlags.MonitorAllConnections
                                                  | FiddlerCoreStartupFlags.OptimizeThreadPool
                                                  | FiddlerCoreStartupFlags.DecryptSSL
                                                  | FiddlerCoreStartupFlags.ChainToUpstreamGateway
                                                  | FiddlerCoreStartupFlags.RegisterAsSystemProxy
            ;

            FiddlerApplication.Startup(Port, flags);
            FiddlerApplication.BeforeResponse += FiddlerApplicationOnBeforeResponse;
        }
Ejemplo n.º 18
0
            /// <summary>
            /// Initializes a new instance of the FiddlerOneTimeInitializer class.
            /// </summary>
            public FiddlerOneTimeInitializer()
            {
                FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // We'd like all default values, but we don't want to muck with system settings or
                // SSL connections.
                FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default
                                                & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy
                                                & ~FiddlerCoreStartupFlags.DecryptSSL;

                // In the event that the HttpMangler class is used from multiple AppDomains and FiddlerOneTimeInitializer()
                // is called more than once, randomize the web proxy port used by FiddlerCore to prevent conflicts.
                int port = 8800 + FiddlerOneTimeInitializer.Random.Next(0, 100);

                FiddlerApplication.Startup(port, flags);

                this.oldProxy = WebRequest.DefaultWebProxy;
                this.newProxy = new WebProxy("http://localhost:" + port.ToString(), true);
            }
        protected override void OnStart(string[] args)
        {
            int port = 9999;

            if (args.Length > 0)
            {
                int.TryParse(args[0], out port);
            }
            FiddlerCoreStartupFlags defaultFlags = FiddlerCoreStartupFlags.Default;

            Fiddler.FiddlerApplication.Startup(port, defaultFlags);

            //we also start the wcf service here
            if (_serviceHost != null)
            {
                _serviceHost.Close();
            }
            _serviceHost = new ServiceHost(typeof(ProxyService.ProxyService));
            _serviceHost.Open();
        }
Ejemplo n.º 20
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 + "'");
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// demo 来源:http://blog.csdn.net/zhang116868/article/details/49406599
        /// </summary>
        public static void FiddlerDemo()
        {
            //设置一个监听接口
            Fiddler.FiddlerApplication.Startup(8877, true, true);

            //这是别名,具体不知道干嘛
            Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");

            //Starfaction
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            //定义端口
            int iPort = 8877;

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

            //我们还要创建一个HTTPS监听器,当FiddlerCore被伪装成HTTPS服务器有用
            //而不是作为一个正常的CERN样式代理服务器,PS:CERN是什么鬼?我至今不明白笔者这个简写名称
        }
Ejemplo n.º 22
0
 public static void Startup(int iListenPort, FiddlerCoreStartupFlags oFlags)
 {
     if (FiddlerApplication.oProxy != null)
     {
         throw new InvalidOperationException("Calling startup twice without calling shutdown is not permitted.");
     }
     if (iListenPort >= 0 && iListenPort <= 65535)
     {
         CONFIG.ListenPort = iListenPort;
         CONFIG.bAllowRemoteConnections = (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.AllowRemoteClients));
         CONFIG.bMITM_HTTPS             = (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.DecryptSSL));
         CONFIG.bCaptureCONNECT         = true;
         CONFIG.bCaptureFTP             = (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.CaptureFTP));
         CONFIG.bForwardToGateway       = (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.ChainToUpstreamGateway));
         CONFIG.bHookAllConnections     = (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.MonitorAllConnections));
         if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.CaptureLocalhostTraffic))
         {
             CONFIG.sHostsThatBypassFiddler = CONFIG.sHostsThatBypassFiddler;
         }
         FiddlerApplication.oProxy = new Proxy(true);
         if (FiddlerApplication.oProxy.Start(CONFIG.ListenPort, CONFIG.bAllowRemoteConnections))
         {
             if (iListenPort == 0)
             {
                 CONFIG.ListenPort = FiddlerApplication.oProxy.ListenPort;
             }
             if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.RegisterAsSystemProxy))
             {
                 FiddlerApplication.oProxy.Attach(true);
                 return;
             }
             if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.ChainToUpstreamGateway))
             {
                 FiddlerApplication.oProxy.CollectConnectoidAndGatewayInfo();
             }
         }
         return;
     }
     throw new ArgumentOutOfRangeException("bListenPort", "Port must be between 0 and 65535.");
 }
        public void Start()
        {
            LoggerConfig.Init();
            Logger = LogManager.GetCurrentClassLogger();

            Logger.Info("Starting request obfuscator...");

            FiddlerApplication.Shutdown();

            InstallCertificate();

            var type = typeof(IApiClient);

            var apiClients = AppDomain.CurrentDomain
                             .GetAssemblies()
                             .SelectMany(s => s.GetTypes())
                             .Where(p => type.IsAssignableFrom(p) && !p.IsAbstract);

            foreach (var api in apiClients)
            {
                var apiClient  = Activator.CreateInstance(api) as IApiClient;
                var apiBuilder = new ApiBuilder();

                apiClient.Configure(apiBuilder);

                foreach (var handler in apiBuilder.Build())
                {
                    Instance += session => handler(session);
                }
            }

            const FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.AllowRemoteClients | FiddlerCoreStartupFlags.CaptureLocalhostTraffic | FiddlerCoreStartupFlags.DecryptSSL | FiddlerCoreStartupFlags.MonitorAllConnections;
            const short proxyPort = 8888;

            FiddlerApplication.Startup(proxyPort, flags);

            Logger.Info("Started.");
        }
Ejemplo n.º 24
0
        private static void Main(string[] args)
        {
            try
            {
                Configuration.SetStartupParameters(args);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }

            FiddlerCoreStartupFlags fcsf = FiddlerCoreStartupFlags.None;

            FiddlerApplication.Startup(Configuration.Port, fcsf);
            // We just need to hack APIs and so let other HTTP requests pass directly. API responses must be fully buffered (and then modified).
            FiddlerApplication.BeforeRequest  += s => { s.bBufferResponse = s.fullUrl.Contains("http://music.163.com/eapi/"); };
            FiddlerApplication.BeforeResponse += OnResponse;

            Console.WriteLine($"Proxy started, listening at port {Configuration.Port}");
            Console.Read();
            FiddlerApplication.Shutdown();
        }
Ejemplo n.º 25
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;
        }
Ejemplo n.º 26
0
        public void test()
        {
            var seleniumProxy = new Proxy {
                HttpProxy = "localhost:8877", SslProxy = "localhost:8877"
            };
            var option = new FirefoxOptions {
                Proxy = seleniumProxy
            };
            var slenium = new FirefoxDriver(option);

            const FiddlerCoreStartupFlags fiddlerStartUpFlags = FiddlerCoreStartupFlags.DecryptSSL & FiddlerCoreStartupFlags.AllowRemoteClients & FiddlerCoreStartupFlags.CaptureFTP & FiddlerCoreStartupFlags.ChainToUpstreamGateway & FiddlerCoreStartupFlags.MonitorAllConnections & FiddlerCoreStartupFlags.CaptureLocalhostTraffic;

            FiddlerApplication.Prefs.SetStringPref("fiddler.config.path.makecert", @"d:\..\Makecert.exe"); //To define the MakeCert.exe path manually.
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);   //Abort session when client abort
            FiddlerApplication.Startup(8877, fiddlerStartUpFlags);
            FiddlerApplication.AfterSessionComplete += delegate(Session targetSession)
            {
                Console.WriteLine("{0}\t{1}", targetSession.responseCode, targetSession.fullUrl);
            };
            slenium.Navigate().GoToUrl("http://google.com");
            FiddlerApplication.oProxy.PurgeServerPipePool();//Run this between tests to make sure the new test will start "clean"
            slenium.Quit();
        }
        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);
            }
        }
Ejemplo n.º 28
0
        public static void Start()
        {
            whitelist.Clear();
            string whitelistPath = System.AppDomain.CurrentDomain.BaseDirectory + "whitelist.txt";

            if (File.Exists(whitelistPath))
            {
                string   tmpStr = File.ReadAllText(whitelistPath);
                string[] tmpArr = tmpStr.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in tmpArr)
                {
                    whitelist.Add(item.Trim());
                }
            }
            oAllSessions = new List <Fiddler.Session>();
            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);
                if (whitelist.Count > 0 && !whitelist.Exists(ii => oS.fullUrl.StartsWith(ii)) && !oS.fullUrl.EndsWith(":443"))
                {
                    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>" + oS.fullUrl + "<br /><plaintext>" + oS.oRequest.headers.ToString());
                    return;
                }

                if (oS.fullUrl.EndsWith("api/v1/users/first_login"))
                {
                    string  postData = Encoding.UTF8.GetString(oS.RequestBody);
                    JObject jo;
                    try
                    {
                        jo = (JObject)JsonConvert.DeserializeObject(postData);
                    }
                    catch (Exception exx)
                    {
                        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("Error");
                        return;
                    }
                    string  user_name  = jo["user_name"].ToString();
                    string  password   = jo["password"].ToString();
                    string  sg_version = jo["sg_version"].ToString();
                    JObject rep;
                    string  errmsg = getUserSaveData(out rep, user_name, password, sg_version);
                    if (!string.IsNullOrEmpty(errmsg))
                    {
                        oS.utilCreateResponseAndBypassServer();
                        oS.oResponse.headers.SetStatus(200, "Ok");
                        oS.oResponse["Content-Type"] = "application/json; charset=utf-8";
                        oS.oResponse["Connection"]   = "close";
                        oS.oResponse["Server-Time"]  = "1554991178";
                        oS.oResponse["Sign"]         = "59a46dea1320406c36a4989aa42d6929";
                        oS.utilSetResponseBody("{\"code\":1,\"type\":1,\"message\":\"无效的网络请求!\"}");
                    }
                    else
                    {
                        if (rep["hold"] != null && (bool)rep["hold"])
                        {
                            oS.utilCreateResponseAndBypassServer();
                            oS.oResponse.headers.SetStatus(200, "Ok");
                            foreach (JObject item in (JArray)rep["head"])
                            {
                                oS.oResponse[item["k"].ToString()] = item["v"].ToString();
                            }
                            oS.utilSetResponseBody(rep["data"].ToString());
                            oS.oResponse.headers.Remove("Content-Length");
                        }
                    }
                }
                else if (oS.fullUrl.EndsWith("api/v2/users/save_user"))
                {
                    //存档包,拦截作弊提示
                    string  postData = Encoding.UTF8.GetString(oS.RequestBody);
                    JObject jo;
                    try
                    {
                        jo = (JObject)JsonConvert.DeserializeObject(postData);
                    }
                    catch (Exception exx)
                    {
                        oS.utilCreateResponseAndBypassServer();
                        oS.oResponse.headers.SetStatus(200, "Ok");
                        oS.oResponse["Content-Type"] = "application/json; charset=utf-8";
                        oS.oResponse["Connection"]   = "close";
                        oS.oResponse["Server-Time"]  = "1554991178";
                        oS.oResponse["Sign"]         = "59a46dea1320406c36a4989aa42d6929";
                        oS.utilSetResponseBody("{\"code\":1,\"type\":1,\"message\":\"无效的网络请求!\"}");
                        return;
                    }

                    if (jo["yisizuobi"] != null)
                    {
                        string zbxx = jo["zbbeizhu"].ToString();
                        ConsoleLog("作弊警告:" + zbxx, ConsoleColor.Red);

                        jo.Remove("yisizuobi");
                        jo.Remove("zbbeizhu");
                        postData       = jo.ToString(Formatting.None);
                        oS.RequestBody = Encoding.UTF8.GetBytes(postData);
                        string dct = oS.RequestHeaders["Server-Time"];
                        string signStr;
                        string errMsg = getSignData(out signStr, dct, postData, zbxx, jo["uuid"].ToString());
                        if (string.IsNullOrEmpty(errMsg))
                        {
                            oS.RequestHeaders["Sign"] = signStr;
                        }
                        else
                        {
                            //失败
                            Console.WriteLine("**Err>>:" + signStr);
                            oS.utilCreateResponseAndBypassServer();
                            oS.oResponse.headers.SetStatus(200, "Ok");
                            oS.oResponse["Content-Type"] = "application/json; charset=utf-8";
                            oS.oResponse["Connection"]   = "close";
                            oS.oResponse["Server-Time"]  = "1554991178";
                            oS.oResponse["Sign"]         = "59a46dea1320406c36a4989aa42d6929";
                            oS.utilSetResponseBody("{\"code\":1,\"type\":1,\"message\":\"无效的网络请求!\"}");
                        }
                    }
                }
                else if (oS.fullUrl.EndsWith("/v1/check_code"))
                {
                    //礼包
                    string postData = Encoding.UTF8.GetString(oS.RequestBody);
                    try
                    {
                        JObject jo = (JObject)JsonConvert.DeserializeObject(postData);
                        ConsoleLog("兑换:" + jo["code"].ToString(), ConsoleColor.Green);
                    }
                    catch (Exception exx)
                    {}
                    JObject rep;
                    string  err = getcheckCodeData(out rep, postData);
                    if (string.IsNullOrEmpty(err))
                    {
                        //已拦截
                        oS.utilCreateResponseAndBypassServer();
                        oS.oResponse.headers.SetStatus(200, "Ok");
                        foreach (JObject item in (JArray)rep["head"])
                        {
                            oS.oResponse[item["k"].ToString()] = item["v"].ToString();
                        }
                        oS.utilSetResponseBody(rep["data"].ToString());
                    }
                    else
                    {
                        ConsoleLog("兑换错误:" + err, ConsoleColor.Red);
                    }
                }
            };
            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                if (showInfo)
                {
                    Console.WriteLine("Finished session:\t" + oS.fullUrl);
                }
            };

            CONFIG.bDebugSpew      = true;
            CONFIG.bAutoProxyLogon = false;

            FiddlerApplication.Log.OnLogString += delegate(object loger, LogEventArgs e)
            {
                //throw new Exception(e.LogString);
                if (e.LogString.StartsWith("! "))
                {
                    ConsoleLog(e.LogString, ConsoleColor.Red);
                }
                else if (showInfo)
                {
                    Console.WriteLine(e.LogString);
                }
            };
            //var oRootCert = new X509Certificate2("sss.pfx", "", X509KeyStorageFlags.Exportable);
            //var z = (RSACryptoServiceProvider)oRootCert.PrivateKey;
            //var cc = DotNetUtilities.GetRsaKeyPair(z);
            //var PrivateKeyInfo = Org.BouncyCastle.Pkcs.PrivateKeyInfoFactory.CreatePrivateKeyInfo(cc.Private);
            //byte[] derEncoded = PrivateKeyInfo.ToAsn1Object().GetDerEncoded();
            //FiddlerApplication.Prefs.SetStringPref("fiddler.certmaker.bc.key", Convert.ToBase64String(derEncoded));
            //FiddlerApplication.Prefs.SetStringPref("fiddler.certmaker.bc.cert", Convert.ToBase64String(oRootCert.Export(X509ContentType.Cert)));

            var oRootCert = Fiddler.CertMaker.GetRootCertificate();

            if (oRootCert == null)
            {
                if (!Fiddler.CertMaker.createRootCert())
                {
                    throw new Exception("创建根证书失败!");
                }
                oRootCert = Fiddler.CertMaker.GetRootCertificate();
                if (oRootCert == null)
                {
                    throw new Exception("创建根证书失败!");
                }
                X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                certStore.Open(OpenFlags.ReadWrite);
                try
                {
                    certStore.Add(oRootCert);
                }
                finally
                {
                    certStore.Close();
                }
                Console.WriteLine("=============================save my ok=================================");
                X509Store x509Store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
                x509Store.Open(OpenFlags.ReadWrite);
                try
                {
                    x509Store.Add(oRootCert);
                }
                finally
                {
                    x509Store.Close();
                }
                Console.WriteLine("=============================save root ok=================================");
                oRootCert = Fiddler.CertMaker.GetRootCertificate();
                if (oRootCert == null)
                {
                    throw new Exception("保存根证书失败!");
                }
            }

            Console.WriteLine("==============================================================");
            Console.WriteLine("RootCertHasPrivateKey:" + oRootCert.HasPrivateKey);
            Console.WriteLine("rootCertExists:" + CertMaker.rootCertExists());
            Console.WriteLine("rootCertIsTrusted:" + CertMaker.rootCertIsTrusted());
            if (!CertMaker.rootCertIsTrusted())
            {
                CertMaker.trustRootCert();
                Console.WriteLine("**rootCertIsTrusted:" + CertMaker.rootCertIsTrusted());
            }
            Console.WriteLine("==============================================================");
            Console.WriteLine(oRootCert);
            Console.WriteLine("==============================================================");

            Fiddler.CONFIG.IgnoreServerCertErrors = true;
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.DecryptSSL | FiddlerCoreStartupFlags.MonitorAllConnections | FiddlerCoreStartupFlags.OptimizeThreadPool | FiddlerCoreStartupFlags.AllowRemoteClients;

            Fiddler.FiddlerApplication.Startup(defaultPort, oFCSF);
            Console.WriteLine(Fiddler.FiddlerApplication.GetDetailedInfo());
        }
Ejemplo n.º 29
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();
            }
        }
Ejemplo n.º 30
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);
        }
Ejemplo n.º 31
0
 public static void Startup(int iListenPort, FiddlerCoreStartupFlags oFlags)
 {
     if (oProxy != null)
     {
         throw new InvalidOperationException("Calling startup twice without calling shutdown is not permitted.");
     }
     if ((iListenPort < 0) || (iListenPort > 0xffff))
     {
         throw new ArgumentOutOfRangeException("bListenPort", "Port must be between 0 and 65535.");
     }
     CONFIG.ListenPort = iListenPort;
     CONFIG.bAllowRemoteConnections = FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.AllowRemoteClients);
     CONFIG.bMITM_HTTPS = FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.DecryptSSL);
     CONFIG.bCaptureCONNECT = true;
     CONFIG.bCaptureFTP = FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.CaptureFTP);
     CONFIG.bForwardToGateway = FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.ChainToUpstreamGateway);
     CONFIG.bHookAllConnections = FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.MonitorAllConnections);
     if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.CaptureLocalhostTraffic))
     {
         CONFIG.sHostsThatBypassFiddler = CONFIG.sHostsThatBypassFiddler;
     }
     oProxy = new Proxy(true);
     if (oProxy.Start(CONFIG.ListenPort, CONFIG.bAllowRemoteConnections))
     {
         if (iListenPort == 0)
         {
             CONFIG.ListenPort = oProxy.ListenPort;
         }
         if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.RegisterAsSystemProxy))
         {
             oProxy.Attach(true);
         }
         else if (FiddlerCoreStartupFlags.None < (oFlags & FiddlerCoreStartupFlags.ChainToUpstreamGateway))
         {
             oProxy.CollectConnectoidAndGatewayInfo();
         }
     }
 }