-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathgadgets.go
More file actions
90 lines (79 loc) · 1.9 KB
/
gadgets.go
File metadata and controls
90 lines (79 loc) · 1.9 KB
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
package main
import (
"encoding/json"
"github.com/yhy0/ChYing/pkg/coder/twj"
"github.com/yhy0/ChYing/pkg/decoder"
"github.com/yhy0/ChYing/pkg/utils"
"github.com/yhy0/logging"
"strings"
"time"
)
/**
@author yhy
@since 2024/8/12
@desc //TODO
**/
func (a *App) Decoder(str string, mode string) string {
switch mode {
case "DecodeUnicode":
return decoder.DecodeUnicode(str)
case "EncodeUnicode":
return decoder.EncodeUnicode(str)
case "DecodeURL":
return decoder.DecodeURL(str)
case "EncodeURL":
return decoder.EncodeURL(str)
case "DecodeBase64":
return decoder.DecodeBase64(str)
case "EncodeBase64":
return decoder.EncodeBase64(str)
case "DecodeHex":
return decoder.DecodeHex(str)
case "EncodeHex":
return decoder.EncodeHex(str)
case "MD5":
return decoder.Md5(str)
default:
return str
}
}
func (a *App) Verify(jwt string, secret string) (res Result) {
parseJWT, err := twj.Verify(jwt, secret)
if err != nil {
logging.Logger.Errorln(err)
res.Error = err.Error()
return
}
h, err := json.Marshal(parseJWT)
res.Data = string(h)
return
}
func (a *App) Brute(jwtMsg string, jwtPath string) string {
// 爆破前判断是否有进程在爆破,如果有停止
if twj.Flag {
twj.Stop = true
time.Sleep(1 * time.Second)
twj.Stop = false
}
return twj.GenerateSignature(jwtMsg, jwtPath)
}
func (a *App) TwjStop() {
twj.Stop = true
time.Sleep(2 * time.Second)
twj.Stop = false
}
// Sign 使用指定算法和密钥签名 JWT
func (a *App) Sign(headerJson string, payloadJson string, secret string, algorithm string) (res Result) {
jwtToken, err := twj.Sign(headerJson, payloadJson, secret, algorithm)
if err != nil {
logging.Logger.Errorln(err)
res.Error = err.Error()
return
}
res.Data = jwtToken
return
}
func (a *App) PredictionApi(api string) []string {
logging.Logger.Debug(strings.Split(api, "\n"))
return utils.PredictionApi(strings.Split(api, "\n"), 1)
}