-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
164 lines (135 loc) · 4.37 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
package main
import (
"flag"
"fmt"
"net"
"net/http"
"regexp"
"strings"
"time"
"github.com/briandowns/spinner"
"github.com/christophwitzko/go-curl"
)
func sendReq(hostname string) string {
err, str, _ := curl.String(hostname)
if err != nil {
return ""
}
err, _, _ = curl.Bytes(hostname)
if err != nil {
return ""
}
return str
}
func otherMethods(hostname string) string {
cb := func(st curl.IoCopyStat) error {
if st.Response != nil {
}
return nil
}
_, str, _ := curl.String(
hostname, cb, "method=", "POST",
"data=", strings.NewReader("{\"asd\": \"test\"}"),
"disablecompression=", true,
"header=", http.Header{"X-My-Header": {"laravelN00b"}},
)
return str
}
func envOrNot(response string) bool {
envFound := regexp.MustCompile("APP([a-zA-Z_]+)=")
if len(envFound.FindStringSubmatch(response)) > 0 {
return true
}
return false
}
func debugOrNot(response string) bool {
debugFound := regexp.MustCompile("APP([a-zA-Z_]+)</td>")
if len(debugFound.FindStringSubmatch(response)) > 0 {
return true
}
return false
}
func main() {
hostname := flag.String("hostname", "", "Please input hostname")
flag.Parse()
fmt.Println(`
_ _ _ _ ___ ___ _
| | __ _ _ __ __ ___ _____| | \ | |/ _ \ / _ \| |__
| | / _ | '__/ _ \ \ / / _ \ | \| | | | | | | | '_ \
| |__| (_| | | | (_| |\ V / __/ | |\ | |_| | |_| | |_) |
|_____\__,_|_| \__,_| \_/ \___|_|_| \_|\___/ \___/|_.__/
Laravel .env file checker. ( Scan domain and IP )
Host : ` + *hostname + `
Sponsored by : bekchy.com
`)
addresses, _ := net.LookupIP(*hostname)
ip := ""
for i := 0; i < len(addresses); i++ {
segments := strings.SplitAfter(addresses[i].String(), " ")
ip = segments[0]
}
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Start()
s.Restart()
fmt.Printf("\033[1;34m%s\033[0m", "Checking .env in : "+"http://"+*hostname+"/ \n")
firstReq := envOrNot(sendReq("http://" + *hostname + "/.env"))
if firstReq == false {
s.Restart()
fmt.Printf("\033[1;34m%s\033[0m", "Checking .env in : "+"https://"+*hostname+"/ \n")
firstReq := envOrNot(sendReq("https://" + *hostname + "/.env"))
if firstReq == false {
s.Restart()
fmt.Printf("\033[1;34m%s\033[0m", "Checking .env in : "+"http://"+ip+"/ \n")
firstReq := envOrNot(sendReq("http://" + ip + "/.env"))
if firstReq == false {
s.Restart()
fmt.Printf("\033[1;34m%s\033[0m", "Checking .env in : "+"http://www."+*hostname+"/ \n")
firstReq := envOrNot(sendReq("http://www." + ip + "/.env"))
if firstReq == false {
s.Restart()
fmt.Printf("\033[1;34m%s\033[0m", "Checking .env in : "+"https://www."+*hostname+"/ \n")
firstReq := envOrNot(sendReq("https://www." + ip + "/.env"))
if firstReq == false {
fmt.Printf("\033[1;31m%s\033[0m", ".env Not Found \n")
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", ".env Found : "+"https://www."+ip+"/.env \n")
}
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", ".env Found : "+"http://www."+ip+"/.env \n")
}
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", ".env Found : "+"http://"+ip+"/.env \n")
}
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", ".env Found : "+"https://"+*hostname+"/.env \n")
}
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", ".env Found : "+"http://"+*hostname+"/.env \n")
}
s.Restart()
fmt.Printf("\033[1;33m%s\033[0m", "--------------------------------------------------------- \n")
fmt.Printf("\033[1;33m%s\033[0m", "Checking .env Debug Mode \n")
denugCheck := debugOrNot(otherMethods("http://" + *hostname))
if denugCheck == false {
denugCheck := debugOrNot(otherMethods("https://" + *hostname))
if denugCheck == false {
s.Restart()
fmt.Printf("\033[1;31m%s\033[0m", "Debug mode not active \n")
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", "* Laravel Debug Mode Active send POST or PUT and read .env Variables. \n\n")
fmt.Printf("\033[1;36m%s\033[0m", "Example curl Command:\ncurl -X POST https://"+*hostname+" | grep APP_\n\n\n")
}
} else {
s.Restart()
fmt.Printf("\033[1;36m%s\033[0m", "* Laravel Debug Mode Active send POST or PUT and read .env Variables. \n\n")
fmt.Printf("\033[1;36m%s\033[0m", "Example curl Command:\ncurl -X POST http://"+*hostname+" | grep APP_\n\n\n")
}
s.Restart()
s.Stop()
}