Update scan.go

This commit is contained in:
ciphersaw 2025-04-26 11:07:14 +08:00
parent aaa910d363
commit 6814aeecc3

18
scan.go
View File

@ -222,17 +222,17 @@ func sendHTTPAndKimi(r *RequestResponseLog) (result, reqA, reqB, respA, respB st
return resultDetect, req1, req2, resp1, resp2, nil return resultDetect, req1, req2, resp1, resp2, nil
} else { } else {
return `{"res": "false", "reason": "相似度小于0.5(` + fmt.Sprint(similarity) + `)判断为未越权未消耗AI tokens","confidence":"100%"}`, req1, req2, resp1, resp2, nil return `{"res": "false", "reason": "相似度小于0.5(` + fmt.Sprint(similarity) + `)判断为未越权未消耗AI tokens", "confidence":"100%"}`, req1, req2, resp1, resp2, nil
} }
} else { } else {
return `{"res": "false", "reason": "匹配到关键字判断为无越权未消耗AI tokens","confidence":"100%"}`, req1, req2, resp1, resp2, nil return `{"res": "false", "reason": "匹配到关键字判断为无越权未消耗AI tokens", "confidence":"100%"}`, req1, req2, resp1, resp2, nil
} }
} else { } else {
return `{"res": "white", "reason": "请求包太大","confidence":"100%"}`, req1, req2, resp1, resp2, nil return `{"res": "white", "reason": "请求包太大", "confidence":"100%"}`, req1, req2, resp1, resp2, nil
} }
} }
return `{"res": "white", "reason": "白名单后缀或白名单Content-Type接口","confidence":"100%"}`, req1, "", resp1, "", nil return `{"res": "white", "reason": "白名单后缀或白名单Content-Type接口", "confidence":"100%"}`, req1, "", resp1, "", nil
} }
func detectPrivilegeEscalation(AI string, reqA, resp1, resp2, statusB string) (string, error) { func detectPrivilegeEscalation(AI string, reqA, resp1, resp2, statusB string) (string, error) {
@ -249,12 +249,12 @@ func detectPrivilegeEscalation(AI string, reqA, resp1, resp2, statusB string) (s
model := "deepseek-chat" model := "deepseek-chat"
aiurl := "https://api.deepseek.com/v1/chat/completions" aiurl := "https://api.deepseek.com/v1/chat/completions"
apikey := config.GetConfig().APIKeys.DeepSeek apikey := config.GetConfig().APIKeys.DeepSeek
result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 kimi 检测是否越权 result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 deepseek 检测是否越权
case "qianwen": case "qianwen":
model := "qwen-plus" model := "qwen-plus"
aiurl := "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions" aiurl := "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
apikey := config.GetConfig().APIKeys.Qianwen apikey := config.GetConfig().APIKeys.Qianwen
result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 kimi 检测是否越权 result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 qianwen 检测是否越权
case "hunyuan": case "hunyuan":
model := "hunyuan-turbo" model := "hunyuan-turbo"
aiurl := "https://api.hunyuan.cloud.tencent.com/v1/chat/completions" aiurl := "https://api.hunyuan.cloud.tencent.com/v1/chat/completions"
@ -264,17 +264,17 @@ func detectPrivilegeEscalation(AI string, reqA, resp1, resp2, statusB string) (s
model := "glm-4-air" model := "glm-4-air"
aiurl := "https://open.bigmodel.cn/api/paas/v4/chat/completions" aiurl := "https://open.bigmodel.cn/api/paas/v4/chat/completions"
apikey := config.GetConfig().APIKeys.Glm apikey := config.GetConfig().APIKeys.Glm
result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 hunyuan 检测是否越权 result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 glm 检测是否越权
case "gpt": case "gpt":
model := "gpt-4o" model := "gpt-4o"
aiurl := "https://open.bigmodel.cn/api/paas/v4/chat/completions" aiurl := "https://open.bigmodel.cn/api/paas/v4/chat/completions"
apikey := config.GetConfig().APIKeys.Gpt apikey := config.GetConfig().APIKeys.Gpt
result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 hunyuan 检测是否越权 result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 gpt 检测是否越权
default: default:
model := "moonshot-v1-8k" model := "moonshot-v1-8k"
aiurl := "https://api.moonshot.cn/v1/chat/completions" aiurl := "https://api.moonshot.cn/v1/chat/completions"
apikey := config.GetConfig().APIKeys.Kimi apikey := config.GetConfig().APIKeys.Kimi
result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 调用 kimi 检测是否越权 result, err = aiapis.AIScan(model, aiurl, apikey, reqA, resp1, resp2, statusB) // 默认调用 kimi 检测是否越权
} }
if err != nil { if err != nil {