Beispiel #1
0
        private void EavesdropperResponse(object sender, EavesdropperResponseEventArgs e)
        {
            try
            {
                if (e.Response.ResponseUri.OriginalString.Contains(_bannerToken))
                {
                    using (var bannerStream = new MemoryStream(e.Payload))
                        _banner = new Bitmap(bannerStream);

                    Remote.Exchange.DoHandshake(_banner, _bannerToken);
                    Local.Exchange.Rsa.Padding = Remote.Exchange.Rsa.Padding;

                    Eavesdropper.Terminate();
                    Eavesdropper.EavesdropperResponse -= EavesdropperResponse;
                }
            }
            catch
            {
                MainUI.Connection.DataIncoming -= DataIncoming;
                MainUI.Connection.DataOutgoing -= DataOutgoing;
            }
        }
Beispiel #2
0
        private void EavesdropperResponse(object sender, EavesdropperResponseEventArgs e)
        {
            try
            {
                if (e.Response.ResponseUri.OriginalString.Contains(_bannerToken))
                {
                    using (var bannerStream = new MemoryStream(e.Payload))
                        _banner = new Bitmap(bannerStream);

                    Remote.Exchange.DoHandshake(_banner, _bannerToken);
                    Local.Exchange.Rsa.Padding = Remote.Exchange.Rsa.Padding;

                    Eavesdropper.Terminate();
                    Eavesdropper.EavesdropperResponse -= EavesdropperResponse;
                }
            }
            catch
            {
                MainUI.Connection.DataIncoming -= DataIncoming;
                MainUI.Connection.DataOutgoing -= DataOutgoing;
            }
        }
Beispiel #3
0
        private void ExtractHostPort(object sender, EavesdropperResponseEventArgs e)
        {
            string responseBody = Encoding.UTF8.GetString(e.Payload);
            if (MainUI.GameData == null && responseBody.Contains("info.host"))
            {
                MainUI.GameData = new HGameData(responseBody);
                MainUI.ExtensionMngr.Hotel = SKore.ToHotel(MainUI.GameData.Host);
                MainUI.IsRetro = (MainUI.ExtensionMngr.Hotel == HHotel.Unknown);

                if (MainUI.IsRetro)
                {
                    responseBody = responseBody
                        .Replace(MainUI.GameData.Host, "127.0.0.1");

                    if (!string.IsNullOrWhiteSpace(MainUI.GameData.ClientStarting))
                    {
                        responseBody = responseBody
                            .Replace(MainUI.GameData.ClientStarting, "Peeling Tangerines...");
                    }
                }

                if (!MainUI.IsRetro && MainUI.Game == null)
                    TryLoadModdedClientAsync().Wait();

                StatusTxt.SetDotAnimation((MainUI.Game == null ?
                    "Intercepting" : "Replacing") + " Client");

                responseBody = responseBody.Replace(".swf?", ".swf")
                    .Replace(".swf", ".swf?" + DateTime.Now.Ticks);

                Eavesdropper.EavesdropperResponse -= ExtractHostPort;
                Eavesdropper.EavesdropperResponse += ReplaceClient;

                e.Payload = Encoding.UTF8.GetBytes(responseBody);
            }
        }
Beispiel #4
0
        private void ReplaceClient(object sender, EavesdropperResponseEventArgs e)
        {
            if (e.Payload.Length > 3000000 &&
                e.Response.ContentType == "application/x-shockwave-flash")
            {
                if (MainUI.Game == null)
                {
                    bool verifySuccess = VerifyGameClientAsync(
                        new ShockwaveFlash(e.Payload)).Result;

                    if (verifySuccess)
                    {
                        StatusTxt.SetDotAnimation("Extracting Tags");
                        var flashTags = MainUI.Game.ExtractTags();

                        IEnumerable<FlashTag> viTags = null;
                        if (MainUI.IsRetro) viTags = flashTags.OfType<DoABCTag>();
                        else viTags = flashTags.OfType<DefineBinaryDataTag>();

                        SearchFlashTags(viTags);

                        StatusTxt.SetDotAnimation("Rebuilding Client");
                        MainUI.Game.Rebuild();
                    }

                    if (!MainUI.IsRetro)
                    {
                        MainUI.Game.Save(Path.Combine("Modified Clients",
                            MainUI.GameData.FlashClientBuild + ".swf"));
                    }
                }

                e.Payload = MainUI.Game.Data;
                Eavesdropper.EavesdropperResponse -= ReplaceClient;
                Eavesdropper.Terminate();

                Task connectTask = MainUI.Connection
                    .ConnectAsync(MainUI.GameData.Host, MainUI.GameData.Port);

                StatusTxt.SetDotAnimation("Intercepting Connection({0})", MainUI.GameData.Port);
            }
        }
Beispiel #5
0
        private void EavesdropperResponse(object sender, EavesdropperResponseEventArgs e)
        {
            if (e.Response.ContentType == "application/x-shockwave-flash" && e.Payload.Length > 3000000)
            {
                if (Main.Game == null)
                {
                    bool verifySuccess = VerifyGameClientAsync(
                        new ShockwaveFlash(e.Payload)).Result;

                    if (verifySuccess)
                    {
                        StatusTxt.SetDotAnimation("Extracting Tags");
                        var binaryDataTags = Main.Game.ExtractTags()
                            .OfType<DefineBinaryDataTag>();

                        ReplaceRsaKeys(binaryDataTags);
                        e.Payload = Main.Game.Rebuild();
                    }
                    Main.Game.Save("Modified Clients\\" + Main.GameData.FlashClientBuild + ".swf");
                }
                else e.Payload = Main.Game.Data;

                Eavesdropper.Terminate();
                StatusTxt.SetDotAnimation("Intercepting Connection");

                Main.Connection.ConnectAsync(Main.GameData.Host, Main.GameData.Port)
                    .ContinueWith(t => Close(), _uiContext);
            }
            else
            {
                string responseBody = Encoding.UTF8.GetString(e.Payload);
                if (responseBody.Contains("connection.info.host"))
                {
                    Main.GameData = new HGameData(responseBody);
                    Main.Contractor.Hotel = SKore.ToHotel(Main.GameData.Host);
                    Main.IsRetro = (Main.Contractor.Hotel == HHotel.Unknown);

                    if (Main.Game == null && !Main.IsRetro)
                        TryLoadModdedClientAsync().Wait();

                    if (Main.Game == null && Main.IsRetro)
                    {
                        Eavesdropper.Terminate();
                        StatusTxt.SetDotAnimation("Intercepting Connection");

                        Main.Connection.ConnectAsync(Main.GameData.Host, Main.GameData.Port)
                            .ContinueWith(t => Close(), _uiContext);
                    }
                    else
                    {
                        StatusTxt.SetDotAnimation((Main.GameData == null ?
                            "Intercepting" : "Replacing") + " Client");
                    }

                    responseBody = responseBody.Replace(".swf", ".swf?" + DateTime.Now.Millisecond);
                    e.Payload = Encoding.UTF8.GetBytes(responseBody);
                }
            }
        }
Beispiel #6
0
        private void ExtractHostPort(object sender, EavesdropperResponseEventArgs e)
        {
            string responseBody = Encoding.UTF8.GetString(e.Payload);
            if (MainUI.GameData == null && responseBody.Contains("info.host"))
            {
                MainUI.GameData = new HGameData(responseBody);
                MainUI.ExtensionMngr.GameData = MainUI.GameData;
                MainUI.ExtensionMngr.Hotel = SKore.ToHotel(MainUI.GameData.Host);
                MainUI.IsRetro = (MainUI.ExtensionMngr.Hotel == HHotel.Unknown);

                if (MainUI.IsRetro)
                {
                    if (!string.IsNullOrWhiteSpace(MainUI.GameData.MovieUrl) &&
                        !string.IsNullOrWhiteSpace(MainUI.GameData.BaseUrl))
                    {
                        IsClientSourceReadable = true;
                        MainUI.GameData.MovieUrl += "?" + DateTime.Now.Ticks;
                        MainUI.GameData["tanji.connection.info.host"] = "127.0.0.1";
                        MainUI.GameData["tanji.client.starting"] = "Peeling Tangerines...";
                    }
                    else
                    {
                        if (responseBody.Contains("embedSWF("))
                        {
                            string child = responseBody.GetChild("embedSWF(", ',');
                            responseBody = responseBody.Replace(child, child + $"+\"?{DateTime.Now.Ticks}\"");
                        }

                        MainUI.GameData["tanji.connection.info.host"] = "127.0.0.1";
                        responseBody = responseBody.Replace(MainUI.GameData.Host, MainUI.GameData.Host +
                            "\", \"tanji.connection.info.host\":\"127.0.0.1");
                    }
                }

                if (!MainUI.IsRetro && MainUI.Game == null)
                    TryLoadModdedClientAsync().Wait();

                StatusTxt.SetDotAnimation((MainUI.Game == null ?
                    "Intercepting" : "Injecting") + " Client");

                if (!MainUI.IsRetro)
                {
                    responseBody = responseBody.Replace(".swf?", ".swf")
                        .Replace(".swf", ".swf?DoInject" + DateTime.Now.Ticks);

                    if (MainUI.Game != null)
                        Eavesdropper.EavesdropperRequest += InjectClient;
                }

                Eavesdropper.EavesdropperResponse -= ExtractHostPort;
                Eavesdropper.EavesdropperResponse += ReplaceClient;

                e.Payload = Encoding.UTF8.GetBytes(
                    MainUI.IsRetro && IsClientSourceReadable ?
                    MainUI.GameData.ToString() : responseBody);
            }
        }
Beispiel #7
0
        private void ReplaceClient(object sender, EavesdropperResponseEventArgs e)
        {
            bool isLocal = false;
            if (e.Payload.Length > 3000000 &&
                e.Response.ContentType == "application/x-shockwave-flash" ||
                (isLocal = File.Exists(e.Response.ResponseUri.LocalPath)))
            {
                string[] ports = MainUI.GameData.Port.Split(',');
                if (MainUI.Game == null)
                {
                    bool verifySuccess = VerifyGameClientAsync(
                        new ShockwaveFlash(e.Payload)).Result;

                    if (verifySuccess)
                    {
                        StatusTxt.SetDotAnimation("Extracting Tags");
                        var flashTags = MainUI.Game.ExtractTags();

                        IEnumerable<FlashTag> tags = null;
                        if (MainUI.IsRetro)
                        {
                            tags = flashTags.OfType<DoABCTag>();
                            foreach (string port in ports)
                            {
                                ushort possiblePort = 0;
                                if (ushort.TryParse(port, out possiblePort) &&
                                    !_possiblePorts.Contains(possiblePort))
                                {
                                    _possiblePorts.Add(possiblePort);
                                }
                            }
                        }
                        else tags = flashTags.OfType<DefineBinaryDataTag>();

                        ModifyTags(tags);
                        StatusTxt.SetDotAnimation("Rebuilding Client");
                        MainUI.Game.Rebuild();
                    }

                    if (!MainUI.IsRetro)
                    {
                        MainUI.Game.Save(Path.Combine("Modified Clients",
                            MainUI.GameData.MovieName + ".swf"));
                    }
                }

                if (!isLocal)
                    e.Payload = MainUI.Game.Data;

                MainUI.GameData.Port = ports[0];

                if (!MainUI.IsRetro)
                    _possiblePorts.Add(ushort.Parse(MainUI.GameData.Port));

                Eavesdropper.EavesdropperResponse -= ReplaceClient;
                Eavesdropper.Terminate();

                Task connectTask = MainUI.Connection
                    .ConnectAsync(MainUI.GameData.Host, _possiblePorts.ToArray());

                StatusTxt.SetDotAnimation(
                    "Intercepting Connection({0})", MainUI.GameData.Port);
            }
        }
Beispiel #8
0
        private void ExtractHostPort(object sender, EavesdropperResponseEventArgs e)
        {
            string responseBody = Encoding.UTF8.GetString(e.Payload);

            if (MainUI.GameData == null && responseBody.Contains("info.host"))
            {
                MainUI.GameData = new HGameData(responseBody);
                MainUI.ExtensionMngr.GameData = MainUI.GameData;
                MainUI.ExtensionMngr.Hotel    = SKore.ToHotel(MainUI.GameData.Host);
                MainUI.IsRetro = (MainUI.ExtensionMngr.Hotel == HHotel.Unknown);

                if (MainUI.IsRetro)
                {
                    if (!string.IsNullOrWhiteSpace(MainUI.GameData.MovieUrl) &&
                        !string.IsNullOrWhiteSpace(MainUI.GameData.BaseUrl))
                    {
                        IsClientSourceReadable    = true;
                        MainUI.GameData.MovieUrl += "?" + DateTime.Now.Ticks;
                        MainUI.GameData["tanji.connection.info.host"] = "127.0.0.1";
                        MainUI.GameData["tanji.client.starting"]      = "Peeling Tangerines...";
                    }
                    else
                    {
                        if (responseBody.Contains("embedSWF("))
                        {
                            string child = responseBody.GetChild("embedSWF(", ',');
                            responseBody = responseBody.Replace(child, child + $"+\"?{DateTime.Now.Ticks}\"");
                        }

                        MainUI.GameData["tanji.connection.info.host"] = "127.0.0.1";
                        responseBody = responseBody.Replace(MainUI.GameData.Host, MainUI.GameData.Host +
                                                            "\", \"tanji.connection.info.host\":\"127.0.0.1");
                    }
                }

                if (!MainUI.IsRetro && MainUI.Game == null)
                {
                    TryLoadModdedClientAsync().Wait();
                }

                StatusTxt.SetDotAnimation((MainUI.Game == null ?
                                           "Intercepting" : "Injecting") + " Client");

                if (!MainUI.IsRetro)
                {
                    responseBody = responseBody.Replace(".swf?", ".swf")
                                   .Replace(".swf", ".swf?DoInject" + DateTime.Now.Ticks);

                    if (MainUI.Game != null)
                    {
                        Eavesdropper.EavesdropperRequest += InjectClient;
                    }
                }

                Eavesdropper.EavesdropperResponse -= ExtractHostPort;
                Eavesdropper.EavesdropperResponse += ReplaceClient;

                e.Payload = Encoding.UTF8.GetBytes(
                    MainUI.IsRetro && IsClientSourceReadable ?
                    MainUI.GameData.ToString() : responseBody);
            }
        }
Beispiel #9
0
        private void ReplaceClient(object sender, EavesdropperResponseEventArgs e)
        {
            bool isLocal = false;

            if (e.Payload.Length > 3000000 &&
                e.Response.ContentType == "application/x-shockwave-flash" ||
                (isLocal = File.Exists(e.Response.ResponseUri.LocalPath)))
            {
                string[] ports = MainUI.GameData.Port.Split(',');
                if (MainUI.Game == null)
                {
                    bool verifySuccess = VerifyGameClientAsync(
                        new ShockwaveFlash(e.Payload)).Result;

                    if (verifySuccess)
                    {
                        StatusTxt.SetDotAnimation("Extracting Tags");
                        var flashTags = MainUI.Game.ExtractTags();

                        IEnumerable <FlashTag> tags = null;
                        if (MainUI.IsRetro)
                        {
                            tags = flashTags.OfType <DoABCTag>();
                            foreach (string port in ports)
                            {
                                ushort possiblePort = 0;
                                if (ushort.TryParse(port, out possiblePort) &&
                                    !_possiblePorts.Contains(possiblePort))
                                {
                                    _possiblePorts.Add(possiblePort);
                                }
                            }
                        }
                        else
                        {
                            tags = flashTags.OfType <DefineBinaryDataTag>();
                        }

                        ModifyTags(tags);
                        StatusTxt.SetDotAnimation("Rebuilding Client");
                        MainUI.Game.Rebuild();
                    }

                    if (!MainUI.IsRetro)
                    {
                        MainUI.Game.Save(Path.Combine("Modified Clients",
                                                      MainUI.GameData.MovieName + ".swf"));
                    }
                }

                if (!isLocal)
                {
                    e.Payload = MainUI.Game.Data;
                }

                MainUI.GameData.Port = ports[0];

                if (!MainUI.IsRetro)
                {
                    _possiblePorts.Add(ushort.Parse(MainUI.GameData.Port));
                }

                Eavesdropper.EavesdropperResponse -= ReplaceClient;
                Eavesdropper.Terminate();

                Task connectTask = MainUI.Connection
                                   .ConnectAsync(MainUI.GameData.Host, _possiblePorts.ToArray());

                StatusTxt.SetDotAnimation(
                    "Intercepting Connection({0})", MainUI.GameData.Port);
            }
        }
Beispiel #10
0
        private void Eavesdropper_EavesdropperResponse(EavesdropperResponseEventArgs e)
        {
            bool isFlash = e.Response.ContentType == "application/x-shockwave-flash";

            e.Payload = ProcessResponse(e.Payload, isFlash);
        }