Skip to content

Commit 4305de4

Browse files
authored
Merge pull request #20 from liamg/liamg-add-nc-flag
Add hide status codes flag (-z)
2 parents acb4219 + c8ea4c8 commit 4305de4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

cmd/scout/url.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ import (
1717
)
1818

1919
var statusCodes []string
20+
var hideStatusCodes []string
2021
var filename string
2122
var headers []string
2223
var extensions = []string{"php", "htm", "html", "txt"}
2324
var enableSpidering bool
24-
var proxy string
25-
var method = "GET"
2625

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

5756
var intStatusCodes []int
57+
var filteredStatusCodes []string
5858

5959
for _, code := range statusCodes {
60+
61+
var skip bool
62+
for _, ignoreCode := range hideStatusCodes {
63+
if ignoreCode == code {
64+
skip = true
65+
break
66+
}
67+
}
68+
if skip {
69+
continue
70+
}
71+
6072
i, err := strconv.Atoi(code)
6173
if err != nil {
6274
tml.Printf("<bold><red>Error:</red></bold> Invalid status code entered: %s.\n", code)
6375
os.Exit(1)
6476
}
77+
filteredStatusCodes = append(filteredStatusCodes, code)
6578
intStatusCodes = append(intStatusCodes, i)
6679
}
6780

6881
options := []scan.URLOption{
69-
scan.WithMethod(method),
7082
scan.WithPositiveStatusCodes(intStatusCodes),
7183
scan.WithTargetURL(*parsedURL),
7284
scan.WithResultChan(resultChan),
@@ -99,19 +111,10 @@ var urlCmd = &cobra.Command{
99111
parsedURL.String(),
100112
parallelism,
101113
strings.Join(extensions, ","),
102-
strings.Join(statusCodes, ","),
114+
strings.Join(filteredStatusCodes, ","),
103115
enableSpidering,
104116
)
105117

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

117120
waitChan := make(chan struct{})
@@ -190,11 +193,10 @@ func clearLine() {
190193
func init() {
191194
urlCmd.Flags().StringVarP(&filename, "filename", "f", filename, "Filename to seek in the directory being searched. Useful when all directories report 404 status.")
192195
urlCmd.Flags().StringSliceVarP(&statusCodes, "status-codes", "c", statusCodes, "HTTP status codes which indicate a positive find.")
196+
urlCmd.Flags().StringSliceVarP(&hideStatusCodes, "hide-status-codes", "z", hideStatusCodes, "HTTP status codes which should be hidden.")
193197
urlCmd.Flags().StringSliceVarP(&extensions, "extensions", "x", extensions, "File extensions to detect.")
194198
urlCmd.Flags().StringSliceVarP(&headers, "header", "H", headers, "Extra header to send with requests (can be specified multiple times).")
195199
urlCmd.Flags().BoolVarP(&enableSpidering, "spider", "s", enableSpidering, "Spider links within page content")
196-
urlCmd.Flags().StringVarP(&proxy, "proxy", "p", proxy, "HTTP Proxy to use")
197-
urlCmd.Flags().StringVarP(&method, "method", "m", method, "HTTP method (default: GET)")
198200

199201
rootCmd.AddCommand(urlCmd)
200202
}

0 commit comments

Comments
 (0)