private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Settings = LoadSettings(); if (args.Length > 0 && args[0].EndsWith(".swf")) { var clientInfo = new FileInfo(Path.GetFullPath(args[0])); using (var game = new HGame(clientInfo.FullName)) { game.Disassemble(); game.DisableHostChecks(); game.InjectKeyShouter(4001); game.InjectEndPointShouter(4000); game.InjectEndPoint("127.0.0.1", (int)Settings["ConnectionListenPort"]); string moddedClientPath = Path.Combine(clientInfo.DirectoryName, "MOD_" + clientInfo.Name); using (var fileOutput = File.Open(moddedClientPath, FileMode.Create)) using (var output = new FlashWriter(fileOutput)) { game.Assemble(output, CompressionKind.ZLIB); } MessageBox.Show($"File has been modified/re-assembled successfully at '{moddedClientPath}'.", "Tanji - Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } return; } Eavesdropper.Certifier = new CertificateManager("Tanji", "Tanji Certificate Authority"); Eavesdropper.Overrides.AddRange(((string)Settings["ProxyOverrides"]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); Application.Run(new MainFrm()); }
private static void PatchClient(FileInfo clientInfo) { using (var game = new HGame(clientInfo.FullName)) { game.Disassemble(); game.DisableHostChecks(); game.InjectKeyShouter(4001); game.InjectEndPointShouter(4000); game.InjectEndPoint("127.0.0.1", (int)Settings["ConnectionListenPort"]); string moddedClientPath = Path.Combine(clientInfo.DirectoryName, "MOD_" + clientInfo.Name); using (var fileOutput = File.Open(moddedClientPath, FileMode.Create)) using (var output = new FlashWriter(fileOutput)) { game.Assemble(output, CompressionKind.ZLIB); } MessageBox.Show($"File has been modified/re-assembled successfully at '{moddedClientPath}'.", "Tanji - Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private async Task InterceptGameClientAsync(object sender, ResponseInterceptedEventArgs e) { if (e.ContentType != "application/x-shockwave-flash") { return; } if (!e.Uri.Query.StartsWith("?" + _randomQuery)) { return; } Eavesdropper.ResponseInterceptedAsync -= InterceptGameClientAsync; string clientPath = Path.Combine(Master.DataDirectory.FullName, $@"Modified Clients\{e.Uri.Host}\{e.Uri.LocalPath}");; string clientDirectory = Path.GetDirectoryName(clientPath); Directory.CreateDirectory(clientDirectory); _ui.SetStatusMessage(Constants.DISASSEMBLING_CLIENT); using var game = new HGame(await e.Content.ReadAsStreamAsync().ConfigureAwait(false)) { Location = clientPath }; game.Disassemble(); _ui.SetStatusMessage(Constants.GENERATING_MESSAGE_HASHES); game.GenerateMessageHashes(Path.Combine(Master.ProgramDirectory.FullName, "Hashes.ini")); //We don't need this stuff in HabboGallery foreach (HMessage message in game.Out.Concat(game.In)) { message.Class = null; message.Parser = null; message.Structure = null; message.References.Clear(); } Master.In = game.In; Master.Out = game.Out; _ui.SetStatusMessage(Constants.MODIFYING_CLIENT); game.DisableHostChecks(); game.InjectKeyShouter(4001); game.InjectEndPointShouter(4000); game.InjectEndPoint("127.0.0.1", Connection.ListenPort); CompressionKind compression = CompressionKind.ZLIB; #if DEBUG compression = CompressionKind.None; #endif _ui.SetStatusMessage(Constants.ASSEMBLING_CLIENT); byte[] payload = game.ToArray(compression); e.Headers[HttpResponseHeader.ContentLength] = payload.Length.ToString(); e.Content = new ByteArrayContent(payload); using (FileStream clientStream = File.Open(clientPath, FileMode.Create, FileAccess.Write)) { clientStream.Write(payload); } TerminateProxy(); Task interceptConnectionTask = InterceptConnectionAsync(); }