Пример #1
0
 public virtual void OnProgression(object sender, ProgressionEventArgs args)
 {
     if (Progression != null)
     {
         Progression(sender, args);
     }
 }
Пример #2
0
        private void AuthWorkload(object sender, DoWorkEventArgs e)
        {
            if (sender.GetType().Equals(typeof(BackgroundWorker)))
            {
                int WorkloadIndex = Workers.IndexOf(((BackgroundWorker)sender));
                int WorkloadDivisor = Emails.Count / Workers.Count;
                int WorkloadMin = (WorkloadIndex * WorkloadDivisor);
                int WorkloadMax = WorkloadIndex < Workers.Count - 1 ? WorkloadMin + WorkloadDivisor : Emails.Count - 1;
                long PreviousTime = 0;
                int TrialsPerSecond = 0;
                int Trials = 0;

                Console.WriteLine("Worker {0} will work on ranges [{1}, {2}].", WorkloadIndex, WorkloadMin, WorkloadMax);

                for (int i = WorkloadMin; i <= WorkloadMax; i++)
                {
                    foreach (String password in Passwords)
                    {

                        if (Workers[WorkloadIndex].CancellationPending)
                            return;

                        if (TryCredentials(Emails[i], password))
                        {
                            MatchFoundEventArgs args = new MatchFoundEventArgs();
                            args.Email = Emails[i];
                            args.Password = password;
                            OnMatchFound(this, args);
                        }

                        Trials++;

                        if (AuthTimer.ElapsedMilliseconds - PreviousTime > 1000)
                        {
                            TrialsPerSecond = Trials;
                            Trials = 0;
                            PreviousTime = AuthTimer.ElapsedMilliseconds;
                        }

                        ProgressionEventArgs pargs = new ProgressionEventArgs();
                        pargs.CurrentEmail = Emails[i];
                        pargs.CurrentPassword = password;
                        pargs.WorkerID = WorkloadIndex;
                        pargs.WorkerLoadMinimum = WorkloadMin;
                        pargs.WorkerLoadMaximum = WorkloadMax;
                        pargs.TrialsPerSecond = TrialsPerSecond;
                        OnProgression(Workers[WorkloadIndex], pargs);

                        TotalPasswordsTried++;
                    }
                    TotalEmailsTried++;
                }
            }
        }
Пример #3
0
 private void OnProgression(object sender, ProgressionEventArgs e)
 {
     Console.WriteLine("{0}% ({1} / {2})", ((double)Auth.TotalEmailsTried / (double)Auth.Emails.Count) * 100, (double)Auth.TotalEmailsTried, (double)Auth.Emails.Count);
     this.Invoke(new MethodInvoker(delegate
     {
         progress.Value = (int)(((double)Auth.TotalEmailsTried / (double)Auth.Emails.Count) * 100.0);
     }));
 }