private void H_DataToClient(object sender, DataToEventArgs e) { HSession HS = (HSession)sender; switch (e.Step) { case 1: { Program.Connections[HS].DoHandshake(e.Packet.ReadString(), e.Packet.ReadString()); HS.SendToServer(3739, Program.Connections[HS].PublicKey); break; } case 2: { byte[] SharedKey = Program.Connections[HS].GetSharedKey(e.Packet.ReadString()); HS.ClientEncrypt = new HRC4(SharedKey); HS.ServerDecrypt = new HRC4(SharedKey); HS.ReceiveData = false; HS.SendToServer(3709, 3937, HS.FlashClientURL, HS.GameData.Variables); HS.SendToServer(2828, HS.SSOTicket, -1); break; } } }
private void Handshake_ToServer(object sender, DataToEventArgs e) { try { switch (e.Step) { case 3: { _fakeServerKey = !string.IsNullOrWhiteSpace(BannerUrl) ? new byte[] { 1 } : _fakeServer.GetSharedKey(e.Packet.ReadString()); e.Packet = new HMessage(e.Packet.Header, HDestination.Server, HProtocol.Modern, _fakeClient.PublicKey); break; } case 4: { if (e.Packet.IsCorrupted) { Game.ClientEncrypt = new Rc4(_fakeClientKey); Game.ClientDecrypt = new Rc4(_fakeServerKey); Game.ClientDecrypt.Parse(e.Packet.ToBytes()); e.Packet = new HMessage(e.Packet.ToBytes(), HDestination.Server); } break; } } } catch { HandshakeFinished(); } Game_DataToServer(sender, e); }
protected virtual void OnDataToServer(DataToEventArgs e) { EventHandler <DataToEventArgs> handler = DataToServer; if (handler != null) { handler(this, e); } }
private void Game_DataToClient(object sender, DataToEventArgs e) { if (_packetloggerF.ViewIncoming) { _packetloggerF.PushToQueue(e.Packet); } _contractor.ProcessIncoming(e.Packet.ToBytes()); }
private void Game_DataToServer(object sender, DataToEventArgs e) { if (_packetloggerF.ViewOutgoing) { _packetloggerF.PushToQueue(e.Packet); } _contractor.ProcessOutgoing(e.Packet.ToBytes()); }
private void Handshake_ToClient(object sender, DataToEventArgs e) { try { switch (e.Step - _clientStepShift) { case 1: { try { _fakeClient.DoHandshake(e.Packet.ReadString(), e.Packet.ReadString()); } catch { if (!AttemptHandshake(e.Packet)) { HandshakeFinished(); } } if (string.IsNullOrWhiteSpace(BannerUrl)) { e.Packet = new HMessage(e.Packet.Header, HDestination.Client, HProtocol.Modern, _fakeServer.SignedPrime, _fakeServer.SignedGenerator); } break; } case 2: { if (e.Packet.Length == 2) { _clientStepShift++; break; } _fakeClientKey = _fakeClient.GetSharedKey(e.Packet.ReadString()); e.Packet = new HMessage(e.Packet.Header, HDestination.Client, HProtocol.Modern, (string.IsNullOrWhiteSpace(BannerUrl) ? _fakeServer.PublicKey : "1"), _tanjiConnect.IsOriginal); break; } case 3: { if (e.Packet.IsCorrupted) { Game.ServerDecrypt = new Rc4(_fakeClientKey); Game.ServerEncrypt = new Rc4(_fakeServerKey); Game.ServerDecrypt.Parse(e.Packet.ToBytes()); e.Packet = new HMessage(e.Packet.ToBytes(), HDestination.Client); } break; } default: HandshakeFinished(); break; } } catch { HandshakeFinished(); } Game_DataToClient(sender, e); }
private void Game_DataToClient(object sender, DataToEventArgs e) { try { switch (e.Step) { case 1: { _fakeClient.DoHandshake(e.Packet.ReadString(), e.Packet.ReadString(e.Packet.Position)); e.Replacement.ReplaceAt <string>(0, _fakeServer.SignedPrime); e.Replacement.ReplaceAt <string>(e.Packet.Position, _fakeServer.SignedGenerator); break; } case 2: { _fakeClientKey = _fakeClient.GetSharedKey(e.Packet.ReadString()); e.Replacement.Replace <string>(_fakeServer.PublicKey); break; } case 3: { if (e.Packet.IsCorrupted) { Game.IncomingDecrypt = new Rc4(_fakeClientKey); Game.IncomingEncrypt = new Rc4(_fakeServerKey); byte[] decrypted = Game.IncomingDecrypt.SafeParse(e.Packet.ToBytes()); e.Replacement = new HMessage(decrypted, HDestination.Client); } break; } } } catch { } finally { if (_packetlogger.ViewIncoming) { _packetlogger.PushToQueue(e); } _contractor.ProcessIncoming(e.Replacement.ToBytes()); } }
public void PushToQueue(DataToEventArgs e) { bool toServer = (e.Replacement.Destination == HDestination.Server); if (!ViewOutgoing && toServer || !ViewIncoming && !toServer || e.IsBlocked && !DisplayBlocked || e.IsReplaced && !DisplayReplaced) { return; } _dataQueue.Enqueue(e); if (!_queueRunning) { Task.Factory.StartNew(RunQueue); } }
private void RunQueue() { if (_queueRunning) { return; } _queueRunning = true; try { while (_dataQueue.Count > 0) { if (_dataQueue.Count == 0) { break; } DataToEventArgs data = _dataQueue.Dequeue(); if (data == null) { continue; } HMessage packet = data.Replacement; bool toServer = (packet.Destination == HDestination.Server); if (!ViewOutgoing && toServer || !ViewIncoming && !toServer || data.IsBlocked && !DisplayBlocked || data.IsReplaced && !DisplayReplaced) { return; } var arguments = new object[] { packet.IsCorrupted ? "Corrupted" : packet.Header.ToString(), packet.Length }; string info = string.Format(INFO_CHUNK_FORMAT, arguments); string log = string.Format(toServer ? OUTGOING_FORMAT : INCOMING_FORMAT, info, packet); while (!_loaded) { Thread.Sleep(100); } Invoke(new MethodInvoker(() => Display(log, data))); } } finally { _queueRunning = false; } }
private void Display(string message, DataToEventArgs e) { Color highlight = (e.Packet.Destination == HDestination.Client ? IncomingHighlight : OutgoingHighlight); if (e.IsBlocked) { WriteHighlight("Blocked | ", BlockHighlight); } else if (e.IsReplaced) { WriteHighlight("Replaced | ", ReplaceHighlight); } WriteHighlight(message + (DisplaySplitter ? "\n--------------------\n" : "\n"), highlight); LoggerTxt.SelectionStart = LoggerTxt.TextLength; LoggerTxt.ScrollToCaret(); Application.DoEvents(); }
private void Game_DataToServer(object sender, DataToEventArgs e) { try { switch (e.Step) { case 3: { _fakeServerKey = _fakeServer.GetSharedKey(e.Packet.ReadString()); e.Replacement.Replace <string>(_fakeClient.PublicKey); break; } case 4: { if (e.Packet.IsCorrupted) { Game.OutgoingEncrypt = new Rc4(_fakeClientKey); Game.OutgoingDecrypt = new Rc4(_fakeServerKey); byte[] decrypted = Game.OutgoingDecrypt.SafeParse(e.Packet.ToBytes()); e.Replacement = new HMessage(decrypted, HDestination.Server); } break; } } } catch { } finally { if (_packetlogger.ViewOutgoing) { _packetlogger.PushToQueue(e); } _contractor.ProcessOutgoing(e.Replacement.ToBytes()); } }