Ejemplo n.º 1
0
        static void InitializeTor()
        {
            try
            {
                Process[] previous = Process.GetProcessesByName("tor");

                if (previous != null && previous.Length > 0)
                {
                    foreach (Process process in previous)
                    {
                        process.Kill();
                    }
                }

                ClientCreateParams createParameters = new ClientCreateParams();
                createParameters.ConfigurationFile        = ConfigurationManager.AppSettings["torConfigurationFile"];
                createParameters.ControlPassword          = ConfigurationManager.AppSettings["torControlPassword"];
                createParameters.ControlPort              = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]);
                createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"];
                createParameters.Path = ConfigurationManager.AppSettings["torPath"];

                createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
                createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip"));
                createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6"));

                client = Client.Create(createParameters);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// initializes Tor browser connection
        /// </summary>
        public void InitializeTor()
        {
            _log.Called();

            try
            {
                Cef.GetGlobalCookieManager().DeleteCookies("", "");

                Process[] previous = Process.GetProcessesByName("tor");
                if (previous != null && previous.Length > 0)
                {
                    foreach (Process process in previous)
                    {
                        process.Kill();
                    }
                }

                ClientCreateParams createParams = new ClientCreateParams();
                createParams.ConfigurationFile        = "";
                createParams.DefaultConfigurationFile = "";
                createParams.ControlPassword          = "";
                createParams.ControlPort = 9051;
                createParams.Path        = @"Tor\Tor\tor.exe";
                createParams.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
                createParams.SetConfig(ConfigurationNames.GeoIPFile, System.IO.Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip"));
                createParams.SetConfig(ConfigurationNames.GeoIPv6File, System.IO.Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6"));

                Client client = Client.Create(createParams);
            }
            catch (Exception e)
            {
                _log.Error(e.Message);
            }
        }
        private void InitializeTor()
        {
            Process[] previous = Process.GetProcessesByName("tor");
            //tutaj zabij proces
            ClientCreateParams createParams = new ClientCreateParams();

            createParams.ConfigurationFile        = "";
            createParams.DefaultConfigurationFile = "";
            createParams.ControlPassword          = "";
            createParams.ControlPort = 9051;
            createParams.Path        = @"Tor\Tor\tor.exe";
            createParams.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
            createParams.SetConfig(ConfigurationNames.GeoIPFile, System.IO.Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip"));
            createParams.SetConfig(ConfigurationNames.GeoIPv6File, System.IO.Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6"));

            client = Client.Create(createParams);
        }
Ejemplo n.º 4
0
        public SiteDownloader(bool IsTor = true)
        {
            if (client == null && IsTor)
            {
                ClientCreateParams createParameters = new ClientCreateParams();
                createParameters.ConfigurationFile        = "";
                createParameters.ControlPassword          = "";
                createParameters.ControlPort              = CONTROL_PORT;
                createParameters.DefaultConfigurationFile = "";
                createParameters.Path = GetTorDirectory(PATH);

                createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
                createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip"));
                createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6"));

                client = Client.Create(createParameters);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes the tor client.
        /// </summary>
        private void InitializeTor()
        {
            Process[] previous = Process.GetProcessesByName("tor");

            SetStatusProgress(PROGRESS_INDETERMINATE);

            if (previous != null && previous.Length > 0)
            {
                SetStatusText("Killing previous tor instances..");

                foreach (Process process in previous)
                {
                    process.Kill();
                }
            }

            SetStatusText("Creating the tor client..");

            ClientCreateParams createParameters = new ClientCreateParams();

            createParameters.ConfigurationFile        = ConfigurationManager.AppSettings["torConfigurationFile"];
            createParameters.ControlPassword          = ConfigurationManager.AppSettings["torControlPassword"];
            createParameters.ControlPort              = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]);
            createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"];
            createParameters.Path = ConfigurationManager.AppSettings["torPath"];

            createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
            createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip"));
            createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6"));

            client = Client.Create(createParameters);

            if (!client.IsRunning)
            {
                SetStatusProgress(PROGRESS_DISABLED);
                SetStatusText("The tor client could not be created");
                return;
            }

            client.Status.BandwidthChanged       += OnClientBandwidthChanged;
            client.Status.CircuitsChanged        += OnClientCircuitsChanged;
            client.Status.ORConnectionsChanged   += OnClientConnectionsChanged;
            client.Status.StreamsChanged         += OnClientStreamsChanged;
            client.Configuration.PropertyChanged += (s, e) => { Invoke((Action) delegate { configGrid.Refresh(); }); };
            client.Shutdown += new EventHandler(OnClientShutdown);

            if (!Program.SetConnectionProxy(string.Format("127.0.0.1:{0}", client.Proxy.Port)))
            {
                MessageBox.Show("The application could not set the default connection proxy. The browser control is not using the tor service as a proxy!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SetStatusProgress(PROGRESS_DISABLED);
            SetStatusText("Ready");

            configGrid.SelectedObject = client.Configuration;

            SetStatusText("Downloading routers");
            SetStatusProgress(PROGRESS_INDETERMINATE);

            ThreadPool.QueueUserWorkItem(state =>
            {
                allRouters = client.Status.GetAllRouters();

                if (allRouters == null)
                {
                    SetStatusText("Could not download routers");
                    SetStatusProgress(PROGRESS_DISABLED);
                }
                else
                {
                    Invoke((Action) delegate
                    {
                        routerList.BeginUpdate();

                        foreach (Router router in allRouters)
                        {
                            routerList.Items.Add(string.Format("{0} [{1}] ({2}/s)", router.Nickname, router.IPAddress, router.Bandwidth));
                        }

                        routerList.EndUpdate();
                    });

                    SetStatusText("Ready");
                    SetStatusProgress(PROGRESS_DISABLED);
                }
            });
        }
Ejemplo n.º 6
0
        private void initializeTor()
        {
            Process[] previous = Process.GetProcessesByName("tor");

            SetStatusProgress(Constants.PROGRESS_INDETERMINATE);

            if (previous != null && previous.Length > 0)
            {
                SetStatusText("Killing previous tor instances..");

                foreach (Process process in previous)
                {
                    process.Kill();
                }
            }

            SetStatusText("Creating the tor client..");

            ClientCreateParams createParameters = new ClientCreateParams();

            createParameters.ConfigurationFile        = ConfigurationManager.AppSettings["torConfigurationFile"]; // Gets values from app.config
            createParameters.ControlPassword          = ConfigurationManager.AppSettings["torControlPassword"];
            createParameters.ControlPort              = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]);
            createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"];
            createParameters.Path = ConfigurationManager.AppSettings["torPath"];

            createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
            createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\geoip"));
            createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\geoip6"));

            client = Client.Create(createParameters);

            if (!client.IsRunning)
            {
                SetStatusProgress(Constants.PROGRESS_DISABLED);
                SetStatusText("The tor client could not be created");
                return;
            }

            client.Status.BandwidthChanged       += OnClientBandwidthChanged;
            client.Status.CircuitsChanged        += OnClientCircuitsChanged;
            client.Status.ORConnectionsChanged   += OnClientConnectionsChanged;
            client.Status.StreamsChanged         += OnClientStreamsChanged;
            client.Configuration.PropertyChanged += (s, e) => { Invoke((Action) delegate { configGrid.Refresh(); }); };
            client.Shutdown += new EventHandler(OnClientShutdown);

            SetStatusProgress(Constants.PROGRESS_DISABLED);
            SetStatusText("Ready");

            configGrid.SelectedObject = client.Configuration;

            SetStatusText("Downloading routers");
            SetStatusProgress(Constants.PROGRESS_INDETERMINATE);

            try
            {
                ThreadPool.QueueUserWorkItem(state =>
                {
                    allRouters = client.Status.GetAllRouters();

                    if (allRouters == null)
                    {
                        SetStatusText("Could not download routers");
                        SetStatusProgress(Constants.PROGRESS_DISABLED);
                    }
                    else
                    {
                        Invoke((Action) delegate
                        {
                            foreach (Router router in allRouters)
                            {
                                routerGridView.Rows.Add(router.Nickname, router.IPAddress, string.Format("{0}/s", router.Bandwidth));
                            }
                        });

                        SetStatusText("Ready");
                        SetStatusProgress(Constants.PROGRESS_DISABLED);
                        ShowTorReady();
                    }
                });
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }