Пример #1
0
        private async void Connected(object sender, ConnectedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(_connected, sender, e);
                return;
            }

            HMessage remoteEndPointPkt = await Connection.Local.ReceivePacketAsync();

            e.HotelServer           = ConnectionPg.HotelServer = HotelEndPoint.Parse(remoteEndPointPkt.ReadString().Split('\0')[0], remoteEndPointPkt.ReadInteger());
            e.IsFakingPolicyRequest = (e.HotelServer.Hotel == HHotel.Unknown);
            e.HotelServerSource.SetResult(e.HotelServer);

            ConnectionPg.IsReceiving = true;
            Text    = $"Tanji ~ Connected[{e.HotelServer}]";
            TopMost = PacketLoggerUI.TopMost;

            PacketLoggerUI.RevisionTxt.Text = ("Revision: " + Game.Revision);

            PacketLoggerUI.Show();
            PacketLoggerUI.WindowState = FormWindowState.Normal;

            BringToFront();
        }
Пример #2
0
 public async Task Start()
 {
     _connection               = new HConnection();
     _connection.Connected    += OnConnect;
     _connection.DataIncoming += OnIncomingData;
     _connection.DataOutgoing += OnOutgoingData;
     await _connection.InterceptAsync(HotelEndPoint.Parse(_host, _port));
 }
Пример #3
0
        private void InjectGameClient(object sender, RequestInterceptedEventArgs e)
        {
            if (e.Request.RequestUri.Query.StartsWith("?Tanji-"))
            {
                Eavesdropper.RequestIntercepted -= InjectGameClient;

                Uri    remoteUrl  = e.Request.RequestUri;
                string clientPath = Path.GetFullPath($"Modified Clients/{remoteUrl.Host}/{remoteUrl.LocalPath}");
                if (!string.IsNullOrWhiteSpace(CustomClientPath))
                {
                    clientPath = CustomClientPath;
                }
#if !NO_CACHE
                if (!File.Exists(clientPath))
#else
                if (true)
#endif
                {
                    Status = INTERCEPTING_CLIENT;
                    Eavesdropper.ResponseIntercepted += InterceptGameClient;
                }
                else
                {
                    Status          = DISASSEMBLING_CLIENT;
                    App.Master.Game = new HGame(clientPath);
                    App.Master.Game.Disassemble();

                    if (App.Master.Game.IsPostShuffle)
                    {
                        Status = GENERATING_MESSAGE_HASHES;
                        App.Master.Game.GenerateMessageHashes();
                    }

                    if (App.Master.GameData.Hotel == HHotel.Unknown && IsAutomaticServerExtraction)
                    {
                        Tuple <string, int?> endPoint = App.Master.Game.ExtractEndPoint();
                        if (!string.IsNullOrWhiteSpace(endPoint.Item1) || endPoint.Item2 != null)
                        {
                            string host = (!string.IsNullOrWhiteSpace(endPoint.Item1) ?
                                           endPoint.Item1 : HotelServer.Host);

                            HotelServer = HotelEndPoint.Parse(host, endPoint.Item2 ?? HotelServer.Port);
                        }
                    }

                    Status = SYNCHRONIZING_GAME;
                    App.Master.Synchronize(App.Master.Game);

                    TerminateProxy();
                    InterceptConnection();
                    e.Request = WebRequest.Create(new Uri(clientPath));
                }
            }
        }
        private void ConnectionOpened(object sender, ConnectedEventArgs e)
        {
            HPacket endPointPkt = Connection.Local.ReceivePacketAsync().Result;

            e.HotelServer = HotelServer = HotelEndPoint.Parse(endPointPkt.ReadUTF8().Split('\0')[0], endPointPkt.ReadInt32());

            e.HotelServerSource.SetResult(HotelServer);

            _ui.SetStatusMessage(Constants.CONNECTED);

            Invoke((MethodInvoker) delegate
            {
                SearchBtn.Enabled = true;
                Resources.RenderButtonState(SearchBtn, SearchBtn.Enabled);
            });
        }
Пример #5
0
 public Task InterceptAsync(string host, int port)
 {
     return(InterceptAsync(HotelEndPoint.Parse(host, port)));
 }
Пример #6
0
        public virtual void OnConnected(HPacket packet)
        {
            HotelServer      = HotelEndPoint.Parse(packet.ReadUTF8(), packet.ReadInt32());
            ClientVersion    = packet.ReadUTF8();
            ClientIdentifier = packet.ReadUTF8();
            ClientType       = packet.ReadUTF8();
            try
            {
                MessagesInfoIncoming = new List <HMessage>();
                MessagesInfoOutgoing = new List <HMessage>();
                Out = new Outgoing(new List <HMessage>());
                In  = new Incoming(new List <HMessage>());
                int MessagesInfoLenght = packet.ReadInt32();
                foreach (var i in Enumerable.Range(0, MessagesInfoLenght))
                {
                    int    CurrentMessageID         = packet.ReadInt32();
                    string CurrentMessageHash       = packet.ReadUTF8();
                    string CurrentMessageName       = packet.ReadUTF8();
                    string CurrentMessageStructure  = packet.ReadUTF8();
                    bool   CurrentMessageIsOutgoing = packet.ReadBoolean();
                    string CurrentMessageSource     = packet.ReadUTF8();
                    if (string.IsNullOrWhiteSpace(CurrentMessageHash) || CurrentMessageHash == "NULL")
                    {
                        CurrentMessageHash = CurrentMessageName;
                    }
                    CurrentMessageHash = CurrentMessageSource + "_" + CurrentMessageHash;
                    HMessage CurrentHMessage = new HMessage((ushort)CurrentMessageID, CurrentMessageHash, CurrentMessageName, CurrentMessageStructure);
                    if (CurrentMessageIsOutgoing)
                    {
                        MessagesInfoOutgoing.Add(CurrentHMessage);
                    }
                    else
                    {
                        MessagesInfoIncoming.Add(CurrentHMessage);
                    }
                }
                List <HMessage> GeodeOut = new List <HMessage>();
                List <HMessage> GeodeIn  = new List <HMessage>();
                foreach (PropertyInfo GeodeOutProperty in Out.GetType().GetProperties())
                {
                    try
                    {
                        if (GeodeOutProperty.PropertyType == typeof(HMessage))
                        {
                            GeodeOut.Add(MessagesInfoOutgoing.First(x => x.Name == GeodeOutProperty.Name));
                        }
                    }
                    catch { Console.WriteLine("MessageInfo not found for: " + GeodeOutProperty.Name); }
                }
                foreach (PropertyInfo GeodeInProperty in In.GetType().GetProperties())
                {
                    try
                    {
                        if (GeodeInProperty.PropertyType == typeof(HMessage))
                        {
                            GeodeIn.Add(MessagesInfoIncoming.First(x => x.Name == GeodeInProperty.Name));
                        }
                    }
                    catch { Console.WriteLine("MessageInfo not found for: " + GeodeInProperty.Name); }
                }
                Out = new Outgoing(GeodeOut);
                In  = new Incoming(GeodeIn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Critical MessagesInfo exception: " + ex.Message);
                MessagesInfo_Failed = true;
            }

            IsConnected = true;
            if (DisableEventHandlers == false)
            {
                try { OnConnectedEvent.Invoke(this, packet); } catch { };//Invoke event handler
            }
        }
Пример #7
0
        private void InterceptGameClient(object sender, ResponseInterceptedEventArgs e)
        {
            if (!e.Response.ResponseUri.Query.StartsWith("?Tanji-"))
            {
                return;
            }
            if (e.Response.ContentType != "application/x-shockwave-flash")
            {
                return;
            }
            Eavesdropper.ResponseIntercepted -= InterceptGameClient;

            Uri    remoteUrl  = e.Response.ResponseUri;
            string clientPath = Path.GetFullPath($"Modified Clients/{remoteUrl.Host}/{remoteUrl.LocalPath}");

            string clientDirectory = Path.GetDirectoryName(clientPath);

            Directory.CreateDirectory(clientDirectory);

            Status                   = DISASSEMBLING_CLIENT;
            App.Master.Game          = new HGame(e.Payload);
            App.Master.Game.Location = clientPath;
            App.Master.Game.Disassemble();

            if (App.Master.Game.IsPostShuffle)
            {
                Status = GENERATING_MESSAGE_HASHES;
                App.Master.Game.GenerateMessageHashes();

                Status = MODIFYING_CLIENT;
                App.Master.Game.DisableHostChecks();
                App.Master.Game.InjectKeyShouter(4001);
            }

            if (App.Master.GameData.Hotel == HHotel.Unknown)
            {
                if (IsAutomaticServerExtraction)
                {
                    Tuple <string, int?> endPoint = App.Master.Game.ExtractEndPoint();
                    if (!string.IsNullOrWhiteSpace(endPoint.Item1) || endPoint.Item2 != null)
                    {
                        string host = (!string.IsNullOrWhiteSpace(endPoint.Item1) ?
                                       endPoint.Item1 : HotelServer.Host);

                        HotelServer = HotelEndPoint.Parse(host, endPoint.Item2 ?? HotelServer.Port);
                    }
                }

                Status = MODIFYING_CLIENT;
                App.Master.Game.InjectEndPoint("127.0.0.1", HotelServer.Port);
            }

            Status = SYNCHRONIZING_GAME;
            App.Master.Synchronize(App.Master.Game);

            CompressionKind compression = CompressionKind.ZLIB;

#if DEBUG
            compression = CompressionKind.None;
#endif

            Status    = ASSEMBLING_CLIENT;
            e.Payload = App.Master.Game.ToArray(compression);
            using (var clientStream = File.Open(clientPath, FileMode.Create, FileAccess.Write))
            {
                clientStream.Write(e.Payload, 0, e.Payload.Length);
            }

            TerminateProxy();
            InterceptConnection();
        }
Пример #8
0
 public async Task Start()
 {
     await Connection.InterceptAsync(HotelEndPoint.Parse(_host, _port));
 }