Skip to content

Commit a0d6b76

Browse files
committed
Update rules.c properly
Nice and tidy :) . Added options h, H, B and modified case v
1 parent d8f5b01 commit a0d6b76

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

src/rules.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,35 @@ char *rules_apply(char *word_in, char *rule, int split)
14241424
break;
14251425

14261426
case 'v': /* assign value to numeric variable */
1427+
if (hc_logic)
14271428
{
1429+
/* HC rule: insert char X every N chars */
1430+
unsigned int n, i, out_len = 0;
1431+
char value;
1432+
char *out;
1433+
POSITION(n)
1434+
VALUE(value)
1435+
if (!n)
1436+
break;
1437+
GET_OUT
1438+
for (i = 0; i < length; i++)
1439+
{
1440+
if (out_len >= RULE_WORD_SIZE - 1)
1441+
break;
1442+
out[out_len++] = in[i];
1443+
if (((i + 1) % n) == 0) {
1444+
if (out_len >= RULE_WORD_SIZE - 1)
1445+
break;
1446+
out[out_len++] = value;
1447+
}
1448+
}
1449+
out[out_len] = 0;
1450+
in = out;
1451+
length = out_len;
1452+
break;
1453+
}
1454+
else
1455+
{ /*Original JtR rule */
14281456
char var;
14291457
int a, s; /* may be negative */
14301458
VALUE(var)
@@ -1436,6 +1464,45 @@ char *rules_apply(char *word_in, char *rule, int split)
14361464
rules_vars[ARCH_INDEX(var)] = a - s; /* may be negative */
14371465
}
14381466
break;
1467+
1468+
case 'h': /*convert the entire password to lowercase hex */
1469+
{
1470+
char outbuf[RULE_WORD_SIZE * 2];
1471+
int i;
1472+
if (length * 2 >= RULE_WORD_SIZE)
1473+
break;
1474+
for (i = 0; i < length; i++)
1475+
sprintf(&outbuf[i * 2], "%02x", (unsigned char)in[i]);
1476+
strcpy(in, outbuf);
1477+
length *= 2;
1478+
}
1479+
break;
1480+
1481+
case 'H': /*convert the entire password to uppercase hex*/
1482+
{
1483+
char outbuf[RULE_WORD_SIZE * 2];
1484+
int i;
1485+
if (length * 2 >= RULE_WORD_SIZE)
1486+
break;
1487+
for (i = 0; i < length; i++)
1488+
sprintf(&outbuf[i * 2], "%02X", (unsigned char)in[i]);
1489+
strcpy(in, outbuf);
1490+
length *= 2;
1491+
}
1492+
break;
1493+
1494+
case 'B': /* add byte value of X at pos N, bytewise. Format: BNX */
1495+
{
1496+
unsigned int pos;
1497+
unsigned char val;
1498+
POSITION(pos)
1499+
VALUE(val)
1500+
if (pos < length)
1501+
{
1502+
in[pos] = (unsigned char)(in[pos] + val);
1503+
}
1504+
}
1505+
break;
14391506

14401507
/* Additional "single crack" mode rules */
14411508
case '1':

0 commit comments

Comments
 (0)