add -S (scramble) option

This commit is contained in:
Lily Tsuru 2023-08-22 19:08:35 -04:00
parent 361fb62804
commit 95a762ee0f
1 changed files with 25 additions and 5 deletions

View File

@ -1,9 +1,11 @@
#include "ansi.hpp"
#include "fprint.hpp"
#include "scramble.hpp"
#include "worker.hpp"
#ifdef _WIN32
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
DWORD lastVtMode = 0;
@ -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] <hash to crack, in hexadecimal>\n"
"Usage: {} [-?/-h] [-X] [-s START_LENGTH] [-e END_LENGTH] <-S STRING> <hash to crack, in hexadecimal>\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",