hashcat-rules-js

September 23, 2025 · View on GitHub

An implementation of the hashcat rules engine in JavaScript. More information about rule-based attacks and the rules themselves can be found on the Hashcat wiki.

Installation

npm install hashcat-rules-js

Compiles and minifies for production

npm run build

Usage

const hashcatRule = require('hashcat-rules-js');
const password="hashcat";
const rule="\$1";
const result= hashcatRule.applyRule(password,rule)

Parameters

The applyRule function takes the following options:

  • password (required): The password to which the rules will be applied.
  • rule (required): Rules compatible with the Hashcat rules engine.

Return Value

The applyRule function returns a string with the applied rules.

  • if rule is an empty string, false will be returned
  • if rule starts with # (hash), false will be returned

Example

const hashcatRule = require('hashcat-rules-js');
const result= hashcatRule.applyRule("hashcat","\$1")
console.log(result);//hashcat1

Rules and output

NameFunctionDescriptionExample RuleInput WordOutput Word
Nothing:Do nothing (passthrough):p@ssW0rdp@ssW0rd
LowercaselLowercase all letterslp@ssW0rdp@ssw0rd
UppercaseuUppercase all lettersup@ssW0rdP@SSW0RD
CapitalizecCapitalize the first letter and lower the restcp@ssW0rdP@ssw0rd
Invert CapitalizeCLowercase first found character, uppercase the restCp@ssW0rdp@SSW0RD
Toggle CasetToggle the case of all characters in word.tp@ssW0rdP@SSw0RD
Toggle @TNToggle the case of characters at position NT3p@ssW0rdp@sSW0rd
ReverserReverse the entire wordrp@ssW0rddr0Wss@p
DuplicatedDuplicate entire worddp@ssW0rdp@ssW0rdp@ssW0rd
Duplicate NpNAppend duplicated word N timesp2p@ssW0rdp@ssW0rdp@ssW0rdp@ssW0rd
ReflectfDuplicate word reversedfp@ssW0rdp@ssW0rddr0Wss@p
Rotate Left{Rotate the word left.{p@ssW0rd@ssW0rdp
Rotate Right}Rotate the word right}p@ssW0rddp@ssW0r
Append Character$XAppend character X to end$1p@ssW0rdp@ssW0rd1
Prepend Character^XPrepend character X to front^1p@ssW0rd1p@ssW0rd
Truncate left[Delete first character[p@ssW0rd@ssW0rd
Trucate right]Delete last character]p@ssW0rdp@assW0r
Delete @ NDNDelete character at position ND3p@ssW0rdp@sW0rd
Extract rangexNMExtract M characters, starting at position Nx04p@ssW0rdp@ss
Omit rangeONMDelete M characters, starting at position NO12p@ssW0rdpsW0rd
Insert @ NiNXInsert character X at position Ni4!p@ssW0rdp@ss!W0rd
Overwrite @ NoNXOverwrite character at position N with Xo3$p@ssW0rdp@s$W0rd
Truncate @ N'NTruncate word at position N'6p@ssW0rdp@ssW0
ReplacesXYReplace all instances of X with Yss$p@ssW0rdp@$$W0rd
Purge@XPurge all instances of X@sp@ssW0rdp@W0rd
Duplicate first NzNDuplicate first character N timesz2p@ssW0rdppp@ssW0rd
Duplicate last NZNDuplicate last character N timesZ2p@ssW0rdp@ssW0rddd
Duplicate allqDuplicate every characterqp@ssW0rdpp@@ssssWW00rrdd
Swap frontkSwap first two characterskp@ssW0rd@pssW0rd
Swap backKSwap last two charactersKp@ssW0rdp@ssW0dr
Swap @ N*NMSwap character at position N with character at position M*34p@ssW0rdp@sWs0rd
Bitwise shift leftLNBitwise shift left character @ NL2p@ssW0rdp@æsW0rd
Bitwise shift rightRNBitwise shift right character @ NR2p@ssW0rdp@9sW0rd
ASCII increment+NIncrement character @ N by 1 ascii value+2p@ssW0rdp@tsW0rd
ASCII decrement-NDecrement character @ N by 1 ascii value-1p@ssW0rdp?ssW0rd
Replace N + 1.NReplace character @ N with value at @ N plus 1.1p@ssW0rdpsssW0rd
Replace N - 1,NReplace character @ N with value at @ N minus 1,1p@ssW0rdppssW0rd
Duplicate block frontyNDuplicate first N charactersy2p@ssW0rdp@p@ssW0rd
Duplicate block backYNDuplicate last N charactersY2p@ssW0rdp@ssW0rdrd
TitleELower case the whole line, then upper case the first letter and every letter after a spaceEp@ssW0rdP@ssw0rd W0rld
Title w/separatoreLower case the whole line, then upper case the first letter and every letter after a custom separator charactere-p@ssW0rdP@ssw0rd-W0rld