Beispiel #1
0
        private void Eavesdropper_OnEavesResponse(object sender, EavesResponseEventArgs e)
        {
            if (UseCustomClient && e.IsSwf && e.ResponeData.Length > 3000000)
            {
                if (!_replaceKeys)
                {
                    e.ResponeData = _flash.ToBytes();
                }
                else
                {
                    _flash = new ShockwaveFlash(e.ResponeData);
                    ReplaceKeys(_flash);
                    e.ResponeData = _flash.ToBytes();

                    string clientPath = PatchedClientsDirectory + "\\" + FlashClientRevision + ".swf";
                    Task.Factory.StartNew(() => _flash.Save(clientPath, true));
                }
                Eavesdropper.Terminate();
                return;
            }
            else if (TanjiMode == TanjiMode.Manual)
            {
                return;
            }

            string response = _encoding.GetString(e.ResponeData);

            if (response.Contains(InfoHost) && response.Contains(InfoPort))
            {
                IsOriginal = SKore.IsOriginal(e.Host);

                string flashVars = response.GetChild("var flashvars", '}');
                while (!flashVars.Contains(InfoHost) || !flashVars.Contains(InfoPort))
                {
                    flashVars = flashVars.GetChild("var flashvars = {", '}');
                }

                string extractedHost = flashVars.GetChild(InfoHost, ',').Trim();
                string extractedPort = flashVars.GetChild(InfoPort, ',').Trim();

                #region Extract 'connection.info.host'
                if (string.IsNullOrEmpty(_maskHost))
                {
                    if (!extractedHost.StartsWith("\""))
                    {
                        PromptEavesdropperReset(HostExtractFail, Main.TanjiError, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        _maskHost = extractedHost.Split('"')[1];
                    }
                }
                #endregion
                #region Extract 'connection.info.port'
                if (_maskPort == 0)
                {
                    if (!extractedPort.StartsWith("\""))
                    {
                        PromptEavesdropperReset(PortExtractFail, Main.TanjiError, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        _maskPort = ushort.Parse(extractedPort.Split(',')[0].Split('"')[1]);
                    }
                }
                #endregion
                #region Extract 'hotelview.banner.url'
                if (!IsOriginal && response.Contains(HotelViewBannerUrl))
                {
                    Main.Cookies   = e.RawCookies;
                    Main.UserAgent = e.UserAgent;
                    Main.BannerUrl = response.GetChild(HotelViewBannerUrl, ',');
                    if (Main.BannerUrl.StartsWith("\""))
                    {
                        Main.BannerUrl = Main.BannerUrl.Split('"')[1] + "?token=";
                    }
                    if (Main.BannerUrl.StartsWith("//"))
                    {
                        Main.BannerUrl = "http://" + Main.BannerUrl;
                    }
                }
                #endregion

                if (!IsOriginal)
                {
                    response      = response.Replace(string.Format("{0}{1},", InfoHost, extractedHost), InfoHost + "\"127.0.0.1\",");
                    e.ResponeData = _encoding.GetBytes(response);
                }
                else if (!UseCustomClient)
                {
                    FlashClientRevision = ("http://" + response.GetChild(FlashClientUrl, ',').Split('"')[1].Substring(3)).Split('/')[4];
                    string patchedClientPath = PatchedClientsDirectory + "\\" + FlashClientRevision + ".swf";

                    if (!File.Exists(patchedClientPath))
                    {
                        UseCustomClient = _replaceKeys = true;
                    }
                    else
                    {
                        Invoke(new MethodInvoker(() => ProcessSwf(patchedClientPath)));
                    }
                }

                if (!UseCustomClient)
                {
                    Eavesdropper.Terminate();
                }
                SetAnimation("Connecting% | Port: " + _maskPort);

                Main.Game            = new HConnection(_maskHost, _maskPort);
                Main.Game.Connected += Game_Connected;
                Main.Game.Connect(IsOriginal);
            }
        }
Beispiel #2
0
        private byte[] ProcessResponse(byte[] payload, bool isFlash)
        {
            if (UseCustomClient && isFlash && payload.Length > 3000000)
            {
                if (!_replaceKeys)
                {
                    payload = _flash.ToBytes();
                }
                else
                {
                    _flash = new ShockwaveFlash(payload);

                    ReplaceRsaKeys(_flash);
                    payload = _flash.ToBytes();

                    string clientPath = Path.Combine("Patched Clients", GameData.FlashClientBuild + ".swf");
                    Task.Factory.StartNew(() => _flash.Save(clientPath, true));
                }

                FiddlerApplication.Shutdown();
                StatusTxt.BeginAnimation("Connecting{0} | Port: " + GameData.Port, "...");
                return(payload);
            }
            else if (TanjiMode.IsManual)
            {
                return(payload);
            }

            string response = Encoding.UTF8.GetString(payload);

            if (response.Contains("connection.info.host") && response.Contains("connection.info.port"))
            {
                GameData = HGameData.Parse(response);
                if (!UseCustomClient)
                {
                    string patchedClientPath = Path.Combine("Patched Clients", GameData.FlashClientBuild + ".swf");

                    if (!File.Exists(patchedClientPath))
                    {
                        UseCustomClient = _replaceKeys = true;
                    }
                    else
                    {
                        LoadGameClient(patchedClientPath);
                    }
                }

                if (!UseCustomClient)
                {
                    FiddlerApplication.Shutdown();
                    StatusTxt.BeginAnimation("Connecting{0} | Port: " + GameData.Port, "...");
                }
                else if (_replaceKeys)
                {
                    StatusTxt.BeginAnimation("Modifying Client{0}", "...");
                }
                else
                {
                    StatusTxt.BeginAnimation("Replacing Client{0}", "...");
                }

                _main.Game.Connect(true, GameData.Host, GameData.Port);

                response = response.Replace("/Habbo.swf", "/Habbo.swf?" + _numberGenerator.Next());
                payload  = Encoding.UTF8.GetBytes(response);
            }
            return(payload);
        }