Skip to content

Commit

Permalink
chore(company): Add leet flag
Browse files Browse the repository at this point in the history
  • Loading branch information
qu35t-code committed Jun 13, 2024
1 parent 3d18c43 commit e10f342
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,23 @@ PASSFINdEr@2024?

passfinder
Passfinder
```

## Leet

```bash
> passfinder company -n passfinder --leet

[...]
p@5$f!nder
p@5$find3r
p@5$finder
p@5sf1nd3r
p@5sf1nder
p@5sf!nd3r
p@5sf!nder
p@5sfind3r
p@5sfinder
p@$5f1nd3r
[...]
```
7 changes: 7 additions & 0 deletions cmd/company.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
shortYear bool
includeSpecialChars bool
includeMixedCase bool
includeLeetCode bool
)

var companyCmd = &cobra.Command{
Expand Down Expand Up @@ -63,6 +64,7 @@ func init() {
companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations")
companyCmd.Flags().BoolVar(&startCaps, "start-caps", false, "First letter in caps")
companyCmd.Flags().BoolVar(&shortYear, "short-year", false, "Truncate the year to two digits")
companyCmd.Flags().BoolVar(&includeLeetCode, "leet", false, "Add leet code")
// companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)")
}

Expand All @@ -77,6 +79,7 @@ func generateCompanyPasslist(name, city string) []string {
yearSeparators = true
shortYear = false // We cannot have both year and shortYear
includeSpecialChars = true
includeLeetCode = true
}

if startCaps {
Expand All @@ -87,6 +90,10 @@ func generateCompanyPasslist(name, city string) []string {
wordlist = generate.WithMixedCase(wordlist)
}

if includeLeetCode {
wordlist = generate.WithLeetCode(wordlist)
}

if shortYear {
year := time.Now().Year() % 100
var separators string
Expand Down
40 changes: 40 additions & 0 deletions lib/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,43 @@ func WithStartCaps(wordlist []string) []string {
}
return wordlist
}

func WithLeetCode(wordlist []string) []string {
leetMap := map[rune][]string{
'a': {"4", "@"}, 'A': {"4", "@"},
'e': {"3"}, 'E': {"3"},
'i': {"1", "!"}, 'I': {"1", "!"},
'o': {"0"}, 'O': {"0"},
's': {"5", "$"}, 'S': {"5", "$"},
't': {"7"}, 'T': {"7"},
'l': {"1"}, 'L': {"1"},
}

for _, word := range wordlist {
leetVariations := generateLeetVariations(word, leetMap)
wordlist = append(wordlist, leetVariations...)
}

return wordlist
}

func generateLeetVariations(word string, leetMap map[rune][]string) []string {
var result []string
helperLeet(word, "", 0, &result, leetMap)
return result
}

func helperLeet(word, current string, index int, result *[]string, leetMap map[rune][]string) {
if index == len(word) {
*result = append(*result, current)
return
}

char := rune(word[index])
if leetChars, ok := leetMap[char]; ok {
for _, leetChar := range leetChars {
helperLeet(word, current+leetChar, index+1, result, leetMap)
}
}
helperLeet(word, current+string(char), index+1, result, leetMap)
}

0 comments on commit e10f342

Please sign in to comment.