Skip to content

Commit 99719bb

Browse files
committed
add proxy option
1 parent 87620d6 commit 99719bb

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

cmd/scout/url.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var filename string
2121
var headers []string
2222
var extensions = []string{"php", "htm", "html", "txt"}
2323
var enableSpidering bool
24+
var proxy string
2425

2526
var urlCmd = &cobra.Command{
2627
Use: "url [url]",
@@ -100,6 +101,15 @@ var urlCmd = &cobra.Command{
100101
enableSpidering,
101102
)
102103

104+
if proxy != "" {
105+
proxyUrl, err := url.Parse(proxy)
106+
if err != nil {
107+
tml.Printf("<bold><red>Error:</red></bold> Invalid Proxy URL: %s\n", err)
108+
os.Exit(1)
109+
}
110+
options = append(options, scan.WithProxy(proxyUrl))
111+
}
112+
103113
scanner := scan.NewURLScanner(options...)
104114

105115
waitChan := make(chan struct{})
@@ -181,6 +191,7 @@ func init() {
181191
urlCmd.Flags().StringSliceVarP(&extensions, "extensions", "x", extensions, "File extensions to detect.")
182192
urlCmd.Flags().StringSliceVarP(&headers, "header", "H", headers, "Extra header to send with requests (can be specified multiple times).")
183193
urlCmd.Flags().BoolVarP(&enableSpidering, "spider", "s", enableSpidering, "Spider links within page content")
194+
urlCmd.Flags().StringVarP(&proxy, "proxy", "x", proxy, "HTTP Porxy to use")
184195

185196
rootCmd.AddCommand(urlCmd)
186197
}

pkg/scan/url_options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ func WithTargetURL(target url.URL) URLOption {
1616
}
1717
} // target url
1818

19+
// WithProxy sets the url to initiate scans from
20+
func WithProxy(proxy *url.URL) URLOption {
21+
return func(s *URLScanner) {
22+
s.proxy = proxy
23+
}
24+
} // target url
25+
1926
// WithPositiveStatusCodes provides status codes that indicate the existence of a file/directory
2027
func WithPositiveStatusCodes(codes []int) URLOption {
2128
return func(s *URLScanner) {

pkg/scan/url_scanner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type URLScanner struct {
4141
checkMutex sync.Mutex
4242
queueChan chan URLJob
4343
jobsLoaded int32
44+
proxy *url.URL
4445
}
4546

4647
type URLJob struct {
@@ -93,6 +94,10 @@ func NewURLScanner(options ...URLOption) *URLScanner {
9394
},
9495
}
9596

97+
if scanner.proxy != nil {
98+
scanner.client.Transport = &http.Transport{Proxy: http.ProxyURL(scanner.proxy)}
99+
}
100+
96101
if scanner.skipSSLVerification {
97102
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
98103
scanner.client.Transport = http.DefaultTransport

0 commit comments

Comments
 (0)