edit readme, change defaults & remove C++20 requirement
This commit is contained in:
parent
8a727a6ed4
commit
501eb679a2
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ TARGETS = passgen
|
||||
BINARYOUT_TARGETS = passgen.o
|
||||
|
||||
CPPFLAGS += -I./include
|
||||
CXXFLAGS += -std=c++20 -O2
|
||||
CXXFLAGS += -O2
|
||||
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
|
17
README.md
17
README.md
@ -1,7 +1,22 @@
|
||||
# passgen
|
||||
passgen generate passphrases based on wordlists.
|
||||
Usage:
|
||||
```
|
||||
passgen <wordlist_path> <word_count>
|
||||
Usage: passgen [options]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help message and exit
|
||||
-s, --short Use the short EFF wordlist
|
||||
-l, --large Use the large EFF wordlist (dfault)
|
||||
--camelcase, -cc Generate passwords in CamelCase format
|
||||
-p <path>, --path <path>
|
||||
Use a custom wordlist file located at <path>
|
||||
-wc <count>, --wordcount <count>
|
||||
Amount of words to use for passphrase
|
||||
--separator <seperator> Specify a character to use as a separator between words, default = `-`
|
||||
|
||||
Description:
|
||||
Generate passphrases based on wordlists.
|
||||
```
|
||||
|
||||
example output:
|
||||
|
@ -1,17 +0,0 @@
|
||||
[
|
||||
{
|
||||
"arguments": [
|
||||
"/usr/bin/g++",
|
||||
"-std=c++20",
|
||||
"-O2",
|
||||
"-I./include",
|
||||
"-c",
|
||||
"-o",
|
||||
"passgen.o",
|
||||
"passgen.cpp"
|
||||
],
|
||||
"directory": "/home/mans/dev/passgen",
|
||||
"file": "/home/mans/dev/passgen/passgen.cpp",
|
||||
"output": "/home/mans/dev/passgen/passgen.o"
|
||||
}
|
||||
]
|
35
passgen.cpp
35
passgen.cpp
@ -1,6 +1,5 @@
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <format>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -19,12 +18,11 @@ enum WordlistType { WORDLIST_EFF_LARGE, WORDLIST_EFF_SHORT, WORDLIST_CUSTOM };
|
||||
|
||||
struct PassgenOptions {
|
||||
bool help = false;
|
||||
WordlistType wordlist_type = WORDLIST_EFF_LARGE;
|
||||
WordlistType wordlist_type = WORDLIST_EFF_SHORT;
|
||||
int wordcount = 5;
|
||||
bool camelcase = false;
|
||||
std::string seperator = "-";
|
||||
std::optional<std::string> wordlist_path;
|
||||
std::optional<std::string> outfile;
|
||||
};
|
||||
|
||||
typedef std::function<void(PassgenOptions&)> NoArgHandle;
|
||||
@ -77,11 +75,11 @@ PassgenOptions parse_options(int argc, const char* argv[]) {
|
||||
k->second(settings, {argv[i]});
|
||||
} else {
|
||||
throw std::runtime_error {"missing param after " + opt};
|
||||
exit(1);
|
||||
std::exit(1);
|
||||
}
|
||||
} else {
|
||||
std::cerr << "unrecognized command-line option " << opt << std::endl;
|
||||
exit(1);
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
@ -91,25 +89,20 @@ std::vector<std::string> getWordlist(PassgenOptions opts)
|
||||
{
|
||||
std::vector<std::string> map;
|
||||
|
||||
if (opts.wordlist_type == WORDLIST_EFF_LARGE)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.write(reinterpret_cast<const char*>(eff_large_wordlist_txt), eff_large_wordlist_txt_len);
|
||||
std::string line;
|
||||
while (std::getline(ss, line)) {
|
||||
map.push_back(line);
|
||||
}
|
||||
}
|
||||
else if (opts.wordlist_type == WORDLIST_EFF_SHORT)
|
||||
if (opts.wordlist_type != WORDLIST_CUSTOM)
|
||||
{
|
||||
std::stringstream ss;
|
||||
if (WORDLIST_EFF_SHORT) {
|
||||
ss.write(reinterpret_cast<const char*>(eff_short_wordlist_1_txt), eff_short_wordlist_1_txt_len);
|
||||
} else {
|
||||
ss.write(reinterpret_cast<const char*>(eff_large_wordlist_txt), eff_large_wordlist_txt_len);
|
||||
}
|
||||
std::string line;
|
||||
while (std::getline(ss, line)) {
|
||||
map.push_back(line);
|
||||
}
|
||||
}
|
||||
else if (opts.wordlist_type == WORDLIST_CUSTOM && opts.wordlist_path.has_value())
|
||||
else if (opts.wordlist_path.has_value())
|
||||
{
|
||||
std::string path = opts.wordlist_path.value();
|
||||
std::ifstream file(path);
|
||||
@ -119,8 +112,10 @@ std::vector<std::string> getWordlist(PassgenOptions opts)
|
||||
map.push_back(line);
|
||||
}
|
||||
} else {
|
||||
std::cout << std::format("ERROR: failed to open '{}'\n", path);
|
||||
std::cout << "ERROR: failed to open '" << path << "'" << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cout << "ERROR: no wordlist specified" << std::endl;
|
||||
}
|
||||
|
||||
return map;
|
||||
@ -135,13 +130,13 @@ Usage: passgen [options]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help message and exit
|
||||
-s, --short Use the short EFF wordlist
|
||||
-l, --large Use the large EFF wordlist (dfault)
|
||||
-s, --short Use the short EFF wordlist (dfault)
|
||||
-l, --large Use the large EFF wordlist
|
||||
--camelcase, -cc Generate passphrase in CamelCase format
|
||||
-p <path>, --path <path>
|
||||
Use a custom wordlist file located at <path>
|
||||
-wc <count>, --wordcount <count>
|
||||
Amount of words to use for passphrase
|
||||
Amount of words to use for passphrase, default = 5
|
||||
--separator <seperator> Specify a character to use as a separator between words, default = `-`
|
||||
|
||||
Description:
|
||||
|
Loading…
Reference in New Issue
Block a user