Skip to content

Commit

Permalink
Did some oopsie with the parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanluc162 committed May 1, 2020
1 parent 5c9e5b7 commit dd8a48b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 38 deletions.
1 change: 1 addition & 0 deletions CombinationGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public string Current

String CurrState = "";
for (int i = 0; i < _Positions.Length; i++) CurrState += _Charset[_Positions[i]];
System.Diagnostics.Debug.WriteLine("CombinationGenerator.Generator.Current: Returned String: " + CurrState);
return CurrState;
}
}
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ This program is a commandline-utility that needs four parameters:
2. \[Charset-String\]: String Containing the characters to use. Example: "0123456789" to test numerical passwords
3. \[MIN LENGTH\]: The shortest combination to test. Example: "2"
4. \[MAX LENGTH\]: The longest combination to test. Example: "8"
5. {output}: Adding 'output' to the end of the command will display every password tried. This slows down execution!

The parameters have to be supplied in the same order as specified above!

Example usage: `dotnet ZipCrackNetCore.dll /home/myaccount/pron.zip abcdefghijklmnopqrstuvwxyz 5 8` would test passwords with 5 to 8 characters consisting of all lowercase letters against the file "pron.zip"
Example usage: `dotnet ZipCrackNetCore.dll /home/myaccount/pron.zip abcdefghijklmnopqrstuvwxyz 5 8 output` would test passwords with 5 to 8 characters consisting of all lowercase letters against the file "pron.zip" and print all the tries.

The programm will either tell you the password or inform you that no password has been found. Progress is not visualized.
The programm will either tell you the password or inform you that no password has been found. Progress is not visualized unless {output} is used.

# How it works

1. The program figures out how many Threads to use. By default, the amount is equal to the amount of logical cores available. If the amount of password lengths to test is smaller than the number of logical cores available, it is used instead (e.g. 8 Cores, Passwords with 5 to 8 characters -> 4 Threads).
1. The program figures out how many Threads to use. By default, the amount is equal to the amount of logical cores available times 1.5 plus one additional Thread for creating the combinations.
2. The program creates one copy of the ZIP-File for each thread in a temporary folder.
3. The program starts the amount of Threads it wants to use (Shorter Combinations are tried before longer ones)
4. When a thread finishes
- A new thread is started if there are combinations left to try and no password has been found
- All threads are cancelled if a password has been found
- The program is done if the thread with the longest combination has finished
3. The program starts the amount of Threads it wants to use.
4. The program stops when a password is found or all combinations have been tried.

19 changes: 0 additions & 19 deletions ZipCrackNetCore/PasswordCheckStream.cs

This file was deleted.

25 changes: 15 additions & 10 deletions ZipCrackNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ internal class Program
private static Int32 MinLength = 0;
private static Int32 MaxLength = 0;
private static String ZipPath = "";
private static Boolean OutputTries = false;

/// <summary>
/// Main Function
/// </summary>
/// <param name="args">[PATH] [Charset-String] [MIN LENGHT] [MAX LENGTH]</param>
/// <param name="args">[PATH] [Charset-String] [MIN LENGHT] [MAX LENGTH] {output}</param>
static void Main(string[] args)
{
if(args.Length != 4) //All 4 Arguments are needed
if(args.Length < 4 || args.Length > 5) //4 Arguments are needed, 'output' is optional
{
Console.WriteLine("Wrong use of arguments!");
Console.WriteLine("[PATH] [Charset-String] [MIN LENGTH] [MAX LENGTH]");
Console.WriteLine("[PATH] [Charset-String] [MIN LENGTH] [MAX LENGTH] {output}");
Console.WriteLine("Adding 'output' to the end of the command will print all tries to the console. This will slow down the program!");
Console.WriteLine("Example: C:\\bruh.zip ABCDEFGHIJKLMNOPQRSTUVWXYZ 5 8");
return;
}
Expand Down Expand Up @@ -81,6 +83,11 @@ static void Main(string[] args)
Console.WriteLine("[MAX LENGTH] is not a valid number!");
return;
}
try
{
if (args[4].Trim().ToLower() == "output") OutputTries = true;
}
catch { }

TempPath = Path.Combine(Path.GetTempPath(), "zipcracknetcore"); //Temporary Directory to use for the copied ZIPs
System.Diagnostics.Debug.WriteLine("Temp Path: " + TempPath);
Expand Down Expand Up @@ -111,7 +118,7 @@ static void Main(string[] args)
return;
}

new Thread(() => GeneratorThread(MinLength, MaxLength, args[0])).Start();
new Thread(() => GeneratorThread(MinLength, MaxLength, args[1])).Start();

for (int i = 0; i < ThreadCount; i++)
{
Expand Down Expand Up @@ -161,21 +168,19 @@ private static void PasswordThread(String Filename)
String PasswordToTry;
if(Passwords.TryDequeue(out PasswordToTry))
{
if(OutputTries) Console.WriteLine(PasswordToTry);
using (MemoryStream tmpms = new MemoryStream())
{
try
{
ToTestAgainst.ExtractWithPassword(tmpms, PasswordToTry);
Console.WriteLine("Found Password: " + ToTestAgainst);
Console.WriteLine("Found Password: " + PasswordToTry);
CancellationToken.Cancel();
Thread.Sleep(10);
Passwords.Clear();
Environment.Exit(0);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(PasswordToTry);
System.Diagnostics.Debug.WriteLine(e.Message);
}
catch { }
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion ZipCrackNetCore/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"ZipCrackNetCore": {
"commandName": "Project",
"commandLineArgs": "D:\\ZipCrack\\tocrack.zip gabverf57 9 10"
"commandLineArgs": "D:\\ZipCrack\\tocrack.zip gvfre57 9 10 output"
}
}
}

0 comments on commit dd8a48b

Please sign in to comment.