-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
154 lines (139 loc) · 4.7 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
package main
/*
* Dork Seacrher Project
* By https://github.com/aDarkDev/
*
*/
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strconv"
"strings"
)
func main() {
showBanner()
var dork, engine string
var save bool
flag.StringVar(&dork, "dork", "", "")
flag.StringVar(&dork, "d", "", "")
flag.StringVar(&engine, "engine", "", "")
flag.StringVar(&engine, "e", "", "")
flag.BoolVar(&save, "save", false, "")
flag.BoolVar(&save, "s", false, "")
flag.Usage = func() {
fmt.Println("\033[92m" + usage + "\033[0m")
}
flag.Parse()
engine = strings.ToLower(engine)
Validengine := engine == "google" || engine == "ask" || engine == "duck"
ValidSave := save == true || save == false
if Validengine && ValidSave {
search(engine, dork, save)
} else {
fmt.Println(ERR, " Parameters Invalid")
fmt.Println("\033[92m" + usage + "\033[0m")
}
}
func search(engine string, dork string, save bool) {
var baseURL, regex, method, dataSend string
fmt.Scan(dataSend)
switch engine {
case "google":
method = "get"
regex = `"><a href="\/url\?q=(.*?)&sa=U&`
baseURL = "https://www.google.com/search?q=" + dork + "&gws_rd=cr,ssl&client=ubuntu&ie=UTF-8&start=1"
case "ask":
method = "get"
regex = `target=\"_blank\" href='(.*?)' data-unified=`
baseURL = "https://www.ask.com/web?q=" + dork
case "duck":
method = "post"
regex = `<a class="result__url" href="(.*?)"`
baseURL = "https://html.duckduckgo.com/html/"
dataSend = "q=" + dork + "&b="
}
fmt.Println(WRN, "if You are using your own ip, it may be block by provider.")
fmt.Println(ENG, "Engine: \t\t", "["+strings.Title(engine)+"]")
fmt.Println(INF, "Dork:\t\t", "["+dork+"]")
var body string
if method == "get" {
resp, err := http.Get(baseURL)
handelError(err)
fmt.Println(INF, "Status Code:\t", "["+strconv.Itoa(resp.StatusCode)+"]")
data, err := ioutil.ReadAll((resp.Body))
handelError(err)
body = string(data)
defer resp.Body.Close()
} else {
BodyToSend := []byte(dataSend)
bodyReader := bytes.NewReader(BodyToSend)
req, err := http.NewRequest("POST", baseURL, bodyReader)
req.Header.Set("accept", `text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9`)
req.Header.Set("accept-language", `en-US,en;q=0.9`)
req.Header.Set("content-type", `application/x-www-form-urlencoded`)
req.Header.Set("origin", `https://html.duckduckgo.com`)
req.Header.Set("referer", `https://html.duckduckgo.com/`)
req.Header.Set("user-agent", `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36`)
resp, err := http.DefaultClient.Do(req)
handelError(err)
fmt.Println(INF, "Status Code:\t", "["+strconv.Itoa(resp.StatusCode)+"]")
data, err := ioutil.ReadAll((resp.Body))
handelError(err)
body = string(data)
defer resp.Body.Close()
}
fmt.Println(INF, "Body Recived:\t", SUCCESS)
fmt.Println(INF, "Scalping Links...\t")
var compileRegex = regexp.MustCompile(regex)
found := compileRegex.FindAllStringSubmatch(body, -1)
all_urls := []string{}
for i := range found {
url_rs := found[i][1]
all_urls = append(all_urls, url_rs)
}
fmt.Print(URL + " ")
fmt.Println(strings.Join(all_urls, "\n"+URL+" "))
if save {
f, err := os.OpenFile("DorkSearch-Result.txt", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
handelError(err)
f.Write([]byte(strings.Join(all_urls, "\n")))
f.Close()
fmt.Println(INF, "Results Saved in DorkSearch-Result.txt")
}
}
func handelError(e error) {
if e != nil {
fmt.Println(e.Error())
}
}
func showBanner() {
author := "@aDarkDev"
version := "v1.1"
banner := `
___ _ __ _
/ \___ _ __| | __ / _\ ___ __ _ _ __ ___| |__ ___ _ __
/ /\ / _ \| '__| |/ / \ \ / _ \/ _' | '__/ __| '_ \ / _ \ '__|
/ /_// (_) | | | < _\ \ __/ (_| | | | (__| | | | __/ |
/___,' \___/|_| |_|\_\ \__/\___|\__,_|_| \___|_| |_|\___|_|
` + version + " - " + author
fmt.Print("\033[96m" + banner + "\033[0m\n\n")
}
type Color string
const (
ENG Color = "[\033[96mENG\033[0m]"
INF = "[\033[0;94mINF\033[0m]"
URL = "[\033[92mURL\033[0m]"
SUCCESS = "[\033[92mSUCCESS\033[0m]"
WRN = "[\033[93mWRN\033[0m]"
ERR = "[\033[91mERR\033[0m]"
usage = `Options:
-d, --dork <dork> Search dork
-e, --engine <engine> Search engine (default: Google.com)
(engines: Google , Ask , Duck(DuckDuckGo))
-s, --save <true/false> Save Dork Result in txt file (default: false)`
)