예제 #1
0
파일: Program.cs 프로젝트: Simonvdh/Tanji
        private static void Main()
        {
            var windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (!windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                using (var tanjiProcess = new Process())
                {
                    tanjiProcess.StartInfo.Verb            = "runas";
                    tanjiProcess.StartInfo.FileName        = "Tanji.exe";
                    tanjiProcess.StartInfo.UseShellExecute = true;
                    tanjiProcess.Start();
                }
            }
            else
            {
                AppDomain.CurrentDomain.UnhandledException +=
                    UnhandledException;

                Eavesdropper.Terminate();
                HConnection.RestoreHosts();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainFrm());

                Eavesdropper.Terminate();
                HConnection.RestoreHosts();
            }
        }
예제 #2
0
 private void TerminateProxy()
 {
     Eavesdropper.Terminate();
     Eavesdropper.RequestIntercepted  -= InjectGameClient;
     Eavesdropper.ResponseIntercepted -= InterceptClientPage;
     Eavesdropper.ResponseIntercepted -= InterceptGameClient;
 }
예제 #3
0
파일: Program.cs 프로젝트: scottstamp/Tanji
        static void Main(string[] args)
        {
            Eavesdropper.Terminate();

            var windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (!windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                MessageBox.Show(MUST_RUN_AS_ADMIN, "Tanji ~ Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool debugging = false;

            foreach (string command in args)
            {
                switch (command.Split(' ')[0])
                {
                case "/debug": debugging = true; break;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main(debugging));
        }
예제 #4
0
        static void Main(string[] args)
        {
            Eavesdropper.Terminate();

            #region Run As Administrator Check
            WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            if (!windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                const string MustRunAsAdmin = "Tanji must be ran with administrative privileges; If you are not being prompted to run as admin, make sure your UAC settings are properly adjusted.";
                MessageBox.Show(MustRunAsAdmin, Tanji.Main.TanjiError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endregion

            bool debugging = false;
            foreach (string command in args)
            {
                switch (command)
                {
                case "/debug": debugging = true; break;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main(debugging));
        }
예제 #5
0
파일: ConnectFrm.cs 프로젝트: Zantil/Tanji
        private void ConnectFrm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                if (IsReplacingClient)
                {
                    Eavesdropper.EavesdropperResponse -= ReplaceClient;
                }

                if (IsExtracingHostPort)
                {
                    Eavesdropper.EavesdropperResponse -= ExtractHostPort;
                }

                ResetInterface();
                Eavesdropper.Terminate();
                HConnection.RestoreHosts();
            }
            finally
            {
                if (!MainUI.Connection.IsConnected)
                {
                    Environment.Exit(0);
                }
            }
        }
예제 #6
0
파일: App.xaml.cs 프로젝트: Nestor/Tanji-1
 private void UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (!e.Handled)
     {
         Display(e.Exception);
         Eavesdropper.Terminate();
     }
 }
예제 #7
0
 public void Halt()
 {
     Eavesdropper.Terminate();
     Eavesdropper.RequestIntercepted  -= InjectClient;
     Eavesdropper.ResponseIntercepted -= ReplaceClient;
     Eavesdropper.ResponseIntercepted -= ExtractGameData;
     Eavesdropper.ResponseIntercepted -= ReplaceResources;
 }
예제 #8
0
        private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = (Exception)e.ExceptionObject;

            MessageBox.Show($"Message: {exception.Message}\r\n\r\n{exception.StackTrace.Trim()}",
                            "Tanji ~ Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

            if (e.IsTerminating)
            {
                Eavesdropper.Terminate();
            }
        }
예제 #9
0
        private void Run()
        {
            Eavesdropper.RequestInterceptedAsync  += RequestInterceptedAsync;
            Eavesdropper.ResponseInterceptedAsync += ResponseInterceptedAsync;
            Eavesdropper.Certifier.CreateTrustedRootCertificate();

            Eavesdropper.Initiate(8282);
            Console.Title = $"Eavesdrop.Sandbox({8282}) - Press any key to exit...";

            Console.ReadLine();
            Eavesdropper.Terminate();
            Console.WriteLine("Eavesdropper has been terminated! | " + DateTime.Now);
        }
예제 #10
0
        public static void Main(string[] args)
        {
            if (Eavesdropper.Certifier.CreateTrustedRootCertificate())
            {
                Eavesdropper.RequestInterceptedAsync  += Eavesdropper_RequestInterceptedAsync;
                Eavesdropper.ResponseInterceptedAsync += Eavesdropper_ResponseInterceptedAsync;

                Eavesdropper.Initiate(8686, Interceptors.Default);
                Console.WriteLine("Press any key to terminate the application at any time...");
            }

            Console.ReadKey();
            Eavesdropper.Terminate();
        }
예제 #11
0
파일: Program.cs 프로젝트: Warafux/Tanji
        private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = (Exception)e.ExceptionObject;

            string title   = ("Tanji - " + (e.IsTerminating ? "Critical Error!" : "Error!"));
            string message = $"Message: {exception.Message}\r\n\r\n{exception.StackTrace.Trim()}";

            MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);

            if (e.IsTerminating)
            {
                Eavesdropper.Terminate();
            }
        }
예제 #12
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;
        }
예제 #13
0
        private void TanjiConnect_FormClosing(object sender, FormClosingEventArgs e)
        {
            SaveSettings();
            if (!_setupFinished)
            {
                Eavesdropper.Terminate();

                if (Main.Game != null)
                {
                    Main.Game.Dispose();
                }

                Environment.Exit(0);
            }
            ResetSetup();
        }
예제 #14
0
        private void ResetSetup()
        {
            Eavesdropper.Terminate();

            _maskPort      = 0;
            _replaceKeys   = false;
            _setupFinished = false;
            _maskHost      = string.Empty;

            StopAnimation("Standing By...");
            if (ProcessBtn.Text == "Cancel")
            {
                ProcessBtn.Text   = "Connect";
                ProcessBtn.Click -= Cancel_Click;
                ProcessBtn.Click += Connect_Click;
            }
        }
예제 #15
0
        public Program()
        {
            Eavesdropper.Terminate();
            Eavesdropper.Certifier = new CertificateManager("HabboGallery", "HabboGallery Root Certificate");

            DataDirectory    = CreateDataDirectory();
            ProgramDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            _configPath = Path.Combine(DataDirectory.FullName, "config.json");

            Resources     = new HGResources();
            Configuration = HGConfiguration.Create(_configPath);

            Api = new ApiClient(new Uri(Constants.BASE_URL));

            GameData   = new HGameData();
            Connection = new HConnection();
        }
예제 #16
0
        static void Main()
        {
            Eavesdropper.Terminate();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (!windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                MessageBox.Show("Tanji must be ran with administrative privileges.",
                                "Tanji ~ Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                HConnection.RestoreHosts();
                Application.Run(new MainFrm());
            }
        }
예제 #17
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;
            }
        }
예제 #18
0
파일: Program.cs 프로젝트: xnumad/Tanji
        private static int Main(string[] args)
        {
            using (var identity = WindowsIdentity.GetCurrent())
            {
                HasAdminPrivilages = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator);
            }

            Settings = LoadSettings();
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            if (args.Length > 0)
            {
                switch (args[0].Substring(args[0].Length - 3))
                {
                case "dcs": DestroyCertificates(); break;

                case "ica": InstallCertificateAuthority(); break;

                case "ems": return((int)EnsureManualWinHttpAutoProxySvcStartup());

                case "swf": PatchClient(new FileInfo(Path.GetFullPath(args[0]))); break;
                }
                return(0);
            }

            IsParentProcess = true;
            if (EnsureManualWinHttpAutoProxySvcStartup() == ServiceControllerStatus.Running)
            {
                Eavesdropper.Certifier = new CertificateManager("Tanji", "Tanji Certificate Authority");
                Eavesdropper.Overrides.AddRange(((string)Settings["ProxyOverrides"]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                Eavesdropper.Terminate();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainFrm());
            }
            return(1);
        }
예제 #19
0
        public Program()
        {
            _haltables     = new List <IHaltable>();
            _receivers     = new SortedList <int, IReceiver>();
            _hotkeyActions = new Dictionary <Keys, Action>();

            GameData = new HGameData();

            Connection               = new HConnection();
            Connection.Connected    += Connected;
            Connection.DataOutgoing += HandleData;
            Connection.DataIncoming += HandleData;
            Connection.Disconnected += Disconnected;

            Hook = new KeyboardHook();
            Hook.HotkeyPressed += HotkeyPressed;

            Config = new TConfiguration();

            Eavesdropper.Terminate();
            Eavesdropper.Certifier = new CertificateManager("Tanji", "Tanji Certificate Authority");
            Eavesdropper.Overrides.AddRange(Config.ProxyOverrides);
        }
예제 #20
0
        private async Task CheckForUpdatesAsync()
        {
            Version?newVersion = await Api.GetLatestVersionAsync().ConfigureAwait(false);

            if (newVersion > Version)
            {
                var result = MessageBox.Show(Constants.UPDATE_FOUND_BODY, Constants.UPDATE_FOUND_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (result == DialogResult.Yes)
                {
                    Eavesdropper.Terminate();
                    Process.Start(new ProcessStartInfo(Constants.BASE_URL + "/download")
                    {
                        UseShellExecute = true
                    });

                    Environment.Exit(0);
                }
            }
            else
            {
                _ui.SetStatusMessage(Constants.UP_TO_DATE_MESSAGE);
            }
        }
예제 #21
0
        private void Eavesdropper_OnEavesResponse(object sender, EavesResponseEventArgs e)
        {
            if (UseCustomClient && e.IsSwf && e.ResponeData.Length > 3000000)
            {
                if (!_replaceKeys)
                {
                    e.ResponeData = _flash.ToBytes();
                }
                else
                {
                    _flash = new ShockwaveFlash(e.ResponeData);
                    ReplaceKeys(_flash);
                    e.ResponeData = _flash.ToBytes();

                    string clientPath = PatchedClientsDirectory + "\\" + FlashClientRevision + ".swf";
                    Task.Factory.StartNew(() => _flash.Save(clientPath, true));
                }
                Eavesdropper.Terminate();
                return;
            }
            else if (TanjiMode == TanjiMode.Manual)
            {
                return;
            }

            string response = _encoding.GetString(e.ResponeData);

            if (response.Contains(InfoHost) && response.Contains(InfoPort))
            {
                IsOriginal = SKore.IsOriginal(e.Host);

                string flashVars = response.GetChild("var flashvars", '}');
                while (!flashVars.Contains(InfoHost) || !flashVars.Contains(InfoPort))
                {
                    flashVars = flashVars.GetChild("var flashvars = {", '}');
                }

                string extractedHost = flashVars.GetChild(InfoHost, ',').Trim();
                string extractedPort = flashVars.GetChild(InfoPort, ',').Trim();

                #region Extract 'connection.info.host'
                if (string.IsNullOrEmpty(_maskHost))
                {
                    if (!extractedHost.StartsWith("\""))
                    {
                        PromptEavesdropperReset(HostExtractFail, Main.TanjiError, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        _maskHost = extractedHost.Split('"')[1];
                    }
                }
                #endregion
                #region Extract 'connection.info.port'
                if (_maskPort == 0)
                {
                    if (!extractedPort.StartsWith("\""))
                    {
                        PromptEavesdropperReset(PortExtractFail, Main.TanjiError, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        _maskPort = ushort.Parse(extractedPort.Split(',')[0].Split('"')[1]);
                    }
                }
                #endregion
                #region Extract 'hotelview.banner.url'
                if (!IsOriginal && response.Contains(HotelViewBannerUrl))
                {
                    Main.Cookies   = e.RawCookies;
                    Main.UserAgent = e.UserAgent;
                    Main.BannerUrl = response.GetChild(HotelViewBannerUrl, ',');
                    if (Main.BannerUrl.StartsWith("\""))
                    {
                        Main.BannerUrl = Main.BannerUrl.Split('"')[1] + "?token=";
                    }
                    if (Main.BannerUrl.StartsWith("//"))
                    {
                        Main.BannerUrl = "http://" + Main.BannerUrl;
                    }
                }
                #endregion

                if (!IsOriginal)
                {
                    response      = response.Replace(string.Format("{0}{1},", InfoHost, extractedHost), InfoHost + "\"127.0.0.1\",");
                    e.ResponeData = _encoding.GetBytes(response);
                }
                else if (!UseCustomClient)
                {
                    FlashClientRevision = ("http://" + response.GetChild(FlashClientUrl, ',').Split('"')[1].Substring(3)).Split('/')[4];
                    string patchedClientPath = PatchedClientsDirectory + "\\" + FlashClientRevision + ".swf";

                    if (!File.Exists(patchedClientPath))
                    {
                        UseCustomClient = _replaceKeys = true;
                    }
                    else
                    {
                        Invoke(new MethodInvoker(() => ProcessSwf(patchedClientPath)));
                    }
                }

                if (!UseCustomClient)
                {
                    Eavesdropper.Terminate();
                }
                SetAnimation("Connecting% | Port: " + _maskPort);

                Main.Game            = new HConnection(_maskHost, _maskPort);
                Main.Game.Connected += Game_Connected;
                Main.Game.Connect(IsOriginal);
            }
        }
예제 #22
0
파일: ConnectFrm.cs 프로젝트: Zantil/Tanji
        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);
            }
        }
예제 #23
0
파일: ConnectFrm.cs 프로젝트: Zantil/Tanji
 private void DoCancelConnect()
 {
     ResetInterface();
     Eavesdropper.Terminate();
     MainUI.Connection.Disconnect();
 }
예제 #24
0
        private void DataOutgoing(object sender, InterceptedEventArgs e)
        {
            try
            {
                switch (e.Step)
                {
                case 2:
                {
                    if (e.Packet.Length > 6)
                    {
                        MainUI.Connection.DataIncoming -= DataIncoming;
                        MainUI.Connection.DataOutgoing -= DataOutgoing;
                        break;
                    }
                    break;
                }

                case 3:
                {
                    if (!string.IsNullOrWhiteSpace(_bannerToken))
                    {
                        if (_banner == null)
                        {
                            MainUI.Connection.DataIncoming -= DataIncoming;
                            MainUI.Connection.DataOutgoing -= DataOutgoing;

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

                            return;
                        }
                        else
                        {
                            _localKey = new byte[] { 1 }
                        };
                    }
                    else
                    {
                        _localKey = Local.Exchange.GetSharedKey(e.Packet.ReadString());
                    }

                    Remote.Exchange.Rsa.Padding = Local.Exchange.Rsa.Padding;
                    e.Replacement.Replace <string>(0, Remote.Exchange.GetPublicKey());
                    break;
                }

                case 4:
                {
                    if (Local.IsDecryptionRequired)
                    {
                        Remote.Encrypter = new Rc4(_remoteKey);
                    }

                    MainUI.Connection.DataOutgoing -= DataOutgoing;
                    break;
                }
                }
            }
            catch
            {
                MainUI.Connection.DataIncoming -= DataIncoming;
                MainUI.Connection.DataOutgoing -= DataOutgoing;
            }
            finally { e.IsBlocked = false; }
        }
예제 #25
0
파일: MainFrm.cs 프로젝트: makinit/Tanji
 private void MainFrm_Load(object sender, EventArgs e)
 {
     Eavesdropper.Terminate();
     ConnectionPg.CreateTrustedRootCertificate();
 }
예제 #26
0
파일: MainFrm.cs 프로젝트: MOD-/Tanji
 private void MainFrm_Load(object sender, EventArgs e)
 {
     Eavesdropper.Terminate();
 }
예제 #27
0
파일: MainFrm.cs 프로젝트: MOD-/Tanji
 private void MainFrm_FormClosed(object sender, FormClosedEventArgs e)
 {
     Eavesdropper.Terminate();
 }