-
Notifications
You must be signed in to change notification settings - Fork 123
/
main.go
113 lines (96 loc) · 2.57 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
package main
import (
"bufio"
"flag"
"fmt"
"os"
"strconv"
"strings"
"github.com/logrusorgru/aurora/v3"
log "github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
)
func init() {
flag.StringVar(&query, "q", "", "")
flag.StringVar(&query, "query", "", "")
flag.StringVar(&engine, "e", "", "")
flag.StringVar(&engine, "engine", "google", "")
flag.IntVar(&page, "p", 1, "")
flag.IntVar(&page, "page", 1, "")
flag.Var(&headers, "header", "")
flag.Var(&headers, "H", "")
flag.StringVar(&proxy, "x", "", "")
flag.StringVar(&proxy, "proxy", "", "")
flag.BoolVar(&silent, "s", false, "")
flag.BoolVar(&silent, "silent", false, "")
flag.Usage = func() {
h := []string{
"Options:",
" -q, --query <query> Search query",
" -e, --engine <engine> Provide search engine (default: Google)",
" (options: Google, Shodan, Bing, Duck, Yahoo, Ask)",
" -p, --page <i> Specify number of pages (default: 1)",
" -H, --header <header> Pass custom header to search engine",
" -x, --proxy <proxy_url> Use proxy to surfing (HTTP/SOCKSv5 proxy)",
" -s, --silent Silent mode",
"\n",
}
showBanner()
fmt.Fprintf(os.Stderr, "%s", aurora.Green(strings.Join(h, "\n")))
}
flag.Parse()
engine = strings.ToLower(engine)
maxLog := levels.LevelDebug
if silent {
maxLog = levels.LevelSilent
}
log.DefaultLogger.SetMaxLevel(maxLog)
showBanner()
}
func main() {
if isStdin() {
sc := bufio.NewScanner(os.Stdin)
for sc.Scan() {
q := sc.Text()
queries = append(queries, q)
}
} else {
if query == "" {
log.Fatal().Msgf("Missing required -q flag!")
os.Exit(2)
}
queries = []string{query}
}
log.Info().Msgf("Query : %+v", queries)
log.Info().Msgf("Page : %s", strconv.Itoa(page))
if proxy != "" {
log.Info().Msgf("Proxy : %s", proxy)
}
if len(headers) > 0 {
log.Info().Msgf("Header: [%+v]", headers)
}
log.Info().Msgf("Engine: %s", strings.Title(engine))
log.Warning().Msg("Use at your own risk! Developers assume no responsibility...")
log.Warning().Msg("If your IP address has been blocked by search engine providers or other reason.\n\n")
for _, q := range queries {
wg.Add(1)
go func(dork string) {
defer wg.Done()
opts := options{
Query: dork,
Engine: engine,
Page: page,
Proxy: proxy,
Headers: headers,
}
fatal, err := opts.search()
if err != nil {
if fatal {
isError(err)
}
log.Warning().Msgf("Something error %s.", err.Error())
}
}(q)
}
wg.Wait()
}