Skip to content

Commit

Permalink
feat(company): Add short year flag
Browse files Browse the repository at this point in the history
  • Loading branch information
qu35t-code committed Jun 13, 2024
1 parent 1b378a9 commit b027831
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ PAsSfiNder
passfinder2024
```

## year-separator
## Short year

```bash
> passfinder company -n passfinder --short-year

passfinder
passfinder24
```

## year-separators

```bash
> passfinder company -n passfinder --year --year-separators
Expand All @@ -77,11 +86,28 @@ passfinder?2024
passfinder=2024
```

```bash
> passfinder company -n passfinder --short-year --year-separators

passfinder
passfinder24
passfinder!24
passfinder@24
passfinder#24
passfinder$24
passfinder%24
passfinder+24
passfinder?24
passfinder=24
passfinder*24
```

## all

```bash
> passfinder company -n passfinder --all

[...]
PASSFINdEr!2024?
PASSFINdEr!2024=
PASSFINdEr!2024*
Expand All @@ -92,6 +118,7 @@ PASSFINdEr@2024$
PASSFINdEr@2024%
PASSFINdEr@2024+
PASSFINdEr@2024?
[...]
```

## Start caps
Expand All @@ -101,5 +128,4 @@ PASSFINdEr@2024?

passfinder
Passfinder
```

```
29 changes: 22 additions & 7 deletions cmd/company.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/GoToolSharing/passfinder/lib/generate"
"github.com/GoToolSharing/passfinder/lib/utils"
"github.com/spf13/cobra"
)

Expand All @@ -16,6 +17,7 @@ var (
includeYear bool
includeAllPermutations bool
startCaps bool
shortYear bool
// includeCity bool
// includeAcronym bool
includeSpecialChars bool
Expand All @@ -31,16 +33,19 @@ var companyCmd = &cobra.Command{
Long: `Generate a passlist based on company name, current year, city, and other relevant information.`,
Run: func(cmd *cobra.Command, args []string) {

if !includeYear && yearSeparators {
fmt.Println("You cannot use --year-separators without --year")
if (!includeYear && !shortYear) && yearSeparators {
fmt.Println("You cannot use --year-separators without --year or --short-year")
return
}

year := time.Now().Year()
if includeYear && shortYear {
fmt.Println("You cannot use both --year and --short-year")
return
}

wordlist := generateCompanyPasslist(companyName, city, year)
wordlist := generateCompanyPasslist(companyName, city)

// TODO: Remove duplicates
wordlist = utils.RemoveDuplicates(wordlist)
for _, password := range wordlist {
fmt.Println(password)
}
Expand All @@ -57,16 +62,16 @@ func init() {
}
// companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company")
companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords")
// companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords")
companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include mixed case variations")
companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year")
companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords")
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(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)")
}

func generateCompanyPasslist(name, city string, year int) []string {
func generateCompanyPasslist(name, city string) []string {
var wordlist []string

wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist
Expand Down Expand Up @@ -112,7 +117,17 @@ func generateCompanyPasslist(name, city string, year int) []string {
wordlist = generate.WithMixedCase(wordlist)
}

if shortYear {
year := time.Now().Year() % 100
var separators string
if yearSeparators {
separators = "!@#$%+?=*"
}
wordlist = generate.WithYearAndSeparators(wordlist, year, separators)
}

if includeYear {
year := time.Now().Year()
var separators string
if yearSeparators {
separators = "!@#$%+?=*"
Expand Down
4 changes: 1 addition & 3 deletions lib/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package generate
import (
"fmt"
"strings"

"github.com/GoToolSharing/passfinder/lib/utils"
)

func WithSpecialChars(wordlist []string) []string {
Expand All @@ -23,7 +21,7 @@ func WithMixedCase(wordlist []string) []string {
caseVariations := generateCaseVariations(word)
wordlist = append(wordlist, caseVariations...)
}
return utils.RemoveDuplicates(wordlist)
return wordlist
}

func generateCaseVariations(word string) []string {
Expand Down

0 comments on commit b027831

Please sign in to comment.