Skip to content

Commit

Permalink
Merge pull request #20 from liamg/liamg-add-nc-flag
Browse files Browse the repository at this point in the history
Add hide status codes flag (-z)
  • Loading branch information
liamg authored Jan 12, 2021
2 parents acb4219 + c8ea4c8 commit 4305de4
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cmd/scout/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import (
)

var statusCodes []string
var hideStatusCodes []string
var filename string
var headers []string
var extensions = []string{"php", "htm", "html", "txt"}
var enableSpidering bool
var proxy string
var method = "GET"

var urlCmd = &cobra.Command{
Use: "url [url]",
Expand Down Expand Up @@ -55,18 +54,31 @@ var urlCmd = &cobra.Command{
busyChan := make(chan string, 0x400)

var intStatusCodes []int
var filteredStatusCodes []string

for _, code := range statusCodes {

var skip bool
for _, ignoreCode := range hideStatusCodes {
if ignoreCode == code {
skip = true
break
}
}
if skip {
continue
}

i, err := strconv.Atoi(code)
if err != nil {
tml.Printf("<bold><red>Error:</red></bold> Invalid status code entered: %s.\n", code)
os.Exit(1)
}
filteredStatusCodes = append(filteredStatusCodes, code)
intStatusCodes = append(intStatusCodes, i)
}

options := []scan.URLOption{
scan.WithMethod(method),
scan.WithPositiveStatusCodes(intStatusCodes),
scan.WithTargetURL(*parsedURL),
scan.WithResultChan(resultChan),
Expand Down Expand Up @@ -99,19 +111,10 @@ var urlCmd = &cobra.Command{
parsedURL.String(),
parallelism,
strings.Join(extensions, ","),
strings.Join(statusCodes, ","),
strings.Join(filteredStatusCodes, ","),
enableSpidering,
)

if proxy != "" {
proxyUrl, err := url.Parse(proxy)
if err != nil {
tml.Printf("<bold><red>Error:</red></bold> Invalid Proxy URL: %s\n", err)
os.Exit(1)
}
options = append(options, scan.WithProxy(proxyUrl))
}

scanner := scan.NewURLScanner(options...)

waitChan := make(chan struct{})
Expand Down Expand Up @@ -190,11 +193,10 @@ func clearLine() {
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(&hideStatusCodes, "hide-status-codes", "z", hideStatusCodes, "HTTP status codes which should be hidden.")
urlCmd.Flags().StringSliceVarP(&extensions, "extensions", "x", extensions, "File extensions to detect.")
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")
urlCmd.Flags().StringVarP(&proxy, "proxy", "p", proxy, "HTTP Proxy to use")
urlCmd.Flags().StringVarP(&method, "method", "m", method, "HTTP method (default: GET)")

rootCmd.AddCommand(urlCmd)
}

0 comments on commit 4305de4

Please sign in to comment.