Skip to content

Commit

Permalink
Added custom wordlist option
Browse files Browse the repository at this point in the history
  • Loading branch information
DemwE committed Sep 12, 2023
1 parent 10924bc commit 962e200
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rgen"
version = "1.3.0"
version = "1.3.1"
authors = ["Mateusz Czarnecki (DemwE)"]
description = "A simple CLI tool for generating random passwords or passphrase passwords."
edition = "2021"
Expand Down
27 changes: 21 additions & 6 deletions build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,29 @@ BuildLinux=$(cat build.conf | grep BuildLinux | cut -d "=" -f 2)
BuildMac=$(cat build.conf | grep BuildMac | cut -d "=" -f 2)

if [ "$UpdateRustTargets" == "true" ]; then
echo -e "\e[94mUpdating rust targets\e[0m"
rustup target add x86_64-pc-windows-gnu
rustup target add x86_64-unknown-linux-gnu
rustup target add x86_64-apple-darwin
echo -e "\e[94mUpdating/Downloading rust targets\e[0m"
if [ "BuildWindows" == "true" ]; then
rustup target remove x86_64-pc-windows-gnu
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to update or download rust targets\e[0m"
fi
fi
if [ "BuildLinux" == "true" ]; then
rustup target remove x86_64-unknown-linux-gnu
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to update or download rust targets\e[0m"
fi
fi
if [ "BuildMac" == "true" ]; then
rustup target remove x86_64-apple-darwin
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to update or download rust targets\e[0m"
fi
fi
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to update rust targets\e[0m"
echo -e "\e[31mError: Failed to update or download rust targets\e[0m"
else
echo -e "\e[92mRust targets updated\e[0m"
echo -e "\e[92mRust targets updated/downloaded\e[0m"
fi
elif [ "$UpdateRustTargets" == "false" ]; then
echo -e "\e[94mSkipping rust target update.\e[0m"
Expand Down
3 changes: 3 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ pub struct RgenArgs {
#[clap(default_value = "3")]
#[clap(short, long)]
pub passphrase_count: Option<i32>,
/// Custom passphrase list file
#[clap(short = 'C', long)]
pub custom_passphrase_list: Option<String>,
}
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fn main() {
for _ in 0..count {
let password = if args.passphrase {
passphrase_password::generator(&args)

} else {
random_password::generator(&args)
};
Expand Down
13 changes: 12 additions & 1 deletion src/passphrase_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ pub fn generator(args: &args::RgenArgs) -> String
{
let mut rng = rand::thread_rng();

let passphrases = include_str!("passphrases.txt");
let passphrases = if args.custom_passphrase_list.is_some() {
match std::fs::read_to_string(args.custom_passphrase_list.as_ref().unwrap()) {
Ok(content) => content,
Err(error) => {
eprintln!("Error: {}", error);
std::process::exit(1);
}
}
} else {
include_str!("passphrases.txt").to_string()
};

let available_passphrases = passphrases.split("\n").collect::<Vec<&str>>();

let count = args.passphrase_count.unwrap_or(3); // Use 3 as the default value
Expand Down

0 comments on commit 962e200

Please sign in to comment.