-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathmain.go
206 lines (159 loc) · 5.74 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package main
// an early version of cloud brute plugin for HunterSuite.io
import (
"fmt"
engine "github.com/0xsha/cloudbrute/internal"
"github.com/akamensky/argparse"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"io/ioutil"
"os"
"path"
)
func main() {
// parse arguments
parser := argparse.NewParser("CloudBrute", "Awesome Cloud Enumerator")
domain := parser.String("d", "domain",
&argparse.Options{
Required: true,
Help: "domain"})
keyword := parser.String("k", "keyword",
&argparse.Options{
Required: true,
Help: "keyword used to generator urls"})
wordList := parser.String("w", "wordlist",
&argparse.Options{
Required: true,
Help: "path to wordlist"})
useProvider := parser.String("c", "cloud",
&argparse.Options{
Required: false,
Help: "force a search, check config.yaml providers list"})
threads := parser.Int("t", "threads",
&argparse.Options{
Required: false,
Help: "number of threads",
Default: 80})
timeout := parser.Int("T", "timeout",
&argparse.Options{
Required: false,
Help: "timeout per request in seconds",
Default: 10})
useProxy := parser.String("p", "proxy",
&argparse.Options{
Required: false,
Help: "use proxy list"})
useAgents := parser.String("a", "randomagent",
&argparse.Options{
Required: false,
Help: "user agent randomization"})
debug := parser.Flag("D", "debug",
&argparse.Options{
Required: false,
Help: "show debug logs",
Default: false})
quite := parser.Flag("q", "quite",
&argparse.Options{
Required: false,
Help: "suppress all output",
Default: false})
mode := parser.String("m", "mode",
&argparse.Options{
Required: false,
Default: "storage",
Help: "storage or app"})
output := parser.String("o", "output",
&argparse.Options{
Default: "out.txt",
Required: false,
Help: "Output file"})
configFolder := parser.String("C", "configFolder",
&argparse.Options{
Default: "config",
Required: false,
Help: "Config path"})
err := parser.Parse(os.Args)
if err != nil {
fmt.Print(parser.Usage(err))
return
}
//banner
banner := ` ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗
██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗██╔══██╗██╔══██╗██║ ██║╚══██╔══╝██╔════╝
██║ ██║ ██║ ██║██║ ██║██║ ██║██████╔╝██████╔╝██║ ██║ ██║ █████╗
██║ ██║ ██║ ██║██║ ██║██║ ██║██╔══██╗██╔══██╗██║ ██║ ██║ ██╔══╝
╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝██████╔╝██║ ██║╚██████╔╝ ██║ ███████╗
╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝
V 1.0.7
`
if !*quite {
_, _ = fmt.Fprintf(os.Stderr, banner)
}
// beautify the results
if !*quite {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.SetGlobalLevel(zerolog.InfoLevel)
} else {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: ioutil.Discard})
zerolog.SetGlobalLevel(zerolog.PanicLevel)
}
// check mode
if *mode != "storage" && *mode != "app" {
log.Fatal().Msg("Invalid mode use app or storage")
}
// initialize config.yaml
configPath := path.Join(*configFolder, "config.yaml")
providerPath := path.Join(*configFolder, "modules")
log.Info().Msg(fmt.Sprintf("Detect config path: %s", configPath))
log.Info().Msg(fmt.Sprintf("Detect provider path: %s", providerPath))
config := engine.InitConfig(configPath)
apiKey := config.IPInfo
log.Info().Msg("Initialized scan config")
if *debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
// check out args
var details engine.RequestDetails
if *useAgents != "" {
userAgents, err := engine.ReadTextFile(*useAgents)
if err != nil {
log.Fatal().Err(err).Msg("Can't read agents file, check config.yaml")
}
details.RandomAgent = userAgents
}
if *useProxy != "" {
proxyList, err := engine.ReadTextFile(*useProxy)
if err != nil {
log.Fatal().Err(err).Msg("Can't read proxy file , check config.yaml")
}
details.ProxyList = proxyList
details.ProxyType = config.ProxyType
}
var cloud string
if *useProvider != "" {
cloud = *useProvider
} else {
// Detect the cloud using ip info
cloud, err = engine.CloudDetectIP(*domain, apiKey)
if err != nil {
log.Error().Err(err).Msg("IP detection failed")
}
}
// Do we support the provider?
provider, err := engine.CheckSupportedCloud(cloud, config)
if err != nil {
log.Warn().Msg("IP detection failed")
// Detect the cloud from HTML and JavaScript source codes
provider, err = engine.CloudDetectHTML(*domain, config , providerPath)
if err != nil {
log.Fatal().Err(err).Msg("Source detection failed as well use -c .")
}
}
log.Info().Msg(provider + " detected")
urls, err := engine.GenerateMutatedUrls(*wordList, *mode, provider, providerPath, *keyword, config.Environments)
if err != nil {
log.Fatal().Err(err).Msg("Exiting...")
}
//output := engine.GenerateOutputName(*keyword)
engine.AsyncHTTPHead(urls, *threads, *timeout, details, *output)
}