Updated Subdomain Validation Code
parent
f57df62b0b
commit
3abfed25e0
|
@ -63,9 +63,12 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
}
|
||||
|
||||
// Now remove duplicate items from the slice
|
||||
unique_passive_subdomains := helper.Unique(finalPassiveSubdomains)
|
||||
fmt.Printf("\n\n[#] Total %d Unique subdomains found passively\n\n", len(unique_passive_subdomains))
|
||||
for _, subdomain := range unique_passive_subdomains {
|
||||
uniquePassiveSubdomains := helper.Unique(finalPassiveSubdomains)
|
||||
// Now, validate all subdomains found
|
||||
validPassiveSubdomains := helper.Validate(state, uniquePassiveSubdomains)
|
||||
|
||||
fmt.Printf("\n\n[#] Total %d Unique subdomains found passively\n\n", len(validPassiveSubdomains))
|
||||
for _, subdomain := range validPassiveSubdomains {
|
||||
fmt.Println(subdomain)
|
||||
}
|
||||
|
||||
|
|
|
@ -86,3 +86,16 @@ func Unique(strSlice []string) []string {
|
|||
}
|
||||
return list
|
||||
}
|
||||
|
||||
//
|
||||
// Returns unique valid subdomains found
|
||||
//
|
||||
func Validate(state *State, strslice []string) (subdomains []string) {
|
||||
for _, entry := range strslice {
|
||||
if state.Regex.MatchString(entry) == true {
|
||||
subdomains = append(subdomains, entry)
|
||||
}
|
||||
}
|
||||
|
||||
return subdomains
|
||||
}
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
package helper
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Holds the State read in from the CLI
|
||||
type State struct {
|
||||
Color bool // Whether to use color or not
|
||||
|
@ -21,6 +25,7 @@ type State struct {
|
|||
Bruteforce bool // Flag to decide whether to bruteforce or not
|
||||
WildcardIPs []string // Wildcard IP Structure
|
||||
IsWildcard bool // Does the host has wildcard subdomains, if yes parse them carefully
|
||||
Regex *regexp.Regexp // Regex object for parsing current subdomains
|
||||
|
||||
ConfigState Config // Current configuration file state
|
||||
}
|
||||
|
@ -37,5 +42,5 @@ func InitState() (state State, err error) {
|
|||
return state, err
|
||||
}
|
||||
|
||||
return State{true, 10, 180, false, "", false, "", false, []string{}, true, *config}, nil
|
||||
return State{true, 10, 180, false, "", false, "", false, []string{}, true, ®exp.Regexp{}, *config}, nil
|
||||
}
|
||||
|
|
10
main.go
10
main.go
|
@ -13,9 +13,11 @@ import (
|
|||
"fmt"
|
||||
"flag"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"subfinder/libsubfinder/helper"
|
||||
"subfinder/libsubfinder/engines/passive"
|
||||
//"subfinder/libsubfinder/engines/bruteforce"
|
||||
)
|
||||
|
||||
|
||||
|
@ -40,6 +42,8 @@ func ParseCmdLine() (state *helper.State, err error) {
|
|||
flag.IntVar(&s.Timeout, "timeout", 180, "Timeout for passive discovery services")
|
||||
flag.StringVar(&s.Domain, "d", "", "Domain to find subdomains for")
|
||||
flag.BoolVar(&s.Recursive, "r", true, "Use recursion to find subdomains")
|
||||
flag.StringVar(&s.Wordlist, "w", "", "Wordlist for doing subdomain bruteforcing")
|
||||
flag.BoolVar(&s.Bruteforce, "b", false, "Use bruteforcing to find subdomains")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -50,7 +54,7 @@ func ParseCmdLine() (state *helper.State, err error) {
|
|||
func main() {
|
||||
|
||||
fmt.Println(banner)
|
||||
fmt.Printf("\nSubFinder v0.1.0 Made with ❤ by @Ice3man")
|
||||
fmt.Printf("\nSubFinder v0.1.0 Made with %s❤%s by @Ice3man", helper.Green, helper.Reset)
|
||||
fmt.Printf("\n==================================================")
|
||||
|
||||
state, err := ParseCmdLine()
|
||||
|
@ -65,5 +69,9 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create a regex for validating subdomains found
|
||||
state.Regex, _ = regexp.Compile("(.*)."+state.Domain)
|
||||
|
||||
passive.PassiveDiscovery(state)
|
||||
//bruteforce.Bruteforce(state)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue