Skip to content

Commit 66b3973

Browse files
committed
add errdetect before dnslog
1 parent c915c23 commit 66b3973

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

Console/console.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func Start(options Utils.Option){
4949
wg.Wait()
5050

5151
writeResults(options.Result,results)
52+
fmt.Println("[*] 结果已保存至 " + options.Result)
5253

5354
//fmt.Println(results)
5455
}

Detect/detect.go

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
func DetectFastjson(url string) (bool,string){
2121
fmt.Println("["+url+"] :"+"[+] 正在进行报错识别")
22-
jsonType, _ := ErrDetectVersion(url)
22+
jsonType := ErrDetectVersion(url,Utils.FS_ERR_DETECT)
2323
if jsonType == "jackson" {
2424
return false,Utils.NOT_FS
2525
}
@@ -64,26 +64,32 @@ func DetectVersion(url string ) Utils.Result {
6464
}
6565
fmt.Println("[" + result.Url + "] :" + "[+] 正在进行版本探测")
6666
payloads, session = Utils.DNS_DETECT_FACTORY()
67-
if DnslogDetect(url, payloads.Dns_48, session) == "48" {
67+
version := DnslogDetect(url, payloads.Dns_48, session)
68+
if version == "48" {
6869
result.Version = Utils.FJ_UNDER_48
6970
return result
7071
}
71-
if DnslogDetect(url, payloads.Dns_68, session) == "68" {
72+
version = DnslogDetect(url, payloads.Dns_68, session)
73+
if version == "68" {
7274
if result.AutoType {
7375
result.Version = Utils.FJ_BEYOND_48
7476
return result
7577
}
7678
result.Version = Utils.FJ_BETWEEN_48_68
7779
return result
7880
}
79-
if DnslogDetect(url, payloads.Dns_80, session) == "80" {
81+
version = DnslogDetect(url, payloads.Dns_80, session)
82+
if version == "80" {
8083
result.Version = Utils.FJ_BETWEEN_69_80
8184
return result
8285
}
83-
if DnslogDetect(url, payloads.Dns_80, session) == "83" {
86+
version = DnslogDetect(url, payloads.Dns_80, session)
87+
if version == "83" {
8488
result.Version = Utils.FS_BEYOND_80
8589
return result
8690
}
91+
result.Version = version
92+
return result
8793
}else{
8894
fmt.Println("客户端与dnslog平台网络不可达")
8995
//内网测试场景 施工中
@@ -171,7 +177,17 @@ func DnslogDetect(target string,payload string,session string) string{
171177
return Utils.NETWORK_NOT_ACCESS
172178
}
173179
}
174-
defer httpRsp.Body.Close()
180+
//defer httpRsp.Body.Close()
181+
body, err := ioutil.ReadAll(httpRsp.Body)
182+
if err != nil{
183+
err.Error()
184+
}
185+
reg := regexp.MustCompile(`fastjson-version\s\d.\d.[0-9]+`)
186+
var version string
187+
version = reg.FindString(string(body))
188+
if version != ""{
189+
return version[17:]
190+
}
175191

176192
//fmt.Println(session)
177193
time.Sleep(3*time.Second) // 等3秒钟,防止由于网络原因误报
@@ -183,9 +199,9 @@ func DnslogDetect(target string,payload string,session string) string{
183199
*** 报错探测
184200
**/
185201

186-
func ErrDetectVersion(target string) (string,bool){
202+
func ErrDetectVersion(target string,payload string) string{
187203
var version string
188-
reqBody := strings.NewReader(Utils.FS_ERR_DETECT)
204+
reqBody := strings.NewReader(payload)
189205
httpReq, err := http.NewRequest("POST", target, reqBody)
190206
if err != nil {
191207
err.Error()
@@ -196,7 +212,7 @@ func ErrDetectVersion(target string) (string,bool){
196212
httpRsp = Utils.NetWorkErrHandle(http.DefaultClient,httpReq,err)
197213
if httpRsp == nil{
198214
fmt.Println("与"+target+"网络不可达,请检查网络")
199-
return Utils.NETWORK_NOT_ACCESS,false
215+
return Utils.NETWORK_NOT_ACCESS
200216
}
201217
}
202218
defer httpRsp.Body.Close()
@@ -210,9 +226,9 @@ func ErrDetectVersion(target string) (string,bool){
210226
if version == ""{
211227
reg = regexp.MustCompile(`jackson`)
212228
version = reg.FindString(string(body))
213-
return version,false
229+
return version
214230
}else{
215-
return version[17:],true
231+
return version[17:]
216232
}
217233
}
218234

Utils/dnslog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func GetDnslogRecord(PHPSESSID string) string{
5656
dns_83 := regexp.MustCompile(`83_.`)
5757
//fmt.Println(string(body))
5858
if string(body) == "[]"{
59-
return string(body)
59+
return ""
6060
}else{
6161
if dns_48.FindString(string(body)) != "" {
6262
return "48"

0 commit comments

Comments
 (0)