-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
109 lines (97 loc) · 2.03 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
/**
* hope it helps u *
* By Nikita Vtorushin<n.vtorushin@inbox.ru> *
* @nikitavoryet *
* GoLang search admin panel (phpmyadmin or any *
**/
package main
import (
"bufio"
"fmt"
"net/http"
"os"
"regexp"
"strconv"
"strings"
"time"
)
var admins, _ = readLines("adminpath.txt")
var (
domain string
protocol string
)
func header1() {
print("coded by @nikitavoryet")
fmt.Println("\n")
}
func header2() {
fmt.Println(strings.Repeat("-", 74))
fmt.Print("| ")
fmt.Print(" status ")
fmt.Print("| ")
fmt.Print("path url")
fmt.Println(" |")
fmt.Println(strings.Repeat("-", 74))
}
func main() {
header1()
fmt.Print("enter domain >> ")
fmt.Scan(&domain)
if !checkProtocol(domain) {
fmt.Println("choose the protocol:\nhttps - 1\nhttp - 2")
fmt.Print(">> ")
fmt.Scan(&protocol)
if protocol == "1" {
protocol = "https://"
} else {
protocol = "http://"
}
domain = protocol + domain
}
header2()
now := strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
_, err := os.Create(now + "_output.txt")
if err != nil {
panic(err)
}
fs, err := os.OpenFile(now+"_output.txt", os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
panic(err)
}
for _, i := range admins {
_domain := domain + "/" + i
resp, _ := http.Get(_domain)
if resp.StatusCode != 404 {
fmt.Print(" OK | ")
if _, err := fs.WriteString(_domain + "\n"); err != nil {
panic(err)
}
} else {
fmt.Print(" failed ")
fmt.Print("| ")
}
fmt.Println(domain + "/" + i)
}
fmt.Println(strings.Repeat("-", 74))
}
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}
func checkProtocol(domain string) bool {
var re = regexp.MustCompile(`http|https`)
if !re.MatchString(domain) {
return false
} else {
return true
}
}