public virtual void OnMatchFound(object sender, MatchFoundEventArgs args)
 {
     if (MatchFound != null)
     {
         MatchFound(sender, args);
     }
 }
        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++;
                }
            }
        }
Beispiel #3
0
 private void OnMatchFound(object sender, MatchFoundEventArgs e)
 {
     this.Invoke(new MethodInvoker(delegate
     {
         crackList.Items.Add(e.Email + ":" + e.Password);
     }));
 }