Skip to content

Commit dd8a48b

Browse files
committed
Did some oopsie with the parameters
1 parent 5c9e5b7 commit dd8a48b

File tree

5 files changed

+23
-38
lines changed

5 files changed

+23
-38
lines changed

CombinationGenerator/Generator.cs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public string Current
5252

5353
String CurrState = "";
5454
for (int i = 0; i < _Positions.Length; i++) CurrState += _Charset[_Positions[i]];
55+
System.Diagnostics.Debug.WriteLine("CombinationGenerator.Generator.Current: Returned String: " + CurrState);
5556
return CurrState;
5657
}
5758
}

README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ This program is a commandline-utility that needs four parameters:
99
2. \[Charset-String\]: String Containing the characters to use. Example: "0123456789" to test numerical passwords
1010
3. \[MIN LENGTH\]: The shortest combination to test. Example: "2"
1111
4. \[MAX LENGTH\]: The longest combination to test. Example: "8"
12+
5. {output}: Adding 'output' to the end of the command will display every password tried. This slows down execution!
1213

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

15-
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"
16+
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.
1617

17-
The programm will either tell you the password or inform you that no password has been found. Progress is not visualized.
18+
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.
1819

1920
# How it works
2021

21-
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).
22+
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.
2223
2. The program creates one copy of the ZIP-File for each thread in a temporary folder.
23-
3. The program starts the amount of Threads it wants to use (Shorter Combinations are tried before longer ones)
24-
4. When a thread finishes
25-
- A new thread is started if there are combinations left to try and no password has been found
26-
- All threads are cancelled if a password has been found
27-
- The program is done if the thread with the longest combination has finished
24+
3. The program starts the amount of Threads it wants to use.
25+
4. The program stops when a password is found or all combinations have been tried.
2826

ZipCrackNetCore/PasswordCheckStream.cs

-19
This file was deleted.

ZipCrackNetCore/Program.cs

+15-10
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ internal class Program
1717
private static Int32 MinLength = 0;
1818
private static Int32 MaxLength = 0;
1919
private static String ZipPath = "";
20+
private static Boolean OutputTries = false;
2021

2122
/// <summary>
2223
/// Main Function
2324
/// </summary>
24-
/// <param name="args">[PATH] [Charset-String] [MIN LENGHT] [MAX LENGTH]</param>
25+
/// <param name="args">[PATH] [Charset-String] [MIN LENGHT] [MAX LENGTH] {output}</param>
2526
static void Main(string[] args)
2627
{
27-
if(args.Length != 4) //All 4 Arguments are needed
28+
if(args.Length < 4 || args.Length > 5) //4 Arguments are needed, 'output' is optional
2829
{
2930
Console.WriteLine("Wrong use of arguments!");
30-
Console.WriteLine("[PATH] [Charset-String] [MIN LENGTH] [MAX LENGTH]");
31+
Console.WriteLine("[PATH] [Charset-String] [MIN LENGTH] [MAX LENGTH] {output}");
32+
Console.WriteLine("Adding 'output' to the end of the command will print all tries to the console. This will slow down the program!");
3133
Console.WriteLine("Example: C:\\bruh.zip ABCDEFGHIJKLMNOPQRSTUVWXYZ 5 8");
3234
return;
3335
}
@@ -81,6 +83,11 @@ static void Main(string[] args)
8183
Console.WriteLine("[MAX LENGTH] is not a valid number!");
8284
return;
8385
}
86+
try
87+
{
88+
if (args[4].Trim().ToLower() == "output") OutputTries = true;
89+
}
90+
catch { }
8491

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

114-
new Thread(() => GeneratorThread(MinLength, MaxLength, args[0])).Start();
121+
new Thread(() => GeneratorThread(MinLength, MaxLength, args[1])).Start();
115122

116123
for (int i = 0; i < ThreadCount; i++)
117124
{
@@ -161,21 +168,19 @@ private static void PasswordThread(String Filename)
161168
String PasswordToTry;
162169
if(Passwords.TryDequeue(out PasswordToTry))
163170
{
171+
if(OutputTries) Console.WriteLine(PasswordToTry);
164172
using (MemoryStream tmpms = new MemoryStream())
165173
{
166174
try
167175
{
168176
ToTestAgainst.ExtractWithPassword(tmpms, PasswordToTry);
169-
Console.WriteLine("Found Password: " + ToTestAgainst);
177+
Console.WriteLine("Found Password: " + PasswordToTry);
170178
CancellationToken.Cancel();
171179
Thread.Sleep(10);
172180
Passwords.Clear();
181+
Environment.Exit(0);
173182
}
174-
catch (Exception e)
175-
{
176-
System.Diagnostics.Debug.WriteLine(PasswordToTry);
177-
System.Diagnostics.Debug.WriteLine(e.Message);
178-
}
183+
catch { }
179184
}
180185
}
181186
else

ZipCrackNetCore/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"ZipCrackNetCore": {
44
"commandName": "Project",
5-
"commandLineArgs": "D:\\ZipCrack\\tocrack.zip gabverf57 9 10"
5+
"commandLineArgs": "D:\\ZipCrack\\tocrack.zip gvfre57 9 10 output"
66
}
77
}
88
}

0 commit comments

Comments
 (0)