示例#1
0
        private void DoAutomaticConnect()
        {
            Eavesdropper.EavesdropperResponse += ExtractHostPort;
            Eavesdropper.Initiate(8080);

            StatusTxt.SetDotAnimation("Extracting Host/Port");
        }
示例#2
0
        private async void ConnectFrm_Shown(object sender, EventArgs e)
        {
            BrowseBtn.Enabled      =
                ConnectBtn.Enabled = ModePnl.Enabled = false;
            StatusTxt.SetDotAnimation("Checking for updates");

            try
            {
                if (await MainUI.UpdateUI.CheckForUpdatesAsync())
                {
                    WindowState = FormWindowState.Minimized;
                    StatusTxt.StopDotAnimation("Update Found!");
                    MainUI.UpdateUI.ShowDialog();
                }
            }
            catch { /* Update check failed. */ }
            finally
            {
                BrowseBtn.Enabled      =
                    ConnectBtn.Enabled = ModePnl.Enabled = true;

                StatusTxt.StopDotAnimation("Standing By...");
                WindowState = FormWindowState.Normal;
            }
        }
示例#3
0
        private void ModifyAbc(DoABCTag abcTag)
        {
            CPoolInfo constants = abcTag.ABCData.ConstantPool;

            StatusTxt.SetDotAnimation("Squeezing ({0})", abcTag.Name);

            for (int i = 1; i < constants.Strings.Length; i++)
            {
                string constant = constants.Strings[i];
                if (constant.Length > 256 || constant.Length < 2)
                {
                    continue;
                }

                if (constant.Length > 2 && constant.Length < 6)
                {
                    ushort possiblePort = 0;
                    if (ushort.TryParse(constant, out possiblePort))
                    {
                        if (!_possiblePorts.Contains(possiblePort))
                        {
                            _possiblePorts.Add(possiblePort);
                        }

                        if (constant != "10001")
                        {
                            continue;
                        }
                    }
                }

                constants.Strings[i] =
                    ReplaceConstant(constant);
            }
        }
示例#4
0
 private void ResetInterface()
 {
     IsConnecting    = false;
     ConnectBtn.Text = "Connect";
     StatusTxt.StopDotAnimation("Standing By...");
     GameHostTxt.ReadOnly = GamePortTxt.ReadOnly = !ModePnl.IsManual;
     ModePnl.Enabled      = !(ExponentTxt.ReadOnly = ModulusTxt.ReadOnly = false);
 }
示例#5
0
        private async Task <bool> DoManualConnectAsync()
        {
            StatusTxt.SetDotAnimation("Intercepting Connection");

            await MainUI.Connection.ConnectAsync(
                GameHostTxt.Text, ushort.Parse(GamePortTxt.Text));

            return(MainUI.Connection.IsConnected);
        }
示例#6
0
        private void ResetSetup()
        {
            FiddlerApplication.Shutdown();

            ConnectBtn.Text      = "Connect";
            CustomClientTxt.Text = string.Empty;
            UseCustomClient      = _replaceKeys = false;

            StatusTxt.EndAnimation("Standing By...");
        }
示例#7
0
        private void DoConnectCleanup()
        {
            IsConnecting    = false;
            ConnectBtn.Text = "Connect";
            StatusTxt.StopDotAnimation("Standing By...");
            GameHostTxt.ReadOnly = GamePortTxt.ReadOnly = !ModePnl.IsManual;
            ModePnl.Enabled      = !(ExponentTxt.ReadOnly = ModulusTxt.ReadOnly = false);

            Eavesdropper.Terminate();
            HConnection.RestoreHosts();
            Eavesdropper.EavesdropperRequest  -= InjectClient;
            Eavesdropper.EavesdropperResponse -= ReplaceClient;
            Eavesdropper.EavesdropperResponse -= ExtractHostPort;
        }
示例#8
0
        private async Task <bool> VerifyGameClientAsync(ShockwaveFlash flash)
        {
            if (flash.IsCompressed)
            {
                StatusTxt.SetDotAnimation("Decompressing Client");
                bool decompressed = await flash.DecompressAsync()
                                    .ConfigureAwait(false);
            }

            if (!flash.IsCompressed)
            {
                MainUI.Game = flash;
            }

            return(MainUI.Game != null);
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Ftp ftpaccess = new Ftp(GlobalTools.GetexeLocation(), "simple.pnz", Ftp.dnsResolve("ftp.technosamurai.net"), "*****@*****.**", "public");

            StatusTxt.AppendText("Creating Missing Folders\n");
            Queue <string> fileNameList = ftpaccess.getFileListQueue();

            ftpaccess.ftpCred.filePath = GlobalTools.GetexeLocation();
            foreach (string fileName in fileNameList)
            {
                //if (GlobalTools.FileExist(GlobalTools.GetexeLocation() + fileName))
                //{
                ftpaccess.ftpCred.fileName = fileName;
                StatusTxt.AppendText("Getting " + fileName + "......");
                ftpaccess.getFileFtp();
                StatusTxt.AppendText("Finished\n");
                //}
            }
        }
示例#10
0
        private async void BrowseBtn_Click(object sender, EventArgs e)
        {
            ChooseClientDlg.FileName = ChooseClientDlg.SafeFileName;
            if (ChooseClientDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            bool verifySuccess = await VerifyGameClientAsync(
                ChooseClientDlg.FileName);

            StatusTxt.StopDotAnimation("Standing By...");
            if (!verifySuccess)
            {
                MessageBox.Show("Unable to disassemble the Shockwave Flash(.swf) file.",
                                "Tanji ~ Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            CustomClientTxt.Text = verifySuccess ?
                                   MainUI.Game.Location : string.Empty;
        }
示例#11
0
        private void ConnectBtn_Click(object sender, EventArgs e)
        {
            bool isCancelling = ConnectBtn.Text == "Cancel";

            ConnectBtn.Text = isCancelling ? "Connect" : "Cancel";

            if (isCancelling)
            {
                ResetSetup();
                _main.Game.Disconnect();
                return;
            }

            _main.Modulus  = ModulusTxt.Text;
            _main.Exponent = int.Parse(string.IsNullOrEmpty(ExponentTxt.Text)
                ? "0" : ExponentTxt.Text);

            int    gamePort           = 0;
            string gameHost           = GameHostTxt.Text.ToLower();
            bool   portConvertSuccess = int.TryParse(GamePortTxt.Text, out gamePort);

            if (TanjiMode.IsManual)
            {
                if (UseCustomClient)
                {
                    Eavesdropper.Initiate();
                }

                _main.Game.Connect(true, gameHost, gamePort);
                StatusTxt.BeginAnimation("Connecting{0} | Port: " + GamePortTxt.Text, "...");
            }
            else
            {
                FiddlerApplication.Startup(8081, FiddlerCoreStartupFlags.Default);
                StatusTxt.BeginAnimation("Extracting Host/Port{0}", "...");
            }
        }
示例#12
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);
            }
        }
示例#13
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);
            }
        }
示例#14
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);
        }