コード例 #1
0
ファイル: GenericTunnel.cs プロジェクト: ploxolq/Unreal.FGO
 protected void OnClientReceive(IAsyncResult iasyncResult_0)
 {
     try
     {
         int num = this.pipeToClient.EndReceive(iasyncResult_0);
         if (num > 0)
         {
             this._lngEgressByteCount += (long)num;
             Trace.WriteLine("[GenericTunnel] Received from client: " + num.ToString() + " bytes. Sending to server...");
             Trace.WriteLine(Utilities.ByteArrayToHexView(this.arrRequestBytes, 16, num));
             FiddlerApplication.DoReadRequestBuffer(this._mySession, this.arrRequestBytes, num);
             this.pipeToRemote.Send(this.arrRequestBytes, 0, num);
             this.pipeToClient.BeginReceive(this.arrRequestBytes, 0, this.arrRequestBytes.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), null);
         }
         else
         {
             FiddlerApplication.DoReadRequestBuffer(this._mySession, this.arrRequestBytes, 0);
             this.CloseTunnel();
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine("[GenericTunnel] OnClientReceive threw... " + ex.Message);
         this.CloseTunnel();
     }
 }
コード例 #2
0
ファイル: CONNECTTunnel.cs プロジェクト: ploxolq/Unreal.FGO
        protected void OnClientReceive(IAsyncResult iasyncResult_0)
        {
            try
            {
                int num = this.socketClient.EndReceive(iasyncResult_0);
                if (num > 0)
                {
                    this._lngEgressByteCount += (long)num;
                    FiddlerApplication.DoReadRequestBuffer(this._mySession, this.arrRequestBytes, num);
                    if (this._mySession.requestBodyBytes != null)
                    {
                        if (this._mySession.requestBodyBytes.LongLength != 0L)
                        {
                            goto IL_FF;
                        }
                    }
                    try
                    {
                        HTTPSClientHello hTTPSClientHello = new HTTPSClientHello();
                        if (hTTPSClientHello.LoadFromStream(new MemoryStream(this.arrRequestBytes, 0, num, false)))
                        {
                            this._mySession.requestBodyBytes          = Encoding.UTF8.GetBytes(hTTPSClientHello.ToString() + "\n");
                            this._mySession["https-Client-SessionID"] = hTTPSClientHello.SessionID;
                            if (!string.IsNullOrEmpty(hTTPSClientHello.ServerNameIndicator))
                            {
                                this._mySession["https-Client-SNIHostname"] = hTTPSClientHello.ServerNameIndicator;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this._mySession.requestBodyBytes = Encoding.UTF8.GetBytes("Request HTTPSParse failed: " + ex.Message);
                    }
IL_FF:
                    this.socketRemote.BeginSend(this.arrRequestBytes, 0, num, SocketFlags.None, new AsyncCallback(this.OnRemoteSent), this.socketRemote);
                }
                else
                {
                    FiddlerApplication.DoReadRequestBuffer(this._mySession, this.arrRequestBytes, 0);
                    this.CloseTunnel();
                }
            }
            catch (Exception)
            {
                this.CloseTunnel();
            }
        }
コード例 #3
0
ファイル: ClientChatter.cs プロジェクト: ploxolq/Unreal.FGO
        internal bool ReadRequest()
        {
            if (this.m_requestData != null)
            {
                FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called when requestData buffer already existed."));
                return(false);
            }
            if (this.pipeClient == null)
            {
                FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called after pipeClient was null'd."));
                return(false);
            }
            this.m_requestData = new PipeReadBuffer(true);
            this.m_session.SetBitFlag(SessionFlags.ClientPipeReused, this.pipeClient.iUseCount > 0u);
            this.pipeClient.IncrementUse(0);
            this.pipeClient.setReceiveTimeout();
            int  num   = 0;
            bool flag  = false;
            bool flag2 = false;

            byte[] array = new byte[ClientChatter._cbClientReadBuffer];
            while (true)
            {
                try
                {
                    num = this.pipeClient.Receive(array);
                    goto IL_1F1;
                }
                catch (Exception ex)
                {
                    if (CONFIG.bDebugSpew)
                    {
                        FiddlerApplication.DebugSpew(string.Format("ReadRequest {0} threw {1}", (this.pipeClient == null) ? "Null pipeClient" : this.pipeClient.ToString(), ex.Message));
                    }
                    flag = true;
                    goto IL_1F1;
                }
                goto IL_D2;
IL_1DE:
                if (flag2 || flag)
                {
                    goto IL_22F;
                }
                if (this.isRequestComplete())
                {
                    goto Block_17;
                }
                continue;
IL_D2:
                flag2 = true;
                FiddlerApplication.DoReadRequestBuffer(this.m_session, array, 0);
                if (CONFIG.bDebugSpew)
                {
                    FiddlerApplication.DebugSpew(string.Format("ReadRequest {0} returned {1}", (this.pipeClient == null) ? "Null pipeClient" : this.pipeClient.ToString(), num));
                    goto IL_1DE;
                }
                goto IL_1DE;
IL_1F1:
                if (num <= 0)
                {
                    goto IL_D2;
                }
                if (CONFIG.bDebugSpew)
                {
                    FiddlerApplication.DebugSpew(string.Format("READ FROM {0}:\n{1}", this.pipeClient, Utilities.ByteArrayToHexView(array, 32, num)));
                }
                if (!FiddlerApplication.DoReadRequestBuffer(this.m_session, array, num))
                {
                    flag = true;
                }
                if (0L == this.m_requestData.Length)
                {
                    this.m_session.Timers.ClientBeginRequest = DateTime.Now;
                    if (1u == this.pipeClient.iUseCount && num > 2)
                    {
                        if (array[0] == 5)
                        {
                            break;
                        }
                        if (array[0] == 5)
                        {
                            break;
                        }
                    }
                    int i;
                    for (i = 0; i < num; i++)
                    {
                        if (13 != array[i] && 10 != array[i])
                        {
                            break;
                        }
                    }
                    this.m_requestData.Write(array, i, num - i);
                    goto IL_1DE;
                }
                this.m_requestData.Write(array, 0, num);
                goto IL_1DE;
            }
            goto IL_1FD;
Block_17:
            goto IL_22F;
IL_1FD:
            FiddlerApplication.Log.LogFormat("It looks like someone is trying to send SOCKS traffic to us.\r\n{0}", new object[]
            {
                Utilities.ByteArrayToHexView(array, 16, Math.Min(num, 256))
            });
            return(false);

IL_22F:
            array = null;
            if (!flag)
            {
                if (this.m_requestData.Length != 0L)
                {
                    if (this.m_headers == null || this.m_session.state >= SessionStates.Done)
                    {
                        this._freeRequestData();
                        return(false);
                    }
                    if ("CONNECT" == this.m_headers.HTTPMethod)
                    {
                        this.m_session.isTunnel = true;
                        this.m_sHostFromURI     = this.m_session.PathAndQuery;
                    }
                    if (this.m_sHostFromURI != null)
                    {
                        if (this.m_headers.Exists("Host"))
                        {
                            if (!Utilities.areOriginsEquivalent(this.m_sHostFromURI, this.m_headers["Host"], this.m_session.isHTTPS ? 443 : (this.m_session.isFTP ? 21 : 80)) && (!this.m_session.isTunnel || !Utilities.areOriginsEquivalent(this.m_sHostFromURI, this.m_headers["Host"], 443)))
                            {
                                this.m_session.oFlags["X-Original-Host"] = this.m_headers["Host"];
                                this.m_session.oFlags["X-URI-Host"]      = this.m_sHostFromURI;
                                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.network.SetHostHeaderFromURL", true))
                                {
                                    this.m_headers["Host"] = this.m_sHostFromURI;
                                }
                            }
                        }
                        else
                        {
                            if ("HTTP/1.1".OICEquals(this.m_headers.HTTPVersion))
                            {
                                this.m_session.oFlags["X-Original-Host"] = string.Empty;
                            }
                            this.m_headers["Host"] = this.m_sHostFromURI;
                        }
                        this.m_sHostFromURI = null;
                    }
                    if (!this.m_headers.Exists("Host"))
                    {
                        this._freeRequestData();
                        return(false);
                    }
                    return(true);
                }
            }
            this._freeRequestData();
            if (this.pipeClient == null)
            {
                return(false);
            }
            if (this.pipeClient.iUseCount < 2u || (this.pipeClient.bIsSecured && this.pipeClient.iUseCount < 3u))
            {
                FiddlerApplication.Log.LogFormat("[Fiddler] No {0} request was received from ({1}) new client socket, port {2}.", new object[]
                {
                    this.pipeClient.bIsSecured ? "HTTPS" : "HTTP",
                    this.m_session.oFlags["X-ProcessInfo"],
                    this.m_session.oFlags["X-CLIENTPORT"]
                });
            }
            return(false);
        }