diff --git a/CHANGELOG.md b/CHANGELOG.md index 979b0439..7b733611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this project should be documented in this file. - Fix the Slack token validation not accepting some tokens (#57) +### v0.0.4-dev + +- Add spinner while getting resources + ### v0.0.3 - Fix the _wrong catch_ for `3xx` status codes to be ignored in Directory Bruteforce (#56) diff --git a/README.md b/README.md index 29c03691..5c5f9821 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Kitabisa SecLab](https://img.shields.io/badge/kitabisa-security%20project-blue)](#) [![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen)](https://github.com/kitabisa/teler/blob/development/LICENSE) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) -[![Version](https://img.shields.io/badge/version-0.0.3-blueviolet)](https://github.com/kitabisa/teler/releases) +[![Version](https://img.shields.io/badge/version-0.0.4--dev-blueviolet)](https://github.com/kitabisa/teler/releases) [![Platform](https://img.shields.io/badge/platform-osx%2Flinux%2Fwindows-green)](#) [![GitHub issues](https://img.shields.io/github/issues/kitabisa/teler)](https://github.com/kitabisa/teler/issues) diff --git a/go.mod b/go.mod index e642b278..80faf7d7 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d + github.com/briandowns/spinner v1.11.1 github.com/bwmarrin/discordgo v0.22.0 github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f diff --git a/go.sum b/go.sum index e7b3aa58..7ce2b571 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0= +github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ= github.com/bwmarrin/discordgo v0.22.0 h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM= github.com/bwmarrin/discordgo v0.22.0/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= @@ -56,6 +58,7 @@ github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaB github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= @@ -172,8 +175,12 @@ github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczG github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -360,6 +367,7 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/internal/runner/constants.go b/internal/runner/constants.go index 7a2ca96a..e366b008 100644 --- a/internal/runner/constants.go +++ b/internal/runner/constants.go @@ -2,8 +2,8 @@ package runner const ( email = "infosec@kitabisa.com" - version = "0.0.3" - development = false + version = "0.0.4-dev" + development = true banner = ` __ __ / /____ / /__ ____ diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 9dd90e15..af8436d0 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -10,6 +10,7 @@ import ( func Exit(err string) { msg := "Error! " if err != "" { + println() for _, e := range strings.Split(strings.TrimSuffix(err, "\n"), "\n") { msg += e Show(msg) diff --git a/pkg/requests/resources.go b/pkg/requests/resources.go index c8c52eb9..e615b13c 100644 --- a/pkg/requests/resources.go +++ b/pkg/requests/resources.go @@ -6,7 +6,9 @@ import ( "os" "path/filepath" "reflect" + "time" + "github.com/briandowns/spinner" "github.com/projectdiscovery/gologger" "ktbs.dev/teler/common" "ktbs.dev/teler/pkg/cache" @@ -19,8 +21,13 @@ var ( exclude bool content []byte errCon error + spin *spinner.Spinner ) +func init() { + spin = spinner.New(spinner.CharSets[11], 90*time.Millisecond, spinner.WithWriter(os.Stderr)) +} + // Resources is to getting all available resources func Resources(options *common.Options) { rsrc = resource.Get() @@ -29,8 +36,14 @@ func Resources(options *common.Options) { func getRules(options *common.Options) { client := Client() - excludes := options.Configs.Rules.Threat.Excludes - isCached := options.Configs.Rules.Cache + + rules := options.Configs.Rules + excludes := rules.Threat.Excludes + isCached := rules.Cache + + if err := spin.Color("blue"); err != nil { + errors.Exit(err.Error()) + } for i := 0; i < len(rsrc.Threat); i++ { exclude = false @@ -49,14 +62,18 @@ func getRules(options *common.Options) { continue } - gologger.Infof("Getting \"%s\" resource...", cat) + spin.Suffix = " Getting \"" + cat + "\" resource..." if cache.Check() && isCached { content, errCon = ioutil.ReadFile(filepath.Join(cache.Path, fname)) if errCon != nil { cache.Purge() + + println() gologger.Labelf("Fail to get local resources. Retry...") getRules(options) + + spin.Restart() } } else { req, err := http.NewRequest("GET", "https://raw.githubusercontent.com/kitabisa/teler-resources/master/db/"+fname, nil) @@ -90,6 +107,8 @@ func getRules(options *common.Options) { threat.FieldByName("Content").SetString(string(content)) } + spin.Stop() + if isCached { cache.Update() }