Skip to content

Commit

Permalink
Added threads and concurrency.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjoe41 committed Jan 10, 2022
1 parent 09b2282 commit 7aa0652
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This list can be used for further bruteforcing for more subdomains.
## Install
To install:

```text
```
go install -v github.com/kenjoe41/goSubsWordlist@latest
```

Expand Down
88 changes: 53 additions & 35 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ import (
func main() {

// Include the Root Domain names in words
includeRoot := flag.Bool("iR", false, "Include root domain names in wordlist.")
help := flag.Bool("h", false, "Print the help.")
var includeRoot bool
flag.BoolVar(&includeRoot, "iR", false, "Include root domain names in wordlist.")

// Concurrency flag
var concurrency int
flag.IntVar(&concurrency, "t", 20, "Threads for concurrency. Default is 20.")

// Print help message
var help bool
flag.BoolVar(&help, "h", false, "Print the help.")

flag.Parse()

// Print help message
if *help {
if help {
output.PrintHelp()
os.Exit(0)
}
Expand All @@ -34,50 +42,60 @@ func main() {

// Domain Input worker
var domainsWG sync.WaitGroup
domainsWG.Add(1)
go func() {
for inDomain := range domains {
inDomain = strings.TrimSpace(strings.ToLower(inDomain))
for i := 0; i < concurrency/2; i++ {

domain := utils.CleanDomain(inDomain)
domainsWG.Add(1)

if domain == "" {
// Log something but continue to next domain if available
// log.Printf("Failed to get domain from: %s", domain)
continue
}
go func() {
for inDomain := range domains {
inDomain = strings.TrimSpace(strings.ToLower(inDomain))

subdomain := utils.ExtractSubdomain(domain, *includeRoot)
domain := utils.CleanDomain(inDomain)

if subdomain == "" {
// Log something but continue to next domain if available
// log.Printf("Failed to get subdomain for domain: %s", domain)
continue
}
if domain == "" {
// Log something but continue to next domain if available
// log.Printf("Failed to get domain from: %s", domain)
continue
}

subdomains <- subdomain
subdomain := utils.ExtractSubdomain(domain, includeRoot)

}
domainsWG.Done()
}()
if subdomain == "" {
// Log something but continue to next domain if available
// log.Printf("Failed to get subdomain for domain: %s", domain)
continue
}

subdomains <- subdomain

}
domainsWG.Done()
}()
}

var subdomainsWG sync.WaitGroup
subdomainsWG.Add(1)
go func() {
for inSubdomains := range subdomains {

// Split the subdomain into separate words by the '.' char.
// Returns slice of words.
subWords := utils.SplitSubToWords(inSubdomains)
for i := 0; i < concurrency/2; i++ {

subdomainsWG.Add(1)

go func() {
for inSubdomains := range subdomains {

// Split the subdomain into separate words by the '.' char.
// Returns slice of words.
subWords := utils.SplitSubToWords(inSubdomains)

// Print to console for now
for _, subword := range subWords {
output <- subword
}

// Print to console for now
for _, subword := range subWords {
output <- subword
}
subdomainsWG.Done()
}()

}
subdomainsWG.Done()
}()
}

// Close subdomains channel when done reading from domains chan.
go func() {
Expand Down
4 changes: 3 additions & 1 deletion output/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import "fmt"
func PrintHelp() {
Beautify()
fmt.Println(`Usage of goSubsWordlist:
-iR bool
-iR Bool
Include Root Domain names in wordlist output.
-t Int
Threads for Concurrency. Default is 8.
-help
Print this help message.`)
}

0 comments on commit 7aa0652

Please sign in to comment.