diff --git a/.gitignore b/.gitignore index 83575a7..ff3b040 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.exe passgen .cache/ +build* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..82543b4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.29) + +set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) +set(CMAKE_EXE_LINKER_FLAGS "-static") + +project(Passgen + VERSION 1.0 + DESCRIPTION "Passphrase generator" + LANGUAGES CXX) + +add_executable(passgen + passgen.cpp +) + +target_include_directories(passgen + PRIVATE + ${CMAKE_SOURCE_DIR}/include/ +) diff --git a/Makefile b/Makefile deleted file mode 100644 index ba5d4f9..0000000 --- a/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -TARGETS = passgen -BINARYOUT_TARGETS = passgen.o - -CPPFLAGS += -I./include -CXXFLAGS += -O2 - - -ifeq ($(OS),Windows_NT) - CC = x86_64-w64-mingw32-g++ - LD = x86_64-w64-mingw32-g++ - EXE_EXT = .exe - INSTALL_DIR = /usr/local/bin # Change this to your desired installation directory -else - CC = g++ - LD = g++ - EXE_EXT = - INSTALL_DIR = /usr/local/bin # Change this to your desired installation directory -endif - -all: $(TARGETS)$(EXE_EXT) - -run: - ./passgen$(EXE_EXT) - -clean: - rm -f *.o *.exe $(TARGETS) $(BINARYOUT_TARGETS) - -passgen.exe: passgen.o - $(LD) -static-libgcc -static-libstdc++ passgen.o -o passgen.exe - -passgen: passgen.o - $(LD) passgen.o -o passgen - -passgen.o: passgen.cpp ./include/pcg_random.hpp \ - ./include/pcg_extras.hpp ./include/pcg_uint128.hpp - $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o passgen.o passgen.cpp - -install: $(TARGETS)$(EXE_EXT) - @mkdir -p $(INSTALL_DIR) - cp $(TARGETS)$(EXE_EXT) $(INSTALL_DIR) - @echo "Installed $(TARGETS)$(EXE_EXT) to $(INSTALL_DIR)" - -uninstall: - rm -f $(INSTALL_DIR)/$(TARGETS)$(EXE_EXT) - @echo "Uninstalled $(TARGETS)$(EXE_EXT) from $(INSTALL_DIR)" diff --git a/README.md b/README.md index ce75ffc..d501ffa 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,14 @@ retrace-choice-litter-dreamt-zipping ``` This project uses the [EFF's Wordlists for Random Passphrases](https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases) and [PCG random](https://www.pcg-random.org/) to pick random words + +Compiling: +Compile to linux: +``` +mkdir build-linux && cd build-linux && cmake .. && make +``` + +Compile to Windows: +``` +mkdir build-windows && cd build-windows && cmake -DCMAKE_TOOLCHAIN_FILE=../mingw-toolchain.cmake .. && make +``` diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..847751b --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,8 @@ +[ +{ + "directory": "/home/mans/dev/passgen/build-windows", + "command": "/usr/bin/c++ -I/home/mans/dev/passgen/include -o CMakeFiles/passgen.dir/passgen.cpp.o -c /home/mans/dev/passgen/passgen.cpp", + "file": "/home/mans/dev/passgen/passgen.cpp", + "output": "CMakeFiles/passgen.dir/passgen.cpp.o" +} +] \ No newline at end of file diff --git a/mingw-toolchain.cmake b/mingw-toolchain.cmake new file mode 100644 index 0000000..2c74183 --- /dev/null +++ b/mingw-toolchain.cmake @@ -0,0 +1,7 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/passgen.cpp b/passgen.cpp index c03f9b0..1ae6cde 100644 --- a/passgen.cpp +++ b/passgen.cpp @@ -43,11 +43,11 @@ const std::unordered_map NoArgs { }; const std::unordered_map OneArgs { - {"-p", [](PassgenOptions& s, const std::string& arg) { + {"-wl", [](PassgenOptions& s, const std::string& arg) { s.wordlist_path = arg; s.wordlist_type = WORDLIST_CUSTOM; }}, - {"--path", [](PassgenOptions& s, const std::string& arg) { + {"--wordlist", [](PassgenOptions& s, const std::string& arg) { s.wordlist_path = arg; s.wordlist_type = WORDLIST_CUSTOM; }}, @@ -92,7 +92,7 @@ std::vector getWordlist(PassgenOptions opts) if (opts.wordlist_type != WORDLIST_CUSTOM) { std::stringstream ss; - if (WORDLIST_EFF_SHORT) { + if (opts.wordlist_type == WORDLIST_EFF_SHORT) { ss.write(reinterpret_cast(eff_short_wordlist_1_txt), eff_short_wordlist_1_txt_len); } else { ss.write(reinterpret_cast(eff_large_wordlist_txt), eff_large_wordlist_txt_len); @@ -133,7 +133,7 @@ Options: -s, --short Use the short EFF wordlist (dfault) -l, --large Use the large EFF wordlist --camelcase, -cc Generate passphrase in CamelCase format - -p , --path + -wl , --wordlist Use a custom wordlist file located at -wc , --wordcount Amount of words to use for passphrase, default = 5 @@ -145,7 +145,7 @@ Description: Examples: passgen -h passgen --short 4 - passgen -p /path/to/custom_wordlist.txt --wordcount 4 + passgen -wl /path/to/custom_wordlist.txt --wordcount 4 )"; return 0; }