-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
158 lines (144 loc) · 5.44 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"os/exec"
"strings"
"sync"
)
var (
target string
outputfile string
verbose bool
githublink string
tools = []string{"assetfinder", "amass", "findomain", "subfinder", "crtsh", "sublist3r", "subbrute"}
)
const (
bold = "\033[1m"
normal = "\033[0m"
green = "\033[32m"
yellow = "\033[33m"
red = "\033[31m"
)
func usage() {
fmt.Printf("\n%s#########################################################%s\n", bold+green, normal)
fmt.Printf("%s# - ************ - #%s\n", bold+yellow, normal)
fmt.Printf("%s# - * Rooter Subdomain Brutforce* - #%s\n", bold+yellow, normal)
fmt.Printf("%s# - ************ - #%s\n", bold+yellow, normal)
fmt.Printf("%s# - by Shubham Rooter - #%s\n", bold+yellow, normal)
fmt.Printf("%s#########################################################%s\n\n", bold+green, normal)
fmt.Printf("Usage: %s -t <target_domain> [-o <output_file>] [-v]\n", os.Args[0])
fmt.Printf("%sOptions:%s\n", bold, normal)
fmt.Println(" -t <target_domain>: Specify the target domain (required).")
fmt.Println(" -o <output_file>: Specify the output file (default: subdomains.txt).")
fmt.Println(" -v: Enable verbose mode (print tool names and progress messages).")
fmt.Println(" -h: Display this help message.")
fmt.Printf("\n%sExample:%s\n", bold, normal)
fmt.Printf(" %s -t example.com -o results.txt -v\n\n", os.Args[0])
fmt.Printf("\n%sDescription:%s\n", bold, normal)
fmt.Println("This script performs subdomain enumeration on a target domain using various tools")
fmt.Println("and saves the results in an output file.")
fmt.Printf("\n%sGitHub:%s\n", bold, normal)
fmt.Printf("GitHub Repository: %s\n", githublink)
os.Exit(1)
}
func runTool(toolName string, command string) {
if verbose {
fmt.Printf("[%s*%s] Running %s%s%s...\n", bold, normal, bold, toolName, normal)
}
cmd := exec.Command("bash", "-c", command)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Printf("[%s-%s] %s%s%s failed.\n", bold, normal, bold, toolName, normal)
} else {
if verbose {
fmt.Printf("[%s+%s] %s%s%s completed.\n", bold, normal, bold, toolName, normal)
}
}
}
func main() {
githublink = "https://github.com/shubham-roote"
flag.StringVar(&target, "t", "", "Specify the target domain (required).")
flag.StringVar(&outputfile, "o", "subdomains.txt", "Specify the output file.")
flag.BoolVar(&verbose, "v", false, "Enable verbose mode.")
help := flag.Bool("h", false, "Display help message.")
flag.Parse()
if *help || target == "" {
usage()
}
outputFile, err := os.Create(outputfile)
if err != nil {
log.Fatalf("[%s-%s] Unable to create output file: %v\n", bold, normal, err)
}
defer outputFile.Close()
var wg sync.WaitGroup
wg.Add(len(tools))
for _, tool := range tools {
switch tool {
case "assetfinder":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("assetfinder --subs-only %s", target))
}()
case "amass":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("amass enum -timeout 2 -passive -d %s", target))
}()
case "findomain":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("findomain --quiet -t %s", target))
}()
case "subfinder":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("subfinder -d %s -o %s", target, outputfile))
}()
case "crtsh":
go func() {
defer wg.Done()
response, err := http.Get(fmt.Sprintf("https://crt.sh/?q=%%25.%s", target))
if err != nil {
fmt.Printf("[%s-%s] Failed to fetch crt.sh data: %v\n", bold, normal, err)
return
}
defer response.Body.Close()
reader := bufio.NewReader(response.Body)
for {
line, err := reader.ReadString('\n')
if err == io.EOF {
break
}
if strings.Contains(line, target) {
subdomain := strings.TrimSpace(line)
outputFile.WriteString(subdomain + "\n")
}
}
}()
case "sublist3r":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("sublist3r -d %s -o %s", target, outputfile))
}()
case "subbrute":
go func() {
defer wg.Done()
runTool(tool, fmt.Sprintf("subbrute -t 5 %s", target))
}()
}
}
wg.Wait()
// Deduplicate and sort the subdomains
cmd := exec.Command("sort", "-u", "-o", outputfile, outputfile)
if err := cmd.Run(); err != nil {
fmt.Printf("[%s-%s] Error sorting subdomains: %v\n", bold, normal, err)
}
fmt.Printf("\n%s[*] Subdomain enumeration completed.%s Results saved to %s\n", bold+green, normal, outputfile)
}