From e10f342e4aedda0bd37fc76a63b75073ebb45a44 Mon Sep 17 00:00:00 2001 From: QU35T-code Date: Thu, 13 Jun 2024 10:53:57 +0200 Subject: [PATCH] chore(company): Add leet flag --- README.md | 19 +++++++++++++++++++ cmd/company.go | 7 +++++++ lib/generate/generate.go | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/README.md b/README.md index 4e138da..6dd8cf5 100644 --- a/README.md +++ b/README.md @@ -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 +[...] ``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index ff1240d..092ab4e 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -20,6 +20,7 @@ var ( shortYear bool includeSpecialChars bool includeMixedCase bool + includeLeetCode bool ) var companyCmd = &cobra.Command{ @@ -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)") } @@ -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 { @@ -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 diff --git a/lib/generate/generate.go b/lib/generate/generate.go index df9f14e..08f85b7 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -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) +}