예제 #1
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));
        }
예제 #2
0
 private void TerminateProxy()
 {
     Eavesdropper.Terminate();
     Eavesdropper.RequestIntercepted  -= InjectGameClient;
     Eavesdropper.ResponseIntercepted -= InterceptClientPage;
     Eavesdropper.ResponseIntercepted -= InterceptGameClient;
 }
예제 #3
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));
        }
예제 #4
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();
            }
        }
예제 #5
0
        public void Connect()
        {
            Eavesdropper.ResponseIntercepted += ExtractGameData;
            Eavesdropper.Initiate(ProxyPort);

            SetStatus(TanjiState.ExtractingGameData);
        }
예제 #6
0
파일: ConnectFrm.cs 프로젝트: Zantil/Tanji
        private void DoAutomaticConnect()
        {
            Eavesdropper.EavesdropperResponse += ExtractHostPort;
            Eavesdropper.Initiate(8080);

            StatusTxt.SetDotAnimation("Extracting Host/Port");
        }
예제 #7
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);
                }
            }
        }
예제 #8
0
파일: App.xaml.cs 프로젝트: Nestor/Tanji-1
 private void UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (!e.Handled)
     {
         Display(e.Exception);
         Eavesdropper.Terminate();
     }
 }
예제 #9
0
 public void Halt()
 {
     Eavesdropper.Terminate();
     Eavesdropper.RequestIntercepted  -= InjectClient;
     Eavesdropper.ResponseIntercepted -= ReplaceClient;
     Eavesdropper.ResponseIntercepted -= ExtractGameData;
     Eavesdropper.ResponseIntercepted -= ReplaceResources;
 }
예제 #10
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();
            }
        }
예제 #11
0
        private void Connect_Click(object sender, EventArgs e)
        {
            ushort port;
            string host = GameHostTxt.Text.Trim();
            bool   portConversionSuccess = ushort.TryParse(GamePortTxt.Text.Trim(), out port);

            switch (TanjiMode)
            {
            case TanjiMode.Automatic:
            {
                StartAnimation("Extracting Host/Port");

                if (!string.IsNullOrWhiteSpace(host))
                {
                    _maskHost = host.ToLower();
                }
                if (portConversionSuccess)
                {
                    _maskPort = port;
                }

                Eavesdropper.Initiate(EavesdropperPort);
                break;
            }

            case TanjiMode.Manual:
            {
                if (string.IsNullOrWhiteSpace(host) || !portConversionSuccess)
                {
                    const string message = "You've specified invalid details into the connection input boxes, please correct these issues before you can continue.";
                    MessageBox.Show(message, Main.TanjiError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (UseCustomClient)
                {
                    Eavesdropper.Initiate(EavesdropperPort);
                }

                StartAnimation("Connecting% | Port: " + port);

                Main.Game            = new HConnection(host, port);
                Main.Game.Connected += Game_Connected;
                Main.Game.Connect(true);
                break;
            }
            }

            ProcessBtn.Text   = "Cancel";
            ProcessBtn.Click -= Connect_Click;
            ProcessBtn.Click += Cancel_Click;
        }
예제 #12
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);
        }
예제 #13
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();
            }
        }
예제 #14
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;
        }
예제 #15
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();
        }
예제 #16
0
파일: ConnectFrm.cs 프로젝트: Zantil/Tanji
        private void CreateTrustedRootCertificate()
        {
            while (!Eavesdropper.CreateTrustedRootCertificate())
            {
                var result = MessageBox.Show(
                    "Eavesdrop requires a self-signed certificate in the root store to intercep HTTPS traffic.\r\n\r\nWould you like to retry the process?",
                    "Tanji ~ Alert!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

                if (result == DialogResult.No)
                {
                    Environment.Exit(0);
                }
            }
            Eavesdropper.ExportTrustedRootCertificate("EavesdropRoot.cer");
        }
예제 #17
0
        private void Initialize()
        {
            Connection.DataOutgoing += HandleOutgoing;
            Connection.DataIncoming += HandleIncoming;

            Connection.Connected    += ConnectionOpened;
            Connection.Disconnected += ConnectionClosed;

            if (Eavesdropper.Certifier.CreateTrustedRootCertificate())
            {
                Eavesdropper.ResponseInterceptedAsync += InterceptClientPageAsync;

                Eavesdropper.Initiate(Constants.PROXY_PORT);
                _ui.SetStatusMessage(Constants.INTERCEPTING_CLIENT_PAGE);
            }
        }
예제 #18
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();
        }
예제 #19
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;
            }
        }
예제 #20
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();
        }
예제 #21
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());
            }
        }
예제 #22
0
        private void Connect(object obj)
        {
            if (App.Master.Connection.IsConnected)
            {
                if (MessageBox.Show("Are you sure you want to disconnect from the current session?", "Tanji - Alert!",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Asterisk) == MessageBoxResult.Yes)
                {
                    App.Master.Connection.Disconnect();
                }
                else
                {
                    return;
                }
            }

            if (!IsAutomaticServerExtraction && HotelServer == null)
            {
                MessageBoxResult result = MessageBox.Show("Hotel server endpoint must be provided; Would you like to attempt an automatic extraction of the endpoint instead?",
                                                          "Tanji - Alert!", MessageBoxButton.YesNo, MessageBoxImage.Asterisk);

                if (result == MessageBoxResult.Yes)
                {
                    IsAutomaticServerExtraction = true;
                }
                else
                {
                    return;
                }
            }

            if (Eavesdropper.Certifier.CreateTrustedRootCertificate())
            {
                Eavesdropper.ResponseIntercepted += InterceptClientPage;
                Eavesdropper.Initiate(ProxyPort);

                Status = INTERCEPTING_CLIENT_PAGE_DATA;
            }
        }
예제 #23
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;
            }
        }
예제 #24
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);
        }
예제 #25
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);
        }
예제 #26
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}", "...");
            }
        }
예제 #27
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);
            }
        }
예제 #28
0
파일: MainFrm.cs 프로젝트: makinit/Tanji
 private void MainFrm_Load(object sender, EventArgs e)
 {
     Eavesdropper.Terminate();
     ConnectionPg.CreateTrustedRootCertificate();
 }
예제 #29
0
파일: MainFrm.cs 프로젝트: MOD-/Tanji
 private void MainFrm_FormClosed(object sender, FormClosedEventArgs e)
 {
     Eavesdropper.Terminate();
 }
예제 #30
0
파일: MainFrm.cs 프로젝트: MOD-/Tanji
 private void MainFrm_Load(object sender, EventArgs e)
 {
     Eavesdropper.Terminate();
 }