Skip to content

Commit

Permalink
Fixed "no password found" scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanluc162 committed Apr 26, 2020
1 parent 6dc5e46 commit 7c8f37b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ZipCrackNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,7 @@ private static void Zct_Finished(object sender, EventArgs e)
Console.WriteLine("Password: " + zct.Password); //Print out the password
Environment.Exit(0); //Exit the program
}
else if(LengthToAssign > MaxLength) //The specified maximum password length as been exceeded without a password being found
{
Console.WriteLine("No Password found");
Environment.Exit(1);
}
else //Start a new Thread to try a longer password
else if(LengthToAssign <= MaxLength) //Start a new Thread to try a longer password
{
CancellationTokenSource cts = new CancellationTokenSource();
zct = new ZipCrackThread(Charset.ToArray(), LengthToAssign, zct.Filename, cts.Token);
Expand All @@ -195,6 +190,11 @@ private static void Zct_Finished(object sender, EventArgs e)
t.Start();
LengthToAssign++;
}
else if(zct.CharCount == MaxLength) //Longest combination has finished testing, program is done
{
Console.WriteLine("No password has been found.");
Environment.Exit(1);
}
}
}
}
10 changes: 10 additions & 0 deletions ZipCrackNetCore/ZipCrackThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public String Filename
}
}
/// <summary>
/// The Length of the Combination that is being tried
/// </summary>
public Int32 CharCount
{
get
{
return cl.StateStart.Length;
}
}
/// <summary>
/// Creates a new ZipCrackThread-Object
/// </summary>
/// <param name="charset">The charset to combine into passwords</param>
Expand Down

0 comments on commit 7c8f37b

Please sign in to comment.