public Contractor(IHConnection connection, HGameData gameData) { _connection = connection; _extensions = new List <IExtension>(); Extensions = new ReadOnlyCollection <IExtension>(_extensions); _extensionsRunning = new List <IExtension>(); ExtensionsRunning = new ReadOnlyCollection <IExtension>(_extensionsRunning); GameData = gameData; if (connection != null && !string.IsNullOrEmpty(connection.Host)) { Hotel = SKore.ToHotel(connection.Host); } }
public static IEnumerable <HSession> Extract(string path, char delimiter = ':') { var accounts = new List <HSession>(); using (var streamReader = new StreamReader(path)) { while (!streamReader.EndOfStream) { string line = streamReader.ReadLine(); if (line.Contains(delimiter)) { string[] credentials = line.Split(delimiter); if (credentials.Count(x => !string.IsNullOrEmpty(x)) != 3) { break; } accounts.Add(new HSession(credentials[0], credentials[1], SKore.ToHotel(credentials[2]))); continue; } if (line.Contains('@') && !streamReader.EndOfStream) { string email = line; string password = streamReader.ReadLine(); if (!streamReader.EndOfStream) { HHotel hotel = SKore.ToHotel((streamReader.ReadLine()).GetChild(" / ")); accounts.Add(new HSession(email, password, hotel)); } else { return(accounts.ToArray()); } } } } return(accounts); }
private void ExtractGameData(object sender, ResponseInterceptedEventArgs e) { if (e.Response.ContentType != "text/html") { return; } if (GameData != null) { return; } string responseBody = Encoding.UTF8.GetString(e.Payload); if (responseBody.Contains("swfobject.embedSWF") && responseBody.Contains("connection.info.host")) { Eavesdropper.ResponseIntercepted -= ExtractGameData; try { GameData = new HGameData(responseBody); Hotel = SKore.ToHotel(GameData.InfoHost); var clientUri = new Uri(GameData["flash.client.url"]); string clientPath = clientUri.Segments[2].TrimEnd('/'); Task <bool> gameClientVerifierTask = VerifyGameClientAsync($"{_modifiedClientsDir.FullName}\\{clientPath}\\Habbo.swf"); if (e.Response.ResponseUri.Segments.Length > 2) { // TODO: Set uniqueId somewhere. //GameData.UniqueId = // e.Response.ResponseUri.Segments[2].TrimEnd('/'); } string embeddedSwf = responseBody.GetChild("embedSWF(", ','); string nonCachedSwf = $"{embeddedSwf} + \"?{DateTime.Now.Ticks}-Tanji\""; responseBody = responseBody.Replace( "embedSWF(" + embeddedSwf, "embedSWF(" + nonCachedSwf); e.Payload = Encoding.UTF8.GetBytes(responseBody); var resourceKeys = ResourceReplacements.Keys.ToArray(); foreach (string resourceKey in resourceKeys) { string realValue = GameData[resourceKey] .Replace("\\/", "/"); string fakeValue = ResourceReplacements[resourceKey]; ResourceReplacements.Remove(resourceKey); ResourceReplacements[realValue] = fakeValue; } if (gameClientVerifierTask.Result) { SetStatus(TanjiState.InjectingClient); Eavesdropper.RequestIntercepted += InjectClient; } else { SetStatus(TanjiState.InterceptingClient); Eavesdropper.ResponseIntercepted += ReplaceClient; } } catch (Exception ex) { WriteLog(ex); } finally { if (GameData == null) { Eavesdropper.ResponseIntercepted += ExtractGameData; } } } }
private void ExtractGameData(object sender, ResponseInterceptedEventArgs e) { if (e.Response.ContentType != "text/html") { return; } if (State != TanjiState.ExtractingGameData) { return; } string responseBody = Encoding.UTF8.GetString(e.Payload); if (responseBody.Contains("swfobject.embedSWF") && responseBody.Contains("connection.info.host")) { byte[] replacementData = e.Payload; Eavesdropper.ResponseIntercepted -= ExtractGameData; try { UI.GameData.Update(responseBody); UI.Hotel = SKore.ToHotel(UI.GameData.InfoHost); UI.ModulesPg.ModifyGameData(UI.GameData); responseBody = UI.GameData.Source; var clientUri = new Uri(UI.GameData["flash.client.url"]); string clientPath = clientUri.Segments[2].TrimEnd('/'); Task <bool> verifyGameClientTask = null; if (!string.IsNullOrWhiteSpace(CustomClientPath)) { verifyGameClientTask = VerifyGameClientAsync(CustomClientPath); } if (verifyGameClientTask == null || !verifyGameClientTask.Result) { verifyGameClientTask = VerifyGameClientAsync($"{_modifiedClientsDir.FullName}\\{clientPath}\\Habbo.swf"); } string embeddedSwf = responseBody.GetChild("embedSWF(", ','); string nonCachedSwf = $"{embeddedSwf} + \"?{DateTime.Now.Ticks}-Tanji\""; responseBody = responseBody.Replace( "embedSWF(" + embeddedSwf, "embedSWF(" + nonCachedSwf); responseBody = responseBody.Replace(UI.GameData.InfoHost, "127.0.0.1"); replacementData = Encoding.UTF8.GetBytes(responseBody); string[] resourceKeys = ResourceReplacements.Keys.ToArray(); foreach (string resourceKey in resourceKeys) { string realValue = UI.GameData[resourceKey] .Replace("\\/", "/"); string fakeValue = ResourceReplacements[resourceKey]; ResourceReplacements.Remove(resourceKey); ResourceReplacements[realValue] = fakeValue; } if (verifyGameClientTask.Result) { SetState(TanjiState.InjectingClient); Eavesdropper.RequestIntercepted += InjectClient; } else { SetState(TanjiState.InterceptingClient); Eavesdropper.ResponseIntercepted += ReplaceClient; } } catch (Exception ex) { MessageBox.Show("Intercepted game data is not recognized as coming from a valid Habbo Hotel site.", "Tanji ~ Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); WriteLog(ex); } finally { if (State == TanjiState.ExtractingGameData) { Eavesdropper.ResponseIntercepted += ExtractGameData; } else { e.Payload = replacementData; } } } }
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); } }