Commits

Fydon committed 0ce7e48 Draft

Attempt to improve performance by removing modular arithmetic in log entry check

  • Participants
  • Parent commits ec2d11b

Comments (0)

Files changed (1)

File CertificatePasswordRecovery/CertPasswordRecoveryForm.cs

         // Container for certificate data, so that the disk only needs to be read once
         byte[] certificateData = null;
 
+        // Iteration counter for logging only every certain number of iterations
+        long logIterationCount = 0;
+
         // X509 Certificate object used while trying to decrypt the keystore / certificate
         X509Certificate2 certificate;
 
             // Password found?
             bool password_found = false;
 
+            // Reset counter
+            logIterationCount = 0;
+
             // loop to find the password
             do
             {
         {
             try
             {
+                // Increment counter for minimal logging
+                ++this.logIterationCount;
+
                 certificate = new X509Certificate2(certificateData, CertificatePassword);
                 
                 // Only log successful crack to a file if the logging is NOT set to 0!
                     // Case 0 is handled in the "success" section. We just don't log anything when told not to!
                     case 2:
                         // Every 10,000 + Succcess
-                        if ((PasswordNumber % 10000) == 0 || PasswordNumber == 0)
+                        if( this.logIterationCount >= 10000 )
                         {
                             Log("Password Failed: " + CertificatePassword, LogFileLocation, PasswordNumber);
+                            this.logIterationCount = 0;
                         }
                         break;
                     case 3: