From 548395a287c24f002bd16b72fde353d9f13a6241 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Fri, 1 May 2020 17:27:33 +0200 Subject: [PATCH] verbose proxy url validation --- go.mod | 2 +- go.sum | 4 ++-- internal/runner/validate.go | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4aa12abb..ae54f776 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,6 @@ require ( github.com/projectdiscovery/gologger v1.0.0 github.com/projectdiscovery/retryabledns v1.0.4 github.com/projectdiscovery/retryablehttp-go v1.0.1 - golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 + golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 gopkg.in/yaml.v2 v2.2.8 ) diff --git a/go.sum b/go.sum index a242a457..e34472c1 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB 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/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U= -golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20190423024810-112230192c58/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= diff --git a/internal/runner/validate.go b/internal/runner/validate.go index 786c84cc..30a19a33 100644 --- a/internal/runner/validate.go +++ b/internal/runner/validate.go @@ -2,6 +2,7 @@ package runner import ( "errors" + "net/url" "github.com/projectdiscovery/gologger" ) @@ -21,9 +22,26 @@ func (options *Options) validateOptions() error { if options.Targets == "" && !options.Stdin { return errors.New("no target input provided") } + + // Validate proxy options if provided + if options.ProxyURL != "" && !isValidProxyURL(options.ProxyURL) { + return errors.New("invalid http proxy format (It should be http(s)://username:password@host:port)") + } + if options.ProxySocksURL != "" && !isValidProxyURL(options.ProxySocksURL) { + return errors.New("invalid socks proxy format (It should be socks5://username:password@host:port)") + } + return nil } +func isValidProxyURL(URL string) bool { + if _, err := url.Parse(URL); err != nil { + return false + } + + return true +} + // configureOutput configures the output on the screen func (options *Options) configureOutput() { // If the user desires verbose output, show verbose output