-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
97 lines (74 loc) · 1.97 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
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"github.com/alecthomas/kingpin"
)
var (
app = kingpin.New("rapiddns", "RapidDNS Scraping tool.")
search = app.Command("search", "Search by word.")
searchWord = search.Flag("word", "Word to find").Required().String()
sameIP = app.Command("sameip", "Search by IP address, CIDR.")
sameIPAdress = sameIP.Flag("address", "Address or CIDR to find").Required().String()
subdomain = app.Command("subdomain", "Search by Subdomain.")
subdomainDomain = subdomain.Flag("domain", "domain to find").Required().String()
)
func main() {
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
case search.FullCommand():
if searchWord != nil {
prov := SearchScraperProvider[SearchResult]{}
c := SearchClient{searchWord, nil, &prov}
rerult := c.Search()
c.Result = &rerult
if c.Result == nil {
log.Fatalln("Search has not completed")
}
bytes, err := json.Marshal(c.Result)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(bytes))
return
}
fmt.Println(app.Help)
case sameIP.FullCommand():
if sameIPAdress != nil {
prov := SameIPScraperProvider[SameIpResult]{}
c := SameIPClient{sameIPAdress, nil, &prov}
rerult := c.Search()
c.Result = &rerult
if c.Result == nil {
log.Fatalln("Search same IP has not completed")
}
bytes, err := json.Marshal(c.Result)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(bytes))
return
}
fmt.Println(app.Help)
case subdomain.FullCommand():
if subdomainDomain != nil {
prov := SubdomainScraperProvider[SubdomainResult]{}
c := SubdomainClient{subdomainDomain, nil, &prov}
rerult := c.Search()
c.Result = &rerult
if c.Result == nil {
log.Fatalln("Search same IP has not completed")
}
bytes, err := json.Marshal(c.Result)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(bytes))
return
}
fmt.Println(app.Help)
default:
fmt.Println(app.Help)
}
}