mirror of
https://github.com/hashcat/hashcat.git
synced 2025-05-30 20:58:51 +00:00
Add support for rule position 'p' in host mode
This commit is contained in:
parent
b924901bb0
commit
be0dec621a
@ -14,6 +14,7 @@
|
|||||||
- Wordlist encoding: Support added for internal convert from and to user-defined encoding during runtime
|
- Wordlist encoding: Support added for internal convert from and to user-defined encoding during runtime
|
||||||
- Wordlist encoding: Added parameters --encoding-from and --encoding-to to configure wordlist encoding handling
|
- Wordlist encoding: Added parameters --encoding-from and --encoding-to to configure wordlist encoding handling
|
||||||
- Rules: Support added for rule 'eX'
|
- Rules: Support added for rule 'eX'
|
||||||
|
- Rules: Support added for position 'p' in host mode (using -j or -k)
|
||||||
|
|
||||||
##
|
##
|
||||||
## Improvements
|
## Improvements
|
||||||
|
@ -56,4 +56,4 @@
|
|||||||
#define RULE_OP_REJECT_EQUAL_AT '=' // reject plains that do not contain char X at position N
|
#define RULE_OP_REJECT_EQUAL_AT '=' // reject plains that do not contain char X at position N
|
||||||
#define RULE_OP_REJECT_CONTAINS '%' // reject plains that contain char X less than N times
|
#define RULE_OP_REJECT_CONTAINS '%' // reject plains that contain char X less than N times
|
||||||
#define RULE_OP_REJECT_MEMORY 'Q' // reject plains that match the plain saved (see M), i.e. if unchanged
|
#define RULE_OP_REJECT_MEMORY 'Q' // reject plains that match the plain saved (see M), i.e. if unchanged
|
||||||
|
#define RULE_LAST_REJECTED_SAVED_POS 'p' // position of the character last found with '/' or '%'
|
||||||
|
@ -293,6 +293,7 @@ typedef enum rule_functions
|
|||||||
RULE_OP_REJECT_EQUAL_AT = '=',
|
RULE_OP_REJECT_EQUAL_AT = '=',
|
||||||
RULE_OP_REJECT_CONTAINS = '%',
|
RULE_OP_REJECT_CONTAINS = '%',
|
||||||
RULE_OP_REJECT_MEMORY = 'Q',
|
RULE_OP_REJECT_MEMORY = 'Q',
|
||||||
|
RULE_LAST_REJECTED_SAVED_POS = 'p',
|
||||||
|
|
||||||
RULE_OP_MANGLE_SWITCH_FIRST = 'k',
|
RULE_OP_MANGLE_SWITCH_FIRST = 'k',
|
||||||
RULE_OP_MANGLE_SWITCH_LAST = 'K',
|
RULE_OP_MANGLE_SWITCH_LAST = 'K',
|
||||||
|
34
src/rp_cpu.c
34
src/rp_cpu.c
@ -9,7 +9,18 @@
|
|||||||
#include "rp_cpu.h"
|
#include "rp_cpu.h"
|
||||||
|
|
||||||
#define NEXT_RULEPOS(rp) if (++(rp) == rule_len) return (RULE_RC_SYNTAX_ERROR)
|
#define NEXT_RULEPOS(rp) if (++(rp) == rule_len) return (RULE_RC_SYNTAX_ERROR)
|
||||||
#define NEXT_RPTOI(r,rp,up) if (((up) = conv_ctoi ((r)[(rp)])) == -1) return (RULE_RC_SYNTAX_ERROR)
|
#define NEXT_RPTOI(r,rp,up) if (((up) = conv_pos ((r)[(rp)], pos_mem)) == -1) return (RULE_RC_SYNTAX_ERROR)
|
||||||
|
|
||||||
|
static int conv_pos (const u8 c, const int pos_mem) {
|
||||||
|
if (c == RULE_LAST_REJECTED_SAVED_POS)
|
||||||
|
{
|
||||||
|
return pos_mem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return conv_ctoi (c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void MANGLE_TOGGLE_AT (char *arr, const int pos)
|
static void MANGLE_TOGGLE_AT (char *arr, const int pos)
|
||||||
{
|
{
|
||||||
@ -464,6 +475,7 @@ static int mangle_title_sep (char arr[BLOCK_SIZE], int arr_len, char c)
|
|||||||
int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE])
|
int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE])
|
||||||
{
|
{
|
||||||
char mem[BLOCK_SIZE] = { 0 };
|
char mem[BLOCK_SIZE] = { 0 };
|
||||||
|
int pos_mem = -1;
|
||||||
|
|
||||||
if (in == NULL) return (RULE_RC_REJECT_ERROR);
|
if (in == NULL) return (RULE_RC_REJECT_ERROR);
|
||||||
|
|
||||||
@ -761,7 +773,15 @@ int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len,
|
|||||||
|
|
||||||
case RULE_OP_REJECT_NOT_CONTAIN:
|
case RULE_OP_REJECT_NOT_CONTAIN:
|
||||||
NEXT_RULEPOS (rule_pos);
|
NEXT_RULEPOS (rule_pos);
|
||||||
if (strchr (out, rule[rule_pos]) == NULL) return (RULE_RC_REJECT_ERROR);
|
char *match = strchr (out, rule[rule_pos]);
|
||||||
|
if (match != NULL)
|
||||||
|
{
|
||||||
|
pos_mem = (int)(match - out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (RULE_RC_REJECT_ERROR);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RULE_OP_REJECT_EQUAL_FIRST:
|
case RULE_OP_REJECT_EQUAL_FIRST:
|
||||||
@ -787,7 +807,15 @@ int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len,
|
|||||||
NEXT_RPTOI (rule, rule_pos, upos);
|
NEXT_RPTOI (rule, rule_pos, upos);
|
||||||
if ((upos + 1) > out_len) return (RULE_RC_REJECT_ERROR);
|
if ((upos + 1) > out_len) return (RULE_RC_REJECT_ERROR);
|
||||||
NEXT_RULEPOS (rule_pos);
|
NEXT_RULEPOS (rule_pos);
|
||||||
int c; int cnt; for (c = 0, cnt = 0; c < out_len; c++) if (out[c] == rule[rule_pos]) cnt++;
|
int c; int cnt;
|
||||||
|
for (c = 0, cnt = 0; c < out_len && cnt < upos; c++) {
|
||||||
|
if (out[c] == rule[rule_pos])
|
||||||
|
{
|
||||||
|
cnt++;
|
||||||
|
pos_mem = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cnt < upos) return (RULE_RC_REJECT_ERROR);
|
if (cnt < upos) return (RULE_RC_REJECT_ERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user