diff --git a/v2/cmd/subfinder/main.go b/v2/cmd/subfinder/main.go index d955d51..ac42492 100644 --- a/v2/cmd/subfinder/main.go +++ b/v2/cmd/subfinder/main.go @@ -15,11 +15,11 @@ func main() { newRunner, err := runner.NewRunner(options) if err != nil { - gologger.Fatalf("Could not create runner: %s\n", err) + gologger.Fatal().Msgf("Could not create runner: %s\n", err) } err = newRunner.RunEnumeration(context.Background()) if err != nil { - gologger.Fatalf("Could not run enumeration: %s\n", err) + gologger.Fatal().Msgf("Could not run enumeration: %s\n", err) } } diff --git a/v2/go.mod b/v2/go.mod index fe02efe..749d857 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -5,14 +5,23 @@ go 1.14 require ( github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026 github.com/json-iterator/go v1.1.10 + github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.9.0 - github.com/miekg/dns v1.1.35 + github.com/logrusorgru/aurora v2.0.3+incompatible // indirect + github.com/miekg/dns v1.1.38 + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect github.com/pkg/errors v0.9.1 - github.com/projectdiscovery/chaos-client v0.1.6 + github.com/projectdiscovery/chaos-client v0.1.7 github.com/projectdiscovery/fdmax v0.0.3 - github.com/projectdiscovery/gologger v1.0.1 + github.com/projectdiscovery/gologger v1.1.3 github.com/rs/xid v1.2.1 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.7.0 github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 - gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 + golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect + golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect + golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect + golang.org/x/sys v0.0.0-20210217105451-b926d437f341 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) diff --git a/v2/go.sum b/v2/go.sum index 517bc48..029ac02 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,3 +1,4 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -6,56 +7,88 @@ github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026 h1:BpJ2o0OR5FV7vrkDYf github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs= -github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= +github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/miekg/dns v1.1.38 h1:MtIY+fmHUVVgv1AXzmKMWcwdCYxTRPG1EDjpqF4RCEw= +github.com/miekg/dns v1.1.38/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/projectdiscovery/chaos-client v0.1.6 h1:AbIN7xUszjUi7FxI4qUVSqJ3um+6eImE/xstbNS0A1M= -github.com/projectdiscovery/chaos-client v0.1.6/go.mod h1:F5omaoJh/vMvWnZhKD4zFFA5ti+RPwUletwepKSyfxk= +github.com/projectdiscovery/chaos-client v0.1.7 h1:8M1LazT+lD3qJP1ERWXiVzQn9lPMO3p6v3qsiGNKUlQ= +github.com/projectdiscovery/chaos-client v0.1.7/go.mod h1:F5omaoJh/vMvWnZhKD4zFFA5ti+RPwUletwepKSyfxk= github.com/projectdiscovery/fdmax v0.0.3 h1:FM6lv9expZ/rEEBI9tkRh6tx3DV0gtpwzdc0h7bGPqg= github.com/projectdiscovery/fdmax v0.0.3/go.mod h1:NWRcaR7JTO7fC27H4jCl9n7Z+KIredwpgw1fV+4KrKI= github.com/projectdiscovery/gologger v1.0.0/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= -github.com/projectdiscovery/gologger v1.0.1 h1:FzoYQZnxz9DCvSi/eg5A6+ET4CQ0CDUs27l6Exr8zMQ= -github.com/projectdiscovery/gologger v1.0.1/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= +github.com/projectdiscovery/gologger v1.1.3 h1:rKWZW2QUigRV1jnlWwWJbJRvz8b+T/+bB5qemDGGBJU= +github.com/projectdiscovery/gologger v1.1.3/go.mod h1:jdXflz3TLB8bcVNzb0v26TztI9KPz8Lr4BVdUhNUs6E= github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 h1:kzM6+9dur93BcC2kVlYl34cHU+TYZLanmpSJHVMmL64= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210217105451-b926d437f341 h1:2/QtM1mL37YmcsT8HaDNHDgTqqFVw+zr8UzMiBVLzYU= +golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/v2/pkg/passive/passive.go b/v2/pkg/passive/passive.go index d4be059..4843f33 100644 --- a/v2/pkg/passive/passive.go +++ b/v2/pkg/passive/passive.go @@ -47,7 +47,7 @@ func (a *Agent) EnumerateSubdomains(domain string, keys *subscraping.Keys, timeo wg.Wait() for source, data := range timeTaken { - gologger.Verbosef(data, source) + gologger.Verbose().Msgf(data, source) } close(results) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index b7ff55e..f6fa611 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -18,19 +18,19 @@ const Version = `2.4.5` // showBanner is used to show the banner to the user func showBanner() { - gologger.Printf("%s\n", banner) - gologger.Printf("\t\tprojectdiscovery.io\n\n") + gologger.Print().Msgf("%s\n", banner) + gologger.Print().Msgf("\t\tprojectdiscovery.io\n\n") - gologger.Labelf("Use with caution. You are responsible for your actions\n") - gologger.Labelf("Developers assume no liability and are not responsible for any misuse or damage.\n") - gologger.Labelf("By using subfinder, you also agree to the terms of the APIs used.\n\n") + gologger.Print().Msgf("Use with caution. You are responsible for your actions\n") + gologger.Print().Msgf("Developers assume no liability and are not responsible for any misuse or damage.\n") + gologger.Print().Msgf("By using subfinder, you also agree to the terms of the APIs used.\n\n") } // normalRunTasks runs the normal startup tasks func (options *Options) normalRunTasks() { configFile, err := UnmarshalRead(options.ConfigFile) if err != nil { - gologger.Fatalf("Could not read configuration file %s: %s\n", options.ConfigFile, err) + gologger.Fatal().Msgf("Could not read configuration file %s: %s\n", options.ConfigFile, err) } // If we have a different version of subfinder installed @@ -43,7 +43,7 @@ func (options *Options) normalRunTasks() { err = configFile.MarshalWrite(options.ConfigFile) if err != nil { - gologger.Fatalf("Could not update configuration file to %s: %s\n", options.ConfigFile, err) + gologger.Fatal().Msgf("Could not update configuration file to %s: %s\n", options.ConfigFile, err) } } options.YAMLConfig = configFile @@ -67,9 +67,9 @@ func (options *Options) firstRunTasks() { err := config.MarshalWrite(options.ConfigFile) if err != nil { - gologger.Fatalf("Could not write configuration file to %s: %s\n", options.ConfigFile, err) + gologger.Fatal().Msgf("Could not write configuration file to %s: %s\n", options.ConfigFile, err) } options.YAMLConfig = config - gologger.Infof("Configuration file saved to %s\n", options.ConfigFile) + gologger.Info().Msgf("Configuration file saved to %s\n", options.ConfigFile) } diff --git a/v2/pkg/runner/chaosuploader.go b/v2/pkg/runner/chaosuploader.go index eab1e17..442bd8f 100644 --- a/v2/pkg/runner/chaosuploader.go +++ b/v2/pkg/runner/chaosuploader.go @@ -42,7 +42,7 @@ func (r *Runner) UploadToChaos(ctx context.Context, reader io.Reader) error { defer func() { _, err := io.Copy(ioutil.Discard, resp.Body) if err != nil { - gologger.Warningf("Could not discard response body: %s\n", err) + gologger.Warning().Msgf("Could not discard response body: %s\n", err) return } resp.Body.Close() diff --git a/v2/pkg/runner/enumerate.go b/v2/pkg/runner/enumerate.go index 3183ecf..34402f0 100644 --- a/v2/pkg/runner/enumerate.go +++ b/v2/pkg/runner/enumerate.go @@ -18,7 +18,7 @@ const maxNumCount = 2 // EnumerateSingleDomain performs subdomain enumeration against a single domain func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output string, appendToFile bool) error { - gologger.Infof("Enumerating subdomains for %s\n", domain) + gologger.Info().Msgf("Enumerating subdomains for %s\n", domain) // Get the API keys for sources from the configuration // and also create the active resolving engine for the domain. @@ -32,7 +32,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin err := resolutionPool.InitWildcards(domain) if err != nil { // Log the error but don't quit. - gologger.Warningf("Could not get wildcards for domain %s: %s\n", domain, err) + gologger.Warning().Msgf("Could not get wildcards for domain %s: %s\n", domain, err) } } @@ -51,7 +51,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin for result := range passiveResults { switch result.Type { case subscraping.Error: - gologger.Warningf("Could not run source %s: %s\n", result.Source, result.Error) + gologger.Warning().Msgf("Could not run source %s: %s\n", result.Source, result.Error) case subscraping.Subdomain: // Validate the subdomain found and remove wildcards from if !strings.HasSuffix(result.Value, "."+domain) { @@ -65,7 +65,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin // Log the verbose message about the found subdomain per source if _, ok := sourceMap[subdomain][result.Source]; !ok { - gologger.Verbosef("%s\n", result.Source, subdomain) + gologger.Verbose().Msgf("%s\n", result.Source, subdomain) } sourceMap[subdomain][result.Source] = struct{}{} @@ -103,7 +103,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin for result := range resolutionPool.Results { switch result.Type { case resolve.Error: - gologger.Warningf("Could not resolve host: %s\n", result.Error) + gologger.Warning().Msgf("Could not resolve host: %s\n", result.Error) case resolve.Subdomain: // Add the found subdomain to a map. if _, ok := foundResults[result.Host]; !ok { @@ -133,16 +133,16 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin } } if err != nil { - gologger.Errorf("Could not verbose results for %s: %s\n", domain, err) + gologger.Error().Msgf("Could not verbose results for %s: %s\n", domain, err) return err } // Show found subdomain count in any case. duration := durafmt.Parse(time.Since(now)).LimitFirstN(maxNumCount).String() if r.options.RemoveWildcard { - gologger.Infof("Found %d subdomains for %s in %s\n", len(foundResults), domain, duration) + gologger.Info().Msgf("Found %d subdomains for %s in %s\n", len(foundResults), domain, duration) } else { - gologger.Infof("Found %d subdomains for %s in %s\n", len(uniqueMap), domain, duration) + gologger.Info().Msgf("Found %d subdomains for %s in %s\n", len(uniqueMap), domain, duration) } // In case the user has specified to upload to chaos, write everything to a temporary buffer and upload @@ -151,14 +151,14 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin err := outputter.WriteForChaos(uniqueMap, buf) // If an error occurs, do not interrupt, continue to check if user specified an output file if err != nil { - gologger.Errorf("Could not prepare results for chaos %s\n", err) + gologger.Error().Msgf("Could not prepare results for chaos %s\n", err) } else { // no error in writing host output, upload to chaos err = r.UploadToChaos(ctx, buf) if err != nil { - gologger.Errorf("Could not upload results to chaos %s\n", err) + gologger.Error().Msgf("Could not upload results to chaos %s\n", err) } else { - gologger.Infof("Input processed successfully and subdomains with valid records will be updated to chaos dataset.\n") + gologger.Info().Msgf("Input processed successfully and subdomains with valid records will be updated to chaos dataset.\n") } // clear buffer buf.Reset() @@ -168,7 +168,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin if output != "" { file, err := outputter.createFile(output, appendToFile) if err != nil { - gologger.Errorf("Could not create file %s for %s: %s\n", output, domain, err) + gologger.Error().Msgf("Could not create file %s for %s: %s\n", output, domain, err) return err } @@ -188,7 +188,7 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain, output strin } } if err != nil { - gologger.Errorf("Could not write results to file %s for %s: %s\n", output, domain, err) + gologger.Error().Msgf("Could not write results to file %s for %s: %s\n", output, domain, err) return err } } diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index ee76d40..321befc 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -49,7 +49,7 @@ func ParseOptions() *Options { config, err := GetConfigDirectory() if err != nil { // This should never be reached - gologger.Fatalf("Could not get user home: %s\n", err) + gologger.Fatal().Msgf("Could not get user home: %s\n", err) } flag.BoolVar(&options.Verbose, "v", false, "Show Verbose output") @@ -89,7 +89,7 @@ func ParseOptions() *Options { showBanner() if options.Version { - gologger.Infof("Current Version: %s\n", Version) + gologger.Info().Msgf("Current Version: %s\n", Version) os.Exit(0) } @@ -111,7 +111,7 @@ func ParseOptions() *Options { // invalid options have been used, exit. err = options.validateOptions() if err != nil { - gologger.Fatalf("Program exiting: %s\n", err) + gologger.Fatal().Msgf("Program exiting: %s\n", err) } return options @@ -130,9 +130,9 @@ func hasStdin() bool { } func listSources(options *Options) { - gologger.Infof("Current list of available sources. [%d]\n", len(options.YAMLConfig.AllSources)) - gologger.Infof("Sources marked with an * needs key or token in order to work.\n") - gologger.Infof("You can modify %s to configure your keys / tokens.\n\n", options.ConfigFile) + gologger.Info().Msgf("Current list of available sources. [%d]\n", len(options.YAMLConfig.AllSources)) + gologger.Info().Msgf("Sources marked with an * needs key or token in order to work.\n") + gologger.Info().Msgf("You can modify %s to configure your keys / tokens.\n\n", options.ConfigFile) keys := options.YAMLConfig.GetKeys() needsKey := make(map[string]interface{}) @@ -146,6 +146,6 @@ func listSources(options *Options) { if _, ok := needsKey[source]; ok { message = "%s *\n" } - gologger.Silentf(message, source) + gologger.Silent().Msgf(message, source) } } diff --git a/v2/pkg/runner/validate.go b/v2/pkg/runner/validate.go index 25d58be..1f833ca 100644 --- a/v2/pkg/runner/validate.go +++ b/v2/pkg/runner/validate.go @@ -4,6 +4,8 @@ import ( "errors" "github.com/projectdiscovery/gologger" + "github.com/projectdiscovery/gologger/formatter" + "github.com/projectdiscovery/gologger/levels" ) // validateOptions validates the configuration options passed @@ -39,12 +41,12 @@ func (options *Options) validateOptions() error { func (options *Options) configureOutput() { // If the user desires verbose output, show verbose output if options.Verbose { - gologger.MaxLevel = gologger.Verbose + gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose) } if options.NoColor { - gologger.UseColors = false + gologger.DefaultLogger.SetFormatter(formatter.NewCLI(true)) } if options.Silent { - gologger.MaxLevel = gologger.Silent + gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent) } } diff --git a/v2/pkg/subscraping/agent.go b/v2/pkg/subscraping/agent.go index 31cff36..b4c89ec 100755 --- a/v2/pkg/subscraping/agent.go +++ b/v2/pkg/subscraping/agent.go @@ -90,7 +90,7 @@ func (s *Session) DiscardHTTPResponse(response *http.Response) { if response != nil { _, err := io.Copy(ioutil.Discard, response.Body) if err != nil { - gologger.Warningf("Could not discard response body: %s\n", err) + gologger.Warning().Msgf("Could not discard response body: %s\n", err) return } response.Body.Close() diff --git a/v2/pkg/subscraping/sources/github/github.go b/v2/pkg/subscraping/sources/github/github.go index d384de8..e0d42ba 100644 --- a/v2/pkg/subscraping/sources/github/github.go +++ b/v2/pkg/subscraping/sources/github/github.go @@ -69,7 +69,7 @@ func (s *Source) enumerate(ctx context.Context, searchURL string, domainRegexp * if token.RetryAfter > 0 { if len(tokens.pool) == 1 { - gologger.Verbosef("GitHub Search request rate limit exceeded, waiting for %d seconds before retry... \n", s.Name(), token.RetryAfter) + gologger.Verbose().Msgf("GitHub Search request rate limit exceeded, waiting for %d seconds before retry... \n", s.Name(), token.RetryAfter) time.Sleep(time.Duration(token.RetryAfter) * time.Second) } else { token = tokens.Get()