diff --git a/src/main.cpp b/src/main.cpp index 8cbccec..7e2e41c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,18 @@ +#include "ansi.hpp" #include "fprint.hpp" +#include "scramble.hpp" #include "worker.hpp" #ifdef _WIN32 -#define _WIN32_LEAN_AND_MEAN -#include + #define _WIN32_LEAN_AND_MEAN + #include DWORD lastVtMode = 0; void EnableVtMode() { GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &lastVtMode); - auto newMode = lastVtMode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; - SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), newMode); + auto newMode = lastVtMode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), newMode); } void DisableVtMode() { @@ -79,6 +81,23 @@ struct Arguments { i++; break; + case 'S': { // Scramble + if(argv[i + 1] == nullptr || argv[i + 1][0] == '-') { + swbf::fprint(stdout, "Invalid value passed to -S\n"); + std::exit(1); + } + auto str = std::string(argv[i + 1]); + + if(str.length() > 8) { + swbf::fprint(stdout, "Invalid value passed to -S\n"); + std::exit(1); + } + + swbf::fprint(stdout, "Scramble of {}\"{}\"{} is {}{:8x}{}\n", swbf::ansi::Color(172), str, swbf::ansi::Reset(), + swbf::ansi::Color(166), swbf::SwsfScramble(str), swbf::ansi::Reset()); + std::exit(0); + } break; + // terminals case '?': case 'h': { @@ -132,8 +151,9 @@ struct Arguments { swbf::fprint(stdout, // clang-format off "SWSF Bruteforcer, (C) 2023 Lily Tsuru under the MIT License\n" - "Usage: {} [-?/-h] [-X] [-s START_LENGTH] [-e END_LENGTH] \n" + "Usage: {} [-?/-h] [-X] [-s START_LENGTH] [-e END_LENGTH] <-S STRING> \n" " -X Test exact length. Uses value of -s; -e is ignored in this mode.\n" + " -S Scramble the given input string\n" " -s Start length to check. Must be greater than or equal to 2 and less than the end size (default 2)\n" " -e End length to check. Must be greater than the start size, and less than or equal to 8 (default 8)\n" " -?/-h Show this help message (and exit)\n",