EdgeSecurityTeam / EHole

EHole(棱洞)3.0 重构版-红队重点攻击系统指纹探测工具
https://forum.ywhack.com/
Apache License 2.0
3.06k stars 400 forks source link

结果写入小bug #70

Open Wnltc opened 1 year ago

Wnltc commented 1 year ago

写入路径的目录名或文件名带 "." 时,会不写入结果到文件中,如/tmp/.sss/1.json、test.xx.json这种,结果都不会写入

r1is commented 4 months ago

这个小Bug存在于:module/finger/output.go文件的outfile函数/tmp/.sss/1.json,test.xx.json 明显不会进入if逻辑,其次获取文件后缀的方式也有问题。

func outfile(filename string, allresult []Outrestul) {
    file := strings.Split(filename, ".")
    if len(file) == 2 {
        if file[1] == "json" {
            buf, err := json.MarshalIndent(allresult, "", " ")
            if err != nil {
                fmt.Println(err.Error())
                return
            }
            outjson(filename, buf)
        }
        if file[1] == "xlsx" {
            outxlsx(filename, allresult)
        }
    }

}

修复后的代码:

func outfile(filename string, allresult []Outrestul) {
    fileExt := filepath.Ext(filename)     //获取后缀名 .json .xlsx ,需要 import "path/filepath"
    if fileExt == ".json" {
        buf, err := json.MarshalIndent(allresult, "", " ")
        if err != nil {
            fmt.Println(err.Error())
            return
        }
        outjson(filename, buf)
    }
    if fileExt == ".xlsx" {
        outxlsx(filename, allresult)
    }
}