diff --git a/README.md b/README.md index 36856cdda..f60e98efa 100644 --- a/README.md +++ b/README.md @@ -175,10 +175,10 @@ priorityNmap=false ./scan4all -tp http -list allOut.txt -v - 2022-06-07 添加相似度算法来检测 404 - 2022-06-07 增加http url列表精准扫描参数,根据环境变量UrlPrecise=true开启 -# Communication group (WeChat, QQ) -| Wechat | Or | QQchat | -| --- |--- |--- | -|||| +# Communication group (WeChat, QQ,Tg) +| Wechat | Or | QQchat | Or | Tg | +| --- |--- |--- |--- |--- | +|||||| # Donation | Wechat Pay | AliPay | Paypal | BTC Pay |BCH Pay | diff --git a/README_CN.md b/README_CN.md index 3f1183a02..675fd017d 100644 --- a/README_CN.md +++ b/README_CN.md @@ -205,10 +205,10 @@ priorityNmap=false ./scan4all -tp http -list allOut.txt -v - 2022-06-07 添加相似度算法来检测 404 - 2022-06-07 增加http url列表精准扫描参数,根据环境变量UrlPrecise=true开启 -# 交流群(微信、QQ) -| Wechat | Or | QQchat | -| --- |--- |--- | -|||| +# 交流群(微信、QQ、Tg) +| Wechat | Or | QQchat | Or | Tg | +| --- |--- |--- |--- |--- | +|||||| # Donation | Wechat Pay | AliPay | Paypal | BTC Pay |BCH Pay | diff --git a/go.mod b/go.mod index 77c8ef6c3..fee6105b3 100644 --- a/go.mod +++ b/go.mod @@ -164,6 +164,7 @@ require ( github.com/fatih/structs v1.1.0 // indirect github.com/fortytw2/leaktest v1.3.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/gizak/termui/v3 v3.1.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect @@ -224,7 +225,9 @@ require ( github.com/mattn/go-sqlite3 v1.14.12 // indirect github.com/mholt/acmez v1.0.2 // indirect github.com/mholt/archiver v3.1.1+incompatible // indirect + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/nwaples/rardecode v1.1.2 // indirect github.com/openrdap/rdap v0.9.1-0.20191017185644-af93e7ef17b7 // indirect github.com/owenrumney/go-sarif/v2 v2.1.2 // indirect diff --git a/go.sum b/go.sum index 57f56808d..59a911a6f 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= +github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -528,6 +530,7 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -554,6 +557,8 @@ github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tB github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -568,6 +573,8 @@ github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3P github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474/go.mod h1:OQA4XLvDbMgS8P0CevmM4m9Q3Jq4phKUzcocxuGJ5m8= github.com/ngdinhtoan/glide-cleanup v0.2.0/go.mod h1:UQzsmiDOb8YV3nOsCxK/c9zPpCZVNoHScRE3EO9pVMM= +github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= +github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M= github.com/nwaples/rardecode v1.1.2/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/lib/cli_ui/scan4all_cli_ui.go b/lib/cli_ui/scan4all_cli_ui.go new file mode 100644 index 000000000..fc89d7583 --- /dev/null +++ b/lib/cli_ui/scan4all_cli_ui.go @@ -0,0 +1,95 @@ +package main + +import ( + "fmt" + "github.com/hktalent/scan4all/lib/util" + "log" + "math" + "time" + + ui "github.com/gizak/termui/v3" + "github.com/gizak/termui/v3/widgets" +) + +func main() { + if err := ui.Init(); err != nil { + log.Fatalf("failed to initialize termui: %v", err) + } + defer ui.Close() + + grid := ui.NewGrid() + termWidth, termHeight := ui.TerminalDimensions() + grid.SetRect(0, 0, termWidth, termHeight) + sinFloat64 := (func() []float64 { + n := 400 + data := make([]float64, n) + for i := range data { + data[i] = 1 + math.Sin(float64(i)/5) + } + return data + })() + + lc := widgets.NewPlot() + lc.Title = "braille-mode Line Chart" + lc.Data = append(lc.Data, sinFloat64) + lc.AxesColor = ui.ColorWhite + lc.LineColors[0] = ui.ColorYellow + + gs := make([]*widgets.Gauge, 3) + for i := range gs { + gs[i] = widgets.NewGauge() + gs[i].Percent = i * 10 + gs[i].BarColor = ui.ColorRed + } + + ls := widgets.NewList() + ls.Rows = []string{ + "[1] Downloading File 1", + "", + "", + "", + "[2] Downloading File 2", + "", + "", + "", + "[3] Uploading File 3", + } + ls.Border = false + + p := widgets.NewParagraph() + p.Text = "<> This row has 3 columns\n<- Widgets can be stacked up like left side\n<- Stacked widgets are treated as a single widget" + p.Title = "Demonstration" + grid.Set( + ui.NewRow(1.0/2, + ui.NewCol(1.0, lc), + ), + ui.NewRow(1.0/2, + ui.NewCol(1.0/4, ls), + ui.NewCol(1.0/4, + ui.NewRow(.9/3, gs[0]), + ui.NewRow(.9/3, gs[1]), + ui.NewRow(1.2/3, gs[2]), + ), + ui.NewCol(1.0/2, p), + ), + ) + + ui.Render(grid) + + tick1 := time.Tick(time.Duration(time.Second * 1)) + uiEvents := ui.PollEvents() + for { + select { + case <-util.Ctx_global.Done(): + return + case <-tick1: + ls.Rows[0] = fmt.Sprintf("%v", time.Now()) + ui.Render(grid) + case e := <-uiEvents: + switch e.ID { + case "q", "": + return + } + } + } +} diff --git a/projectdiscovery/nuclei_Yaml/nclruner/runner/runner.go b/projectdiscovery/nuclei_Yaml/nclruner/runner/runner.go index a5f1212d9..e90fae90f 100644 --- a/projectdiscovery/nuclei_Yaml/nclruner/runner/runner.go +++ b/projectdiscovery/nuclei_Yaml/nclruner/runner/runner.go @@ -298,6 +298,9 @@ func (r *Runner) Close() { if r.pprofServer != nil { _ = r.pprofServer.Shutdown(context.Background()) } + if r.interactsh != nil { + r.interactsh.Close() + } } // RunEnumeration sets up the input layer for giving input nuclei. @@ -380,7 +383,39 @@ func (r *Runner) RunEnumeration() error { if err != nil { return errors.Wrap(err, "could not load templates from config") } + // 确保释放资源,多实例运行优化 + defer func() { + var results *atomic.Bool + if r.options.AutomaticScan { + if results, err = r.executeSmartWorkflowInput(executerOpts, store, engine); err != nil { + return + } + + } else { + if results, err = r.executeTemplatesInput(store, engine); err != nil { + return + } + } + if r.interactsh != nil { + matched := r.interactsh.Close() + if matched { + results.CAS(false, true) + } + } + r.progress.Stop() + + if r.issuesClient != nil { + r.issuesClient.Close() + } + + if !results.Load() { + gologger.Info().Msgf("No results found. Better luck next time!") + } + if r.browser != nil { + r.browser.Close() + } + }() if r.options.Validate { if err := store.ValidateTemplates(); err != nil { return err @@ -396,36 +431,6 @@ func (r *Runner) RunEnumeration() error { r.displayExecutionInfo(store) - var results *atomic.Bool - if r.options.AutomaticScan { - if results, err = r.executeSmartWorkflowInput(executerOpts, store, engine); err != nil { - return err - } - - } else { - if results, err = r.executeTemplatesInput(store, engine); err != nil { - return err - } - } - - if r.interactsh != nil { - matched := r.interactsh.Close() - if matched { - results.CAS(false, true) - } - } - r.progress.Stop() - - if r.issuesClient != nil { - r.issuesClient.Close() - } - - if !results.Load() { - gologger.Info().Msgf("No results found. Better luck next time!") - } - if r.browser != nil { - r.browser.Close() - } return err } diff --git a/static/tg.jpg b/static/tg.jpg new file mode 100644 index 000000000..a763b21a3 Binary files /dev/null and b/static/tg.jpg differ diff --git a/vendor/github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/request.go b/vendor/github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/request.go index 8f0d572c3..007c4dfea 100644 --- a/vendor/github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/request.go +++ b/vendor/github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/request.go @@ -346,7 +346,7 @@ func (request *Request) ExecuteWithResults(reqURL string, dynamicValues, previou const drainReqSize = int64(8 * 1024) var errStopExecution = errors.New("stop execution due to unresolved variables") -var someMapMutex = sync.RWMutex{} + // executeRequest executes the actual generated request and returns error if occurred func (request *Request) executeRequest(reqURL string, generatedRequest *generatedRequest, previousEvent output.InternalEvent, hasInteractMatchers bool, callback protocols.OutputEventCallback, requestCount int) error { request.setCustomHeaders(generatedRequest) @@ -582,7 +582,6 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate if request.options.Interactsh != nil { request.options.Interactsh.MakePlaceholders(generatedRequest.interactshURLs, outputEvent) } - someMapMutex.Lock() for k, v := range previousEvent { finalEvent[k] = v } @@ -598,7 +597,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate finalEvent[key] = v } } - someMapMutex.Unlock() + // prune signature internal values if any request.pruneSignatureInternalValues(generatedRequest.meta) diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e3d00556..9d2a7f301 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -267,6 +267,11 @@ github.com/fatih/structs # github.com/fsnotify/fsnotify v1.5.4 ## explicit; go 1.16 github.com/fsnotify/fsnotify +# github.com/gizak/termui/v3 v3.1.0 +## explicit +github.com/gizak/termui/v3 +github.com/gizak/termui/v3/drawille +github.com/gizak/termui/v3/widgets # github.com/go-ole/go-ole v1.2.6 ## explicit; go 1.12 github.com/go-ole/go-ole @@ -628,6 +633,9 @@ github.com/miekg/dns # github.com/mitchellh/go-homedir v1.1.0 ## explicit github.com/mitchellh/go-homedir +# github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 +## explicit +github.com/mitchellh/go-wordwrap # github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 github.com/mitchellh/mapstructure @@ -637,6 +645,9 @@ github.com/modern-go/concurrent # github.com/modern-go/reflect2 v1.0.2 ## explicit; go 1.12 github.com/modern-go/reflect2 +# github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d +## explicit +github.com/nsf/termbox-go # github.com/nwaples/rardecode v1.1.2 ## explicit github.com/nwaples/rardecode