mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
修复10个代码缺陷: panic防护, 死锁, 密钥泄漏, 错误吞没
- eval_random: randomInt参数max<=min时不再panic,返回CEL错误 - scanner: 长驻插件nil/panic时兜底发送ready通道,消除死锁 - poc_executor: Ceye API密钥改为环境变量CEYE_API/CEYE_DOMAIN - Eval: ParseResponse加入oResp.Request nil检查 - Eval: reverseCheck中http.NewRequest错误不再忽略 - poc_executor: clusterpoc中CEL表达式求值错误记录日志 - winwmi: PowerShell执行失败完整记录错误信息 - sshkey: authorized_keys读取失败处理错误 - minidump: Scan结束后释放系统DLL句柄 - Windows插件: PE文件错误消息改用i18n
This commit is contained in:
+11
-2
@@ -363,7 +363,10 @@ func reverseCheck(r *Reverse, timeout int64) bool {
|
||||
ceyeAPI, sub)
|
||||
|
||||
// 创建并发送请求
|
||||
req, _ := http.NewRequest("GET", apiURL, nil)
|
||||
req, err := http.NewRequest("GET", apiURL, nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
resp, err := DoRequest(req, false)
|
||||
if err != nil {
|
||||
return false
|
||||
@@ -521,9 +524,15 @@ func ParseRequest(oReq *http.Request) (*Request, error) {
|
||||
|
||||
// ParseResponse 将标准 HTTP 响应转换为自定义响应对象
|
||||
func ParseResponse(oResp *http.Response) (*Response, error) {
|
||||
var respURL *UrlType
|
||||
if oResp.Request != nil {
|
||||
respURL = ParseURL(oResp.Request.URL)
|
||||
} else {
|
||||
respURL = &UrlType{}
|
||||
}
|
||||
resp := Response{
|
||||
Status: int32(oResp.StatusCode),
|
||||
URL: ParseURL(oResp.Request.URL),
|
||||
URL: respURL,
|
||||
Headers: make(map[string]string),
|
||||
ContentType: oResp.Header.Get("Content-Type"),
|
||||
}
|
||||
|
||||
@@ -46,9 +46,12 @@ func registerRandomImplementations() []*functions.Overload {
|
||||
if !ok {
|
||||
return types.ValOrErr(rhs, "unexpected type '%v' passed to randomInt", rhs.Type())
|
||||
}
|
||||
min, max := int(from), int(to)
|
||||
//nolint:gosec // G404: 用于生成POC测试随机数,非加密用途
|
||||
return types.Int(rand.Intn(max-min) + min)
|
||||
min, max := int(from), int(to)
|
||||
if max <= min {
|
||||
return types.NewErr("randomInt: max(%d) must be greater than min(%d)", max, min)
|
||||
}
|
||||
//nolint:gosec // G404: 用于生成POC测试随机数,非加密用途
|
||||
return types.Int(rand.Intn(max-min) + min)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"math/rand" //nolint:gosec // G404: math/rand用于生成测试数据,非加密用途
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -19,11 +20,18 @@ import (
|
||||
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
|
||||
)
|
||||
|
||||
// API配置常量
|
||||
const (
|
||||
ceyeAPI = "a78a1cb49d91fe09e01876078d1868b2" // Ceye平台的API密钥
|
||||
ceyeDomain = "7wtusr.ceye.io" // Ceye平台的域名
|
||||
)
|
||||
// Ceye平台凭据(通过环境变量配置,避免将密钥硬编码在源码中)
|
||||
// CEYE_API: Ceye API令牌
|
||||
// CEYE_DOMAIN: Ceye平台域名(可选,默认使用api.ceye.io)
|
||||
var ceyeAPI, ceyeDomain string
|
||||
|
||||
func init() {
|
||||
ceyeAPI = os.Getenv("CEYE_API")
|
||||
ceyeDomain = os.Getenv("CEYE_DOMAIN")
|
||||
if ceyeDomain == "" {
|
||||
ceyeDomain = "api.ceye.io"
|
||||
}
|
||||
}
|
||||
|
||||
// Task 定义单个POC检测任务的结构体
|
||||
type Task struct {
|
||||
@@ -480,7 +488,10 @@ func clusterpoc(oReq *http.Request, p *Poc, variableMap map[string]interface{},
|
||||
if key == "payload" {
|
||||
payloadExpr = expr
|
||||
}
|
||||
output, _ := evalset1(env, variableMap, key, expr)
|
||||
output, err := evalset1(env, variableMap, key, expr)
|
||||
if err != nil {
|
||||
common.LogError(i18n.Tr("webscan_set_exec_error", key, err))
|
||||
}
|
||||
payloads[key] = output
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user