From 0a1ec0ab241cfe3c5887b156c8ede4a0515cd5b9 Mon Sep 17 00:00:00 2001 From: hktalent <18223385+hktalent@users.noreply.github.com> Date: Sat, 15 Oct 2022 17:55:36 +0800 Subject: [PATCH] fix logs 2022-10-15 --- brute/filefuzz.go | 5 +++++ lib/util/log.go | 1 + pkg/httpx/runner/runner.go | 5 ++--- pkg/hydra/doNmapResult.go | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/brute/filefuzz.go b/brute/filefuzz.go index a1dba1ebb..072819053 100644 --- a/brute/filefuzz.go +++ b/brute/filefuzz.go @@ -432,10 +432,15 @@ BreakAll: // 默认情况等待所有结束 wg.Wait() if 0 < len(path) { + util.SendLog(u, "brute", strings.Join(path, "\n"), "") + log.Printf("fuzz is over: %s found:\n%s\n", u, strings.Join(path, "\n")) path = util.SliceRemoveDuplicates(path) } technologies = util.SliceRemoveDuplicates(technologies) + if 0 < len(technologies) { + util.SendLog(u, "brute", strings.Join(technologies, "\n"), "") + } stop() //发停止指令 <-time.After(time.Second * 2) diff --git a/lib/util/log.go b/lib/util/log.go index e7151702a..9c3b83f61 100644 --- a/lib/util/log.go +++ b/lib/util/log.go @@ -87,4 +87,5 @@ func writeoutput(v interface{}) { } defer f.Close() //nolint f.WriteString(szLog) + } diff --git a/pkg/httpx/runner/runner.go b/pkg/httpx/runner/runner.go index e31678d49..bf8f7cf6c 100644 --- a/pkg/httpx/runner/runner.go +++ b/pkg/httpx/runner/runner.go @@ -537,14 +537,14 @@ func (r *Runner) RunEnumeration() { // output routine wgoutput := sizedwaitgroup.New(1) wgoutput.Add() - output := make(chan Result) + output := make(chan Result, 200) go func(output chan Result) { defer wgoutput.Done() var f *os.File if r.options.Output != "" { var err error - f, err = os.Create(r.options.Output) + f, err := os.OpenFile(r.options.Output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { gologger.Fatal().Msgf("Could not create output file '%s': %s\n", r.options.Output, err) } @@ -554,7 +554,6 @@ func (r *Runner) RunEnumeration() { header := Result{}.CSVHeader() //gologger.Silent().Msgf("%s\n", header) if f != nil { - f.WriteString("\xEF\xBB\xBF") //nolint:errcheck // this method needs a small refactor to reduce complexity f.WriteString(header + "\n") } diff --git a/pkg/hydra/doNmapResult.go b/pkg/hydra/doNmapResult.go index 387a23034..8a0f2a4f0 100644 --- a/pkg/hydra/doNmapResult.go +++ b/pkg/hydra/doNmapResult.go @@ -129,7 +129,9 @@ func DoParseXml(s string, bf *bytes.Buffer) { } } - log.Printf("%s\t%d\t%s\n", ip, port, service) + s1 := fmt.Sprintf("%s\t%d\t%s\n", ip, port, service) + util.SendLog(ip, "nmap", s1, "") + log.Printf("%s", s1) } } }