Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding --city flag #20

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/company.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
includeNumbers int
includePostal int
includeAll bool
includeCity string
)

var companyCmd = &cobra.Command{
Expand All @@ -55,6 +56,7 @@ func init() {
companyCmd.Flags().StringVarP(&includeMask, "mask", "m", "", "Apply a custom mask to the passwords")
companyCmd.Flags().IntVar(&includeNumbers, "numbers", 0, "Include numbers to the passwords")
companyCmd.Flags().IntVarP(&includePostal, "postal", "p", 0, "Include postal code to the passwords")
companyCmd.Flags().StringVar(&includeCity, "city", "", "Include city name to the passwords")
companyCmd.Flags().BoolVarP(&includeAll, "all", "a", false, "Include all variations")
}

Expand Down Expand Up @@ -170,6 +172,10 @@ func generateCompanyPasslist(name string) []string {
wordlist = append(wordlist, generate.WithPostal(baseWordlist, includePostal)...)
}

if includeCity != "" {
wordlist = append(wordlist, generate.WithCity(baseWordlist, includeCity)...)
}

wordlist = append(wordlist, baseWordlist...)

transformedWordlist := wordlist
Expand Down
11 changes: 11 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,14 @@ func WithPostal(wordlist []string, includePostal int) []string {
}
return result
}

// WithCity appends the city name to each word in the wordlist
func WithCity(wordlist []string, includeCity string) []string {
var result []string

for _, word := range wordlist {
result = append(wordlist, word+includeCity)
}

return result
}