refactor bruteforce headers and namespace

This commit is contained in:
PhaseLoop 2023-05-27 11:57:39 +00:00
commit bad5c1ea61
4 changed files with 47 additions and 41 deletions

View file

@ -22,28 +22,33 @@
#include "common.h"
typedef uint8_t bruteforce_mode_t;
#define BF_KEY_SIZE_32 4
#define BF_KEY_SIZE_48 6
// bruteforcing all keys sequentially between X and Y
#define BRUTEFORCE_MODE_RANGE 1
#define BF_MODE_RANGE 1
// try keys based on limited charset/passphrases
// some payment systems use user-provided passphrase as system key
#define BRUTEFORCE_MODE_CHARSET 2
#define BF_MODE_CHARSET 2
// "smart" mode - try some predictable patterns
#define BRUTEFORCE_MODE_SMART 3
#define BF_MODE_SMART 3
typedef uint8_t bruteforce_charset_t;
// bit flags - can be used together using logical OR
#define CHARSET_DIGITS 1
#define CHARSET_UPPERCASE 2
#define BF_CHARSET_DIGITS 1
#define BF_CHARSET_UPPERCASE 2
#define GENERATOR_END 0
#define GENERATOR_NEXT 1
#define GENERATOR_ERROR 2
#define BF_GENERATOR_END 0
#define BF_GENERATOR_NEXT 1
#define BF_GENERATOR_ERROR 2
#define BF_CHARSET_DIGITS_SIZE 10
#define BF_CHARSET_UPPERCASE_SIZE 25
#define CHARSET_DIGITS_SIZE 10
#define CHARSET_UPPERCASE_SIZE 25
extern uint8_t charset_digits[];
extern uint8_t charset_uppercase[];
@ -53,12 +58,13 @@ typedef struct {
// position of each of 4 bytes in 32 bit key in charset mode
// add more bytes to support larger keys
// pos[0] is most significant byte - all maths avoid relying on little/big endian memory layout
uint8_t pos[4];
uint8_t pos[6]; // max supported key is now 48 bit
uint8_t key_length; // bytes
uint32_t current_key32;
uint8_t mode;
uint8_t charset[
CHARSET_DIGITS_SIZE
+ CHARSET_UPPERCASE_SIZE
BF_CHARSET_DIGITS_SIZE
+ BF_CHARSET_UPPERCASE_SIZE
];
uint8_t charset_length;
@ -69,7 +75,7 @@ typedef struct {
} generator_context_t;
void bf_generator_init(generator_context_t *ctx, uint8_t mode);
void bf_generator_init(generator_context_t *ctx, uint8_t mode, uint8_t key_size);
int bf_generator_set_charset(generator_context_t *ctx, uint8_t charsets);
int bf_generate32(generator_context_t *ctx);
int _bf_generate_mode_range32(generator_context_t *ctx);