From acdf9c1be4abe272069296e6e4f7cb6d6f178931 Mon Sep 17 00:00:00 2001 From: ice3man Date: Sun, 8 Apr 2018 13:50:16 +0530 Subject: [PATCH] Added Text Output Feature --- libsubfinder/output/output.go | 36 +++++++++++++++++++++++++++++++++++ main.go | 14 +++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 libsubfinder/output/output.go diff --git a/libsubfinder/output/output.go b/libsubfinder/output/output.go new file mode 100644 index 0000000..f614e21 --- /dev/null +++ b/libsubfinder/output/output.go @@ -0,0 +1,36 @@ +// +// output.go : Contains different functions for reporting +// Written By : @ice3man (Nizamul Rana) +// +// Distributed Under MIT License +// Copyrights (C) 2018 Ice3man +// + +package output + +import ( + "os" + "io" + + "subfinder/libsubfinder/helper" +) + +// Write output to a normal text file +func WriteOutputText(state *helper.State, subdomains []string) error { + file, err := os.Create(state.Output) + + if err != nil { + return err + } + + for _, subdomain := range subdomains { + _, err := io.WriteString(file, subdomain+"\n") + if err != nil { + return err + } + } + + file.Close() + + return nil +} \ No newline at end of file diff --git a/main.go b/main.go index 94ad4a6..9184a57 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "os" "subfinder/libsubfinder/helper" + "subfinder/libsubfinder/output" "subfinder/libsubfinder/engines/passive" //"subfinder/libsubfinder/engines/bruteforce" ) @@ -40,6 +41,8 @@ func ParseCmdLine() (state *helper.State, err error) { flag.IntVar(&s.Threads, "t", 10, "Number of concurrent threads") flag.IntVar(&s.Timeout, "timeout", 180, "Timeout for passive discovery services") flag.StringVar(&s.Domain, "d", "", "Domain to find subdomains for") + flag.StringVar(&s.Output, "o", "", "Name of the output file (optional)") + flag.BoolVar(&s.IsJSON, "oJ", false, "Write output in JSON Format") 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") @@ -68,6 +71,15 @@ func main() { os.Exit(1) } - passive.PassiveDiscovery(state) + passiveSubdomains := passive.PassiveDiscovery(state) + if state.Output != "" { + err := output.WriteOutputText(state, passiveSubdomains) + if err != nil { + fmt.Printf("\nerror : %v", err) + } else { + fmt.Printf("\n[#] Successfully Written Output to File : %s", state.Output) + } + } + //bruteforce.Bruteforce(state) }