Skip to content

Commit 16bf075

Browse files
committed
Refactor whitespace in main.go, main_test.go, and wordlist-gen.go for improved readability and consistency. Cleaned up unnecessary blank lines and ensured proper formatting throughout the files.
1 parent 9eaa780 commit 16bf075

File tree

3 files changed

+51
-51
lines changed

3 files changed

+51
-51
lines changed

main.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// IMPORTANT LEGAL NOTICE:
66
// This tool is provided for educational and legitimate security testing purposes ONLY.
7-
// Usage of this tool against any domain without explicit permission from the domain
7+
// Usage of this tool against any domain without explicit permission from the domain
88
// owner may violate applicable local, national, and/or international laws.
99
//
1010
// Users MUST:
@@ -82,7 +82,7 @@ func main() {
8282
fmt.Println("Error: Concurrency level (-t) must be greater than 0")
8383
os.Exit(1)
8484
}
85-
85+
8686
if *timeoutMs <= 0 {
8787
fmt.Println("Error: Timeout (-timeout) must be greater than 0")
8888
os.Exit(1)
@@ -145,10 +145,10 @@ func main() {
145145
if err := scanner.Err(); err != nil {
146146
fmt.Printf("Error counting wordlist lines: %v\n", err)
147147
}
148-
148+
149149
// Reset file position to beginning
150150
file.Seek(0, 0)
151-
151+
152152
if *verbose {
153153
fmt.Printf("Total wordlist entries: %d\n", totalWords)
154154
}
@@ -174,12 +174,12 @@ func main() {
174174
processed := atomic.LoadInt64(&processedWords)
175175
found := atomic.LoadInt64(&foundSubdomains)
176176
progress := float64(processed) / float64(totalWords) * 100
177-
fmt.Printf("\rProgress: %.1f%% (%d/%d) | Found: %d ",
177+
fmt.Printf("\rProgress: %.1f%% (%d/%d) | Found: %d ",
178178
progress, processed, totalWords, found)
179179
}
180180
}
181181
}()
182-
182+
183183
// Clean up the progress goroutine when main() exits
184184
defer func() {
185185
done <- true
@@ -196,15 +196,15 @@ func main() {
196196
for subdomainPrefix := range subdomains {
197197
fullDomain := subdomainPrefix + "." + domain
198198
var resolved bool
199-
199+
200200
if *testMode {
201201
// In test mode, simulate DNS resolution without actual queries
202202
resolved = simulateResolution(fullDomain, *testHitRate, *verbose)
203203
} else {
204204
// In normal mode, perform actual DNS resolution
205205
resolved = resolveDomain(fullDomain, timeout, *dnsServer, *verbose)
206206
}
207-
207+
208208
if resolved {
209209
if *testMode {
210210
fmt.Printf("Found (SIMULATED): %s\n", fullDomain)
@@ -230,7 +230,7 @@ func main() {
230230

231231
close(subdomains)
232232
wg.Wait()
233-
233+
234234
// Final summary
235235
if *verbose {
236236
fmt.Printf("\nScan completed for %s\n", domain)
@@ -240,7 +240,7 @@ func main() {
240240
fmt.Printf("simulated ")
241241
}
242242
fmt.Printf("subdomains\n")
243-
243+
244244
if *testMode {
245245
fmt.Println("\nNOTE: Results were simulated and no actual DNS queries were performed.")
246246
fmt.Println("This mode is intended for educational and testing purposes only.")
@@ -253,11 +253,11 @@ func main() {
253253
func simulateResolution(domain string, hitRate int, verbose bool) bool {
254254
// Always resolve common subdomains for more realistic simulation
255255
commonSubdomains := []string{
256-
"www", "mail", "ftp", "blog",
257-
"api", "dev", "staging", "test",
256+
"www", "mail", "ftp", "blog",
257+
"api", "dev", "staging", "test",
258258
"admin", "portal", "app", "secure",
259259
}
260-
260+
261261
for _, sub := range commonSubdomains {
262262
if strings.HasPrefix(domain, sub+".") {
263263
// Simulate a successful lookup for these common subdomains
@@ -270,10 +270,10 @@ func simulateResolution(domain string, hitRate int, verbose bool) bool {
270270
return rand.Intn(100) < 90
271271
}
272272
}
273-
273+
274274
// For other subdomains, use the hit rate to determine if they resolve
275275
result := rand.Intn(100) < hitRate
276-
276+
277277
if verbose {
278278
fakeTiming := time.Duration(100+rand.Intn(500)) * time.Millisecond
279279
if result {
@@ -283,7 +283,7 @@ func simulateResolution(domain string, hitRate int, verbose bool) bool {
283283
fmt.Printf("Failed to resolve (SIMULATED): %s (Error: no such host) in %s\n", domain, fakeTiming)
284284
}
285285
}
286-
286+
287287
return result
288288
}
289289

@@ -297,16 +297,16 @@ func resolveDomain(domain string, timeout time.Duration, dnsServer string, verbo
297297
return d.DialContext(ctx, "udp", dnsServer)
298298
},
299299
}
300-
300+
301301
start := time.Now()
302302
ips, err := resolver.LookupHost(context.Background(), domain)
303303
elapsed := time.Since(start)
304-
304+
305305
if verbose && err == nil {
306306
fmt.Printf("Resolved: %s (IP: %s) in %s\n", domain, ips[0], elapsed)
307307
} else if verbose {
308308
fmt.Printf("Failed to resolve: %s (Error: %v) in %s\n", domain, err, elapsed)
309309
}
310-
310+
311311
return err == nil
312-
}
312+
}

main_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ func TestResolveDomain(t *testing.T) {
4949
for _, tt := range tests {
5050
t.Run(tt.name, func(t *testing.T) {
5151
got := resolveDomain(tt.domain, timeout)
52-
52+
5353
// Note: DNS results can be unpredictable depending on the network environment
5454
// If this test fails, it might be due to network issues or DNS changes
5555
if got != tt.expected {
56-
t.Logf("Warning: DNS resolution result for %s was %v, expected %v",
56+
t.Logf("Warning: DNS resolution result for %s was %v, expected %v",
5757
tt.domain, got, tt.expected)
5858
t.Logf("This might be due to network conditions or DNS changes")
59-
59+
6060
// Commented out the actual failure to make the test more robust
6161
// Uncomment to enforce strict testing
6262
// t.Errorf("resolveDomain(%s) = %v, want %v", tt.domain, got, tt.expected)
@@ -74,10 +74,10 @@ func TestResolveDomainTimeout(t *testing.T) {
7474

7575
// Use a very short timeout that should cause the lookup to time out
7676
veryShortTimeout := time.Millisecond * 1
77-
77+
7878
// This should time out and return false, regardless of whether the domain exists
7979
result := resolveDomain("google.com", veryShortTimeout)
80-
80+
8181
// We expect this to time out and return false
8282
// However, on some very fast networks, this might still succeed
8383
if result == true {
@@ -97,20 +97,20 @@ func TestResolveDomainWithCustomDNS(t *testing.T) {
9797

9898
// Set a reasonable timeout for tests
9999
timeout := time.Second * 2
100-
100+
101101
// Define DNS servers to test
102102
dnsServers := []string{
103-
"8.8.8.8:53", // Google
104-
"1.1.1.1:53", // Cloudflare
103+
"8.8.8.8:53", // Google
104+
"1.1.1.1:53", // Cloudflare
105105
}
106-
106+
107107
// A domain that should definitely resolve
108108
testDomain := "google.com"
109-
109+
110110
for _, server := range dnsServers {
111111
t.Run(fmt.Sprintf("DNS_Server_%s", server), func(t *testing.T) {
112112
result := resolveDomain(testDomain, timeout, server, false)
113-
113+
114114
if !result {
115115
t.Logf("Warning: Failed to resolve %s using DNS server %s", testDomain, server)
116116
t.Logf("This might be due to network conditions or DNS configuration")
@@ -125,32 +125,32 @@ func TestResolveDomainWithCustomDNS(t *testing.T) {
125125
func TestDNSServerValidation(t *testing.T) {
126126
// This test doesn't actually call any functions directly,
127127
// but it checks the validation logic we'd want to apply to DNS server strings
128-
128+
129129
validServers := []string{
130130
"8.8.8.8:53",
131131
"1.1.1.1:53",
132132
"192.168.1.1:53",
133133
"[2001:4860:4860::8888]:53", // IPv6
134134
}
135-
135+
136136
invalidServers := []string{
137-
"8.8.8.8", // Missing port
138-
":53", // Missing IP
139-
"localhost", // Not in IP:port format
140-
"256.1.1.1:53", // Invalid IP
141-
"1.1.1.1:99999" // Invalid port
137+
"8.8.8.8", // Missing port
138+
":53", // Missing IP
139+
"localhost", // Not in IP:port format
140+
"256.1.1.1:53", // Invalid IP
141+
"1.1.1.1:99999", // Invalid port
142142
}
143-
143+
144144
for _, server := range validServers {
145145
if !strings.Contains(server, ":") {
146146
t.Errorf("DNS server validation should pass for %s but would fail with our check", server)
147147
}
148148
}
149-
149+
150150
for _, server := range invalidServers {
151151
if strings.Contains(server, ":") && server != ":53" {
152152
t.Logf("Simple validation would pass for invalid server: %s", server)
153153
t.Logf("Consider implementing more thorough validation")
154154
}
155155
}
156-
}
156+
}

tools/wordlist-gen.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2025 TM Hospitality Strategies
2-
//
2+
//
33
// Tool for generating custom wordlists for subdomain enumeration
44
// Educational purposes only
55

@@ -64,23 +64,23 @@ func main() {
6464
// Process domain-specific terms if provided
6565
if *domainInfo != "" {
6666
fmt.Printf("Extracting terms from domain: %s\n", *domainInfo)
67-
67+
6868
// Remove TLD and split by separators
6969
domain := *domainInfo
70-
70+
7171
// Remove common TLDs
7272
domain = strings.TrimSuffix(domain, ".com")
7373
domain = strings.TrimSuffix(domain, ".org")
7474
domain = strings.TrimSuffix(domain, ".net")
7575
domain = strings.TrimSuffix(domain, ".edu")
7676
domain = strings.TrimSuffix(domain, ".gov")
7777
domain = strings.TrimSuffix(domain, ".io")
78-
78+
7979
// Split by common separators
8080
parts := strings.FieldsFunc(domain, func(r rune) bool {
8181
return r == '.' || r == '-' || r == '_'
8282
})
83-
83+
8484
for _, part := range parts {
8585
if len(part) > 2 && !addedWords[part] { // Only add if length > 2
8686
fmt.Fprintln(writer, part)
@@ -94,27 +94,27 @@ func main() {
9494
if *combineWith != "" {
9595
prefixes := strings.Split(*combineWith, ",")
9696
fmt.Printf("Combining with prefixes: %v\n", prefixes)
97-
97+
9898
// Create a temporary copy of addedWords to iterate over
9999
wordsCopy := make([]string, 0, len(addedWords))
100100
for word := range addedWords {
101101
wordsCopy = append(wordsCopy, word)
102102
}
103-
103+
104104
// Create combinations
105105
for _, prefix := range prefixes {
106106
prefix = strings.TrimSpace(prefix)
107107
if prefix == "" {
108108
continue
109109
}
110-
110+
111111
// Add the prefix itself
112112
if !addedWords[prefix] {
113113
fmt.Fprintln(writer, prefix)
114114
addedWords[prefix] = true
115115
fmt.Printf("Added: %s\n", prefix)
116116
}
117-
117+
118118
// Create combinations with existing words
119119
for _, word := range wordsCopy {
120120
combination := prefix + "-" + word
@@ -130,4 +130,4 @@ func main() {
130130
// Count total words
131131
fmt.Printf("\nWordlist generated at %s with %d unique entries\n", *outputFile, len(addedWords))
132132
fmt.Println("\nNOTE: Only use this tool to generate wordlists for domains you have explicit permission to test.")
133-
}
133+
}

0 commit comments

Comments
 (0)