Beispiel #1
0
 private void txtInput_TextChanged(object sender, EventArgs e)
 {
     try
     {
         txtResult.Text = WPDUtil.Transform(txtInput.Text, TransformMethod == Method.Decode ? "D" : "E");
     }
     catch (Exception)
     { txtResult.Text = "Invalid Input!"; }
 }
Beispiel #2
0
        private async Task ResolveOfficialData()
        {
            using (var client = new HttpClient())
            {
                // clientTexts
                var cmd = new JObject();
                cmd["cmd"]        = "ClientTextMetaDatas";
                cmd["languageId"] = JToken.FromObject(LoginConfig.DefaultLanguageId);
                var clientTexts = await client.PostAsync("http://auth-useu.flyff-legacy.com/Api.ashx",
                                                         new StringContent(WPDUtil.Transform(cmd.ToString(), "E")))
                                  .Result.Content.ReadAsStringAsync();

                ClientTexts = new List <WPDClientTexts>();
                var clientTextsObj = JObject.Parse(clientTexts);
                var texts          = new WPDClientTexts();
                texts.DeserializeFromBase64String(WPDUtil.UnZipFromBase64(clientTextsObj["clientTexts"].ToObject <string>()));
                ClientTexts.Add(texts);

                // systemSettings
                var systemSettings = await client.PostAsync("http://auth-useu.flyff-legacy.com/Api.ashx",
                                                            new StringContent("iqj50z9l1no7FFb3DFDCptsx/V6fvA9IWAr0VTncFmssilWtIzfhMbj47ZPYgFUntCBb5rhQDw9Vm/YfciqWSQ=="))
                                     .Result.Content.ReadAsStringAsync();

                var systemSettingsObj = JObject.Parse(systemSettings);
                SystemSettings = systemSettingsObj["systemSettings"].ToObject <List <SystemSetting> >();

                // gameAssetBundles
                var assetBundles = await client.PostAsync("http://auth-useu.flyff-legacy.com/Api.ashx",
                                                          new StringContent("ASLSWps5IKooLJRL3iSyy90lZ/rU9GA2OAtMxIRPymA="))
                                   .Result.Content.ReadAsStringAsync();

                var assetBundlesObj = JObject.Parse(assetBundles);
                GameAssetBundles = assetBundlesObj["gameAssetBundles"].ToObject <List <GameAssetBundle> >();

                // imageResources
                var imageResources = await client.PostAsync("http://auth-useu.flyff-legacy.com/Api.ashx",
                                                            new StringContent("MsyFTWwwCoXatcd94okYZXz96tp5wnj4u7RfXjYUR9civXXRkEiJtJ7PrssWIN18"))
                                     .Result.Content.ReadAsStringAsync();

                var imageResourcesObj = JObject.Parse(imageResources);
                ImageResources = imageResourcesObj["imageResources"].ToObject <List <ImageResource> >();
            }
        }
Beispiel #3
0
        private async void GetContextCallback(IAsyncResult ar)
        {
            var listener = ar.AsyncState as HttpListener;

            try
            {
                var context = listener.EndGetContext(ar);

                var splitter = context.Request.RawUrl.Split('/');
                if (splitter[1] == "gate")
                {
                    using (var reader = new StreamReader(context.Request.InputStream))
                        using (var writer = new StreamWriter(context.Response.OutputStream))
                        {
                            var requestContent = reader.ReadToEnd();
                            var Command        = JObject.Parse(requestContent)["cmd"].ToObject <string>();
                            //Console.WriteLine($"Handling: {Command}");
                            requestContent = AppContext.Instance.HookManager.CallClientToGateHooks(Command, requestContent);
                            var genuineResponse = await GenuineClient.PostAsync(AppContext.Instance.Configuration.GenuineGateServerAddress, new StringContent(requestContent));

                            var genuineResponseContent = await genuineResponse.Content.ReadAsStringAsync();

                            genuineResponseContent = AppContext.Instance.HookManager.CallGateToClientHooks(Command, genuineResponseContent);
                            writer.Write(genuineResponseContent);
                        }
                }

                if (splitter[1] == "auth")
                {
                    using (var reader = new StreamReader(context.Request.InputStream))
                        using (var writer = new StreamWriter(context.Response.OutputStream))
                        {
                            var requestContent = reader.ReadToEnd();
                            requestContent = WPDUtil.Transform(requestContent, "D");
                            var Command = JObject.Parse(requestContent)["cmd"].ToObject <string>();
                            //Console.WriteLine($"Handling: {Command}");
                            var requestContentPatched = AppContext.Instance.HookManager.CallClientToAuthHooks(Command, requestContent);
                            requestContentPatched = WPDUtil.Transform(requestContentPatched, "E");
                            var genuineResponse = await GenuineClient.PostAsync(AppContext.Instance.Configuration.GenuineAuthServerAddress, new StringContent(requestContentPatched));

                            var genuineResponseContent = await genuineResponse.Content.ReadAsStringAsync();

                            if (EncryptedResponses.Any(r => r == Command))
                            {
                                var genuineResponseContentDecrypted = WPDUtil.Transform(genuineResponseContent, "D");
                                var genuineResponseContentPatched   = AppContext.Instance.HookManager.CallAuthToClientHooks(Command, genuineResponseContentDecrypted);
                                genuineResponseContent = WPDUtil.Transform(genuineResponseContentPatched, "E");
                            }
                            else
                            {
                                genuineResponseContent = AppContext.Instance.HookManager.CallAuthToClientHooks(Command, genuineResponseContent);
                            }

                            writer.Write(genuineResponseContent);
                        }
                }

                if (splitter[1] == "game")
                {
                    using (var reader = new StreamReader(context.Request.InputStream))
                        using (var writer = new StreamWriter(context.Response.OutputStream))
                        {
                            var requestContent = reader.ReadToEnd();
                            var Command        = JObject.Parse(requestContent)["cmd"].ToObject <string>();
                            //Console.WriteLine($"Handling: {Command}");
                            requestContent = AppContext.Instance.HookManager.CallClientToGameHooks(Command, requestContent);
                            var genuineResponse = await GenuineClient.PostAsync(AppContext.Instance.Configuration.GenuineGameServerAddress, new StringContent(requestContent));

                            var genuineResponseContent = await genuineResponse.Content.ReadAsStringAsync();

                            genuineResponseContent = AppContext.Instance.HookManager.CallGameToClientHooks(Command, genuineResponseContent);

                            writer.Write(genuineResponseContent);
                        }
                }

                listener.BeginGetContext(new AsyncCallback(GetContextCallback), listener);
            }
            catch (Exception ex) { Console.WriteLine(ex.ToString()); }
        }