Skip to content

Commit 7c8f37b

Browse files
committed
Fixed "no password found" scenario
1 parent 6dc5e46 commit 7c8f37b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

ZipCrackNetCore/Program.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,7 @@ private static void Zct_Finished(object sender, EventArgs e)
181181
Console.WriteLine("Password: " + zct.Password); //Print out the password
182182
Environment.Exit(0); //Exit the program
183183
}
184-
else if(LengthToAssign > MaxLength) //The specified maximum password length as been exceeded without a password being found
185-
{
186-
Console.WriteLine("No Password found");
187-
Environment.Exit(1);
188-
}
189-
else //Start a new Thread to try a longer password
184+
else if(LengthToAssign <= MaxLength) //Start a new Thread to try a longer password
190185
{
191186
CancellationTokenSource cts = new CancellationTokenSource();
192187
zct = new ZipCrackThread(Charset.ToArray(), LengthToAssign, zct.Filename, cts.Token);
@@ -195,6 +190,11 @@ private static void Zct_Finished(object sender, EventArgs e)
195190
t.Start();
196191
LengthToAssign++;
197192
}
193+
else if(zct.CharCount == MaxLength) //Longest combination has finished testing, program is done
194+
{
195+
Console.WriteLine("No password has been found.");
196+
Environment.Exit(1);
197+
}
198198
}
199199
}
200200
}

ZipCrackNetCore/ZipCrackThread.cs

+10
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public String Filename
5353
}
5454
}
5555
/// <summary>
56+
/// The Length of the Combination that is being tried
57+
/// </summary>
58+
public Int32 CharCount
59+
{
60+
get
61+
{
62+
return cl.StateStart.Length;
63+
}
64+
}
65+
/// <summary>
5666
/// Creates a new ZipCrackThread-Object
5767
/// </summary>
5868
/// <param name="charset">The charset to combine into passwords</param>

0 commit comments

Comments
 (0)