Skip to content

Commit

Permalink
Merge pull request #13 from liamg/liamg-multiple-custom-headers
Browse files Browse the repository at this point in the history
Allow specifying -H multiple times
  • Loading branch information
liamg authored Jul 16, 2020
2 parents d05d1ed + 160887b commit 87620d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cmd/scout/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

var statusCodes []string
var filename string
var header string
var headers []string
var extensions = []string{"php", "htm", "html", "txt"}
var enableSpidering bool

Expand Down Expand Up @@ -72,7 +72,7 @@ var urlCmd = &cobra.Command{
scan.WithExtensions(extensions),
scan.WithFilename(filename),
scan.WithSkipSSLVerification(skipSSLVerification),
scan.WithExtraHeader(header),
scan.WithExtraHeaders(headers),
scan.WithSpidering(enableSpidering),
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func init() {
urlCmd.Flags().StringVarP(&filename, "filename", "f", filename, "Filename to seek in the directory being searched. Useful when all directories report 404 status.")
urlCmd.Flags().StringSliceVarP(&statusCodes, "status-codes", "c", statusCodes, "HTTP status codes which indicate a positive find.")
urlCmd.Flags().StringSliceVarP(&extensions, "extensions", "x", extensions, "File extensions to detect.")
urlCmd.Flags().StringVarP(&header, "header", "H", header, "Extra header to send with requests.")
urlCmd.Flags().StringSliceVarP(&headers, "header", "H", headers, "Extra header to send with requests (can be specified multiple times).")
urlCmd.Flags().BoolVarP(&enableSpidering, "spider", "s", enableSpidering, "Spider links within page content")

rootCmd.AddCommand(urlCmd)
Expand Down
4 changes: 2 additions & 2 deletions pkg/scan/url_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func WithBackupExtensions(backupExtensions []string) URLOption {
}
}

func WithExtraHeader(header string) URLOption {
func WithExtraHeaders(headers []string) URLOption {
return func(s *URLScanner) {
s.extraHeader = header
s.extraHeaders = append(s.extraHeaders, headers...)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/scan/url_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type URLScanner struct {
filename string
skipSSLVerification bool
backupExtensions []string
extraHeader string
extraHeaders []string
enableSpidering bool
checked map[string]struct{}
checkMutex sync.Mutex
Expand Down Expand Up @@ -269,8 +269,8 @@ func (scanner *URLScanner) checkURL(job URLJob) *URLResult {
return err
}

if scanner.extraHeader != "" {
parts := strings.SplitN(scanner.extraHeader, ":", 2)
for _, header := range scanner.extraHeaders {
parts := strings.SplitN(header, ":", 2)
if len(parts) == 2 {
req.Header.Set(parts[0], strings.TrimPrefix(parts[1], " "))
}
Expand Down

0 comments on commit 87620d6

Please sign in to comment.