private void Game_Connected(object sender, EventArgs e) { if (InvokeRequired) { Invoke(_onConnected, sender, e); return; } IsOriginal = SKore.IsOriginal(Main.Game.Host, Main.Game.Port); _main.HookGameEvents(); _setupFinished = true; Close(); }
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); } }