Skip to content

Commit 779aa1f

Browse files
committed
Merge branch 'dev' for release 1.2.3
2 parents 3c1bb65 + e458c20 commit 779aa1f

File tree

10 files changed

+55
-57
lines changed

10 files changed

+55
-57
lines changed

Cargo.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "worgen_x"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
edition = "2021"
55
authors = ["Xen0rInspire"]
66
license = "GNU General Public License v3.0"
@@ -15,17 +15,17 @@ cli = ["serde_json", "clap"]
1515
gui = []
1616

1717
[dependencies]
18-
rand = { version = "0.8.5", features = ["getrandom"], default-features = false }
19-
thiserror = "2.0.8"
20-
num_cpus = "1.16.0"
21-
serde_json = { version = "1.0.133", optional = true, features = ["std"], default-features = false }
22-
indicatif = { version = "0.17.9", default-features = false }
23-
clap = { version = "4.5.23", optional = true, features = ["std"], default-features = false }
24-
md-5 = "0.10.6"
25-
sha-1 = "0.10.1"
26-
sha2 = "0.10.8"
27-
digest = "0.10.7"
28-
hex = "0.4.3"
29-
sha3 = "0.10.8"
30-
blake2 = "0.10.6"
31-
whirlpool = "0.10.4"
18+
rand = { version = "0.9.0", features = ["thread_rng"], default-features = false }
19+
thiserror = { version = "2.0.12", default-features = false }
20+
num_cpus = { version = "1.16.0", default-features = false }
21+
serde_json = { version = "1.0.140", optional = true, features = ["std"], default-features = false }
22+
indicatif = { version = "0.17.11", default-features = false }
23+
clap = { version = "4.5.32", optional = true, features = ["std"], default-features = false }
24+
hex = { version = "0.4.3", features = ["alloc"], default-features = false }
25+
md-5 = { version = "0.10.6", default-features = false }
26+
sha-1 = { version = "0.10.1", default-features = false }
27+
sha2 = { version = "0.10.8", default-features = false }
28+
digest = { version = "0.10.7", default-features = false }
29+
sha3 = { version = "0.10.8", default-features = false }
30+
blake2 = { version = "0.10.6", default-features = false }
31+
whirlpool = { version = "0.10.4", default-features = false }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ You can find below the options for the main features of WorgenX:
111111
-h, --hash <hash> Hash algorithm to use for the wordlist.
112112
You can choose between: md5, sha1, sha224, sha256, sha384, sha512, sha3-224, sha3-256, sha3-384, sha3-512, blake2b, blake2s and whirlpool
113113
-t <threads>, --threads <threads> Number of threads to generate the passwords
114-
By default, the number of threads is based on the number of physical cores of the CPU
114+
By default, the number of threads is based on the number of logical cores of the CPU
115115
116116
--- Password generation ---
117117
You must specify at least one of the following options: -l, -u, -n, -x
@@ -133,7 +133,7 @@ You can find below the options for the main features of WorgenX:
133133
--- CPU Benchmark ---
134134
The following option is optional:
135135
-t <threads>, --threads <threads> Number of threads to use for the CPU benchmark
136-
By default, the number of threads is based on the number of physical cores of the CPU
136+
By default, the number of threads is based on the number of logical cores of the CPU
137137
138138
```
139139

src/benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const PASSWORD_CONFIG: PasswordConfig = PasswordConfig {
3838
///
3939
/// * `Result<u64, WorgenXError>` - The number of passwords generated in 60 seconds, WorgenXError otherwise.
4040
///
41-
pub fn load_cpu_benchmark(nb_of_threads: u8) -> Result<u64, WorgenXError> {
41+
pub fn load_cpu_benchmark(nb_of_threads: usize) -> Result<u64, WorgenXError> {
4242
let (tx_progress_bar, rx_progress_bar) = mpsc::channel::<Result<u64, WorgenXError>>();
4343
let pb: Arc<Mutex<ProgressBar>> = Arc::new(Mutex::new(system::get_progress_bar()));
4444
let pb_clone: Arc<Mutex<ProgressBar>> = Arc::clone(&pb);

src/error.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ pub enum ArgError {
1616
/// This error is raised if the user doesn't specify any argument.
1717
#[error("Error: no argument specified\nUsage: worgenX <command> [options]\nTry 'worgenX --help' for more information.")]
1818
NoArgument,
19-
/// This error is raised if the user specifies an argument that requires a value but doesn't give it.
20-
#[error("Error: missing value for {0}")]
21-
MissingValue(String),
2219
/// This error is raised if there isn't any configuration given by the user (for example just wordlist feature without any type of characters specified).
2320
#[error("Error: no configuration given for argument.\nPlease specify the mandatory parameters and at least one type of characters.\nUsage: worgenX <command> [options]\nTry 'worgenX --help' for more information.")]
2421
MissingConfiguration,

src/main.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ fn main() {
2727
mode::gui::run();
2828

2929
#[cfg(feature = "cli")]
30-
match mode::cli::run() {
31-
Ok(_) => {
32-
std::process::exit(0);
33-
}
34-
Err(e) => {
35-
println!("{}", e);
36-
std::process::exit(1);
37-
}
30+
if let Err(e) = mode::cli::run() {
31+
eprintln!("{}", e);
32+
std::process::exit(1);
3833
}
34+
35+
std::process::exit(0);
3936
}

src/mode/cli.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ struct WordlistGenerationOptions {
3131
wordlist_values: WordlistValues,
3232
output_file: String,
3333
no_loading_bar: bool,
34-
threads: u8,
34+
threads: usize,
3535
}
3636

3737
/// This struct is built from the arguments for the benchmark feature.
3838
///
3939
struct BenchmarkOptions {
40-
threads: u8,
40+
threads: usize,
4141
}
4242

4343
/// This function is responsible for building the command context of the CLI mode with the clap framework.
@@ -47,7 +47,7 @@ struct BenchmarkOptions {
4747
/// Command struct containing the different features of WorgenX.
4848
///
4949
fn build_command_context() -> Command {
50-
let default_threads: &'static str = Box::leak(num_cpus::get_physical().to_string().into_boxed_str()); // Ensure a static reference to the number of physical cores of the CPU
50+
let default_threads: &'static str = Box::leak(num_cpus::get().to_string().into_boxed_str()); // Ensure a static reference to the number of logical cores of the CPU
5151
let wordlist_command: Command = Command::new("wordlist")
5252
.arg_required_else_help(true)
5353
.arg(
@@ -116,7 +116,7 @@ fn build_command_context() -> Command {
116116
.short('t')
117117
.long("threads")
118118
.help("Number of threads to generate the passwords")
119-
.value_parser(value_parser!(u8).range(1..u8::MAX as i64))
119+
.value_parser(value_parser!(usize))
120120
.value_name("threads")
121121
.default_value(default_threads),
122122
);
@@ -201,7 +201,7 @@ fn build_command_context() -> Command {
201201
.short('t')
202202
.long("threads")
203203
.help("Number of threads to use for the CPU benchmark")
204-
.value_parser(value_parser!(u8).range(1..u8::MAX as i64))
204+
.value_parser(value_parser!(usize))
205205
.value_name("threads")
206206
.default_value(default_threads),
207207
);
@@ -245,7 +245,7 @@ pub fn run() -> Result<(), WorgenXError> {
245245
Some(("wordlist", sub_matches)) => run_wordlist(sub_matches),
246246
Some(("password", sub_matches)) => run_passwd(sub_matches),
247247
Some(("benchmark", sub_matches)) => run_benchmark(sub_matches),
248-
_ => Err(WorgenXError::ArgError(ArgError::NoArgument)) // Should never happen.
248+
_ => Err(WorgenXError::ArgError(ArgError::NoArgument))
249249
}
250250
}
251251

@@ -313,6 +313,10 @@ fn run_passwd(sub_matches: &ArgMatches) -> Result<(), WorgenXError> {
313313
fn allocate_passwd_config_cli(
314314
sub_matches: &ArgMatches,
315315
) -> Result<PasswordGenerationOptions, WorgenXError> {
316+
// Clap framework ensures that the arguments are present.
317+
let length: u32 = *sub_matches.get_one::<u32>("size").unwrap();
318+
let size: u64 = *sub_matches.get_one::<u64>("count").unwrap();
319+
316320
let mut output_file: String = String::new();
317321
let mut json: bool = false;
318322
let mut no_display: bool = false;
@@ -322,8 +326,8 @@ fn allocate_passwd_config_cli(
322326
special_characters: false,
323327
uppercase: false,
324328
lowercase: false,
325-
length: *sub_matches.get_one::<u32>("size").ok_or(WorgenXError::ArgError(ArgError::MissingValue("-s or --size".to_string())))?,
326-
number_of_passwords: *sub_matches.get_one::<u64>("count").ok_or(WorgenXError::ArgError(ArgError::MissingValue("-c or --count".to_string())))?,
329+
length,
330+
number_of_passwords: size,
327331
};
328332

329333
update_config(&mut password_config.lowercase, sub_matches, "lowercase_password");
@@ -401,7 +405,7 @@ fn allocate_wordlist_config_cli(
401405
) -> Result<WordlistGenerationOptions, WorgenXError> {
402406
let mut output_file: String = String::new();
403407
let mut no_loading_bar: bool = false;
404-
let mut threads: u8 = 0;
408+
let mut threads: usize = 0;
405409
let mut wordlist_values: WordlistValues = WordlistValues {
406410
numbers: false,
407411
special_characters: false,
@@ -472,7 +476,7 @@ fn run_benchmark(sub_matches: &ArgMatches) -> Result<(), WorgenXError> {
472476
fn allocate_benchmark_config_cli(
473477
sub_matches: &ArgMatches,
474478
) -> Result<BenchmarkOptions, WorgenXError> {
475-
let mut threads: u8 = 0;
479+
let mut threads: usize = 0;
476480
update_config(&mut threads, sub_matches, "threads_benchmark");
477481

478482
Ok(BenchmarkOptions { threads })
@@ -541,7 +545,7 @@ fn display_help() {
541545
println!("\n The following options are optional:");
542546
println!(" -d, --disable-loading-bar\t\tDisable the loading bar when generating the wordlist");
543547
println!(" -h, --hash <hash>\t\t\tHash algorithm to use for the wordlist.\n\t\t\t\t\tYou can choose between: md5, sha1, sha224, sha256, sha384, sha512,\n\t\t\t\t\tsha3-224, sha3-256, sha3-384, sha3-512, blake2b-512, blake2s-256 and whirlpool");
544-
println!(" -t <threads>, --threads <threads>\tNumber of threads to generate the passwords\n\t\t\t\t\tBy default, the number of threads is based on the number of physical cores of the CPU");
548+
println!(" -t <threads>, --threads <threads>\tNumber of threads to generate the passwords\n\t\t\t\t\tBy default, the number of threads is based on the number of logical cores of the CPU");
545549

546550
println!("\n --- Password generation ---");
547551
println!(" You must specify at least one of the following options: -l, -u, -n, -x");
@@ -559,7 +563,7 @@ fn display_help() {
559563

560564
println!("\n --- CPU Benchmark ---");
561565
println!(" The following option is optional:");
562-
println!(" -t <threads>, --threads <threads>\tNumber of threads to use for the CPU benchmark\n\t\t\t\t\tBy default, the number of threads is based on the number of physical cores of the CPU\n");
566+
println!(" -t <threads>, --threads <threads>\tNumber of threads to use for the CPU benchmark\n\t\t\t\t\tBy default, the number of threads is based on the number of logical cores of the CPU\n");
563567
}
564568

565569
#[cfg(test)]
@@ -592,7 +596,7 @@ mod tests {
592596
let result: WordlistGenerationOptions = allocate_wordlist_config_cli(sub_matches).unwrap();
593597

594598
assert_eq!(result.wordlist_values.mask, "A?1");
595-
assert_eq!(result.threads, 4);
599+
assert_eq!(result.threads, 4_usize);
596600
assert!(result.wordlist_values.lowercase);
597601
assert!(result.wordlist_values.uppercase);
598602
assert!(result.wordlist_values.numbers);
@@ -608,7 +612,7 @@ mod tests {
608612
let (_, sub_matches) = matches.subcommand().unwrap();
609613
let result: BenchmarkOptions = allocate_benchmark_config_cli(sub_matches).unwrap();
610614

611-
assert_eq!(result.threads, 4);
615+
assert_eq!(result.threads, 4_usize);
612616
}
613617

614618
#[test]

src/mode/gui.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn main_wordlist_generation() {
216216
if let Err(e) = wordlist::wordlist_generation_scheduler(
217217
&wordlist_config,
218218
nb_of_passwords,
219-
num_cpus::get_physical() as u8,
219+
num_cpus::get(),
220220
&filename,
221221
false,
222222
) {
@@ -318,7 +318,7 @@ fn main_benchmark() {
318318
while again.eq("y") {
319319
println!("The benchmark will start in 5 seconds...");
320320
thread::sleep(std::time::Duration::from_secs(5));
321-
match benchmark::load_cpu_benchmark(num_cpus::get_physical() as u8) {
321+
match benchmark::load_cpu_benchmark(num_cpus::get()) {
322322
Ok(nb_of_passwords) => {
323323
println!("Your CPU has generated {} passwords in 1 minute", nb_of_passwords);
324324
}

src/password.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::dict;
33

44
// External crates.
5-
use rand::{rngs::OsRng, seq::SliceRandom, Rng};
5+
use rand::{rngs::ThreadRng, seq::SliceRandom, Rng};
66

77
/// This struct built from the user's choices will be used to generate the random password.
88
///
@@ -47,7 +47,7 @@ fn create_passwd_content(password_config: &PasswordConfig) -> Vec<u8> {
4747
password_content.extend(shuffle_dict(dict::SPECIAL_CHARACTERS));
4848
}
4949

50-
let mut rng: OsRng = OsRng;
50+
let mut rng: ThreadRng = rand::rng();
5151
password_content.shuffle(&mut rng);
5252
password_content
5353
}
@@ -64,7 +64,7 @@ fn create_passwd_content(password_config: &PasswordConfig) -> Vec<u8> {
6464
///
6565
fn shuffle_dict(dict: &[u8]) -> Vec<u8> {
6666
let mut shuffled_dict: Vec<u8> = dict.to_vec();
67-
let mut rng: OsRng = OsRng;
67+
let mut rng: ThreadRng = rand::rng();
6868
shuffled_dict.shuffle(&mut rng);
6969
shuffled_dict
7070
}
@@ -85,10 +85,10 @@ pub fn generate_random_passwords(password_config: &PasswordConfig) -> Vec<String
8585
let password_content: Vec<u8> = create_passwd_content(password_config);
8686

8787
for _ in 0..password_config.number_of_passwords {
88-
let mut rng: OsRng = OsRng;
88+
let mut rng: ThreadRng = rand::rng();
8989
let mut password: String = String::new();
9090
for _ in 0..password_config.length {
91-
let idx: usize = rng.gen_range(0..password_content.len());
91+
let idx: usize = rng.random_range(0..password_content.len());
9292
password.push(password_content[idx] as char);
9393
}
9494
passwords.push(password);
@@ -112,7 +112,7 @@ mod tests {
112112
number_of_passwords: 1,
113113
};
114114
let password_content: Vec<u8> = create_passwd_content(&password_config);
115-
115+
116116
assert_eq!(password_content.len(), 91);
117117
}
118118

src/system.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn is_valid_path(path: &str) -> Result<String, SystemError> {
149149
))
150150
}
151151
};
152-
current_dir + "/" + path
152+
current_dir + "/" + path.trim_start_matches("./")
153153
} else {
154154
path.to_string()
155155
};
@@ -312,7 +312,7 @@ pub fn get_progress_bar() -> indicatif::ProgressBar {
312312
pb
313313
}
314314

315-
/// This functions is responsible for returning the estimated size of the wordlist.
315+
/// This function is responsible for returning the estimated size of the wordlist.
316316
///
317317
/// # Arguments
318318
///
@@ -352,7 +352,7 @@ pub fn get_estimated_size(nb_of_passwords: u64, length: u64) -> String {
352352
size_str
353353
}
354354

355-
/// This functions is responsible for managing password hashing.
355+
/// This function is responsible for managing password hashing.
356356
/// It returns the hashed password from the hash algorithm specified by the user.
357357
/// If the hash algorithm is not supported, it returns an error.
358358
///
@@ -384,7 +384,7 @@ pub fn manage_hash(password: String, hash: &str) -> Result<String, SystemError>
384384
}
385385
}
386386

387-
/// This functions is responsible for hashing a password with a specific hash algorithm.
387+
/// This function is responsible for hashing a password with a specific hash algorithm.
388388
/// It returns the hashed password.
389389
///
390390
/// # Arguments

src/wordlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn build_wordlist_config(wordlist_values: &WordlistValues) -> WordlistConfig
164164
pub fn wordlist_generation_scheduler(
165165
wordlist_config: &WordlistConfig,
166166
nb_of_passwords: u64,
167-
nb_of_threads: u8,
167+
nb_of_threads: usize,
168168
file_path: &str,
169169
no_loading_bar: bool,
170170
) -> Result<(), WorgenXError> {
@@ -217,7 +217,7 @@ pub fn wordlist_generation_scheduler(
217217
fn run_wordlist_generation(
218218
wordlist_config: &WordlistConfig,
219219
nb_of_passwords: u64,
220-
nb_of_threads: u8,
220+
nb_of_threads: usize,
221221
file_path: &str,
222222
) -> Result<(), WorgenXError> {
223223
let shared_formated_mask: Arc<Vec<char>> = Arc::new(wordlist_config.formated_mask.clone());

0 commit comments

Comments
 (0)