From 02195a8005a9a02c3fd7091e1d02a7b40e296c17 Mon Sep 17 00:00:00 2001 From: M09Ic Date: Thu, 12 Jan 2023 16:35:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=A4=9A=E5=A4=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=B8=8E=E6=97=A5=E5=BF=97=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/cmd.go | 2 ++ internal/option.go | 21 +++++++++++++++++++-- internal/pool.go | 3 +++ pkg/baseline.go | 14 +++++++++----- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 6df1c80..b2fb38f 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -73,6 +73,8 @@ func Spray() { logs.Log.Level = logs.Debug } + logs.DefaultColorMap[logs.Info] = logs.PurpleBold + logs.DefaultColorMap[logs.Important] = logs.GreenBold pkg.Distance = uint8(option.SimhashDistance) ihttp.DefaultMaxBodySize = option.MaxBodyLength * 1024 internal.MaxCrawl = option.CrawlDepth diff --git a/internal/option.go b/internal/option.go index f7b3727..ae625e2 100644 --- a/internal/option.go +++ b/internal/option.go @@ -143,8 +143,6 @@ func (opt *Option) PrepareRunner() (*Runner, error) { // log and bar if !opt.NoColor { logs.Log.Color = true - logs.DefaultColorMap[logs.Info] = logs.PurpleBold - logs.DefaultColorMap[logs.Important] = logs.Green r.Color = true } if opt.Quiet { @@ -182,6 +180,25 @@ func (opt *Option) PrepareRunner() (*Runner, error) { } else if opt.FileBak { opt.AppendRule = append(opt.AppendRule, "filebak") } + var s strings.Builder + if r.Crawl { + s.WriteString("crawl enable; ") + } + if r.Active { + s.WriteString("active fingerprint enable; ") + } + if r.Bak { + s.WriteString("bak file enable; ") + } + if r.Common { + s.WriteString("common file enable; ") + } + if len(opt.AppendRule) > 0 { + s.WriteString("file bak enable; ") + } + if s.Len() > 0 { + logs.Log.Important("Advance Mod: " + s.String()) + } if opt.BlackStatus != "" { for _, s := range strings.Split(opt.BlackStatus, ",") { diff --git a/internal/pool.go b/internal/pool.go index c07f7e8..c09b5b6 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -184,6 +184,9 @@ func (pool *Pool) Init() error { if pool.index.ErrString != "" { return fmt.Errorf(pool.index.String()) } + if pool.index.Chunked && pool.ClientType == ihttp.FAST { + logs.Log.Warn("chunk encoding! buf current client FASTHTTP not support chunk decode") + } logs.Log.Info("[baseline.index] " + pool.index.Format([]string{"status", "length", "spend", "title", "frame", "redirect"})) // 检测基本访问能力 if pool.random.ErrString != "" { diff --git a/pkg/baseline.go b/pkg/baseline.go index 54646e0..d676a3c 100644 --- a/pkg/baseline.go +++ b/pkg/baseline.go @@ -30,6 +30,7 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline { copy(bl.Body, body) if i == -1 { + bl.Chunked = true bl.BodyLength = len(bl.Body) } else { bl.BodyLength = i @@ -45,12 +46,13 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline { bl.Raw = append(bl.Header, bl.Body...) bl.RedirectURL = resp.GetHeader("Location") + bl.Dir = bl.IsDir() uu, err := url.Parse(u) if err == nil { bl.Path = uu.Path bl.Url = uu } - bl.Dir = bl.IsDir() + if bl.Url.Host != host { bl.Host = host } @@ -70,13 +72,14 @@ func NewInvalidBaseline(u, host string, resp *ihttp.Response, reason string) *Ba bl.BodyLength = resp.ContentLength() bl.RedirectURL = string(resp.GetHeader("Location")) + bl.Dir = bl.IsDir() uu, err := url.Parse(u) if err == nil { bl.Path = uu.Path bl.Url = uu + } else { return bl } - bl.Dir = bl.IsDir() if bl.Url.Host != host { bl.Host = host @@ -90,7 +93,8 @@ type Baseline struct { Url *url.URL `json:"-"` UrlString string `json:"url"` Path string `json:"path"` - Dir bool `json:"isdir"` + Dir bool `json:"-"` + Chunked bool `json:"-"` Host string `json:"host"` Body []byte `json:"-"` BodyLength int `json:"body_length"` @@ -361,7 +365,7 @@ func (bl *Baseline) ColorString() string { } if len(bl.Extracteds) > 0 { for _, e := range bl.Extracteds { - line.WriteString("\n " + e.Name + ": \n\t") + line.WriteString("\n " + e.Name + " (" + strconv.Itoa(len(e.ExtractResult)) + ") items : \n\t") line.WriteString(logs.GreenLine(strings.Join(e.ExtractResult, "\n\t"))) } } @@ -414,7 +418,7 @@ func (bl *Baseline) String() string { } if len(bl.Extracteds) > 0 { for _, e := range bl.Extracteds { - line.WriteString("\n " + e.Name + ": \n\t") + line.WriteString("\n " + e.Name + " (" + strconv.Itoa(len(e.ExtractResult)) + ") items : \n\t") line.WriteString(strings.Join(e.ExtractResult, "\n\t")) } }