From bd0e747183cf6df217cdf8154b830f45cfd7e82c Mon Sep 17 00:00:00 2001 From: edoardottt Date: Wed, 22 Sep 2021 17:34:12 +0200 Subject: [PATCH] Add Proxy mode #13 --- README.md | 7 +++++-- crawler/colly.go | 13 +++++++++++-- input/flags.go | 3 +++ main.go | 2 +- output/examples.go | 4 +++- output/help.go | 2 ++ 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 49c27a2..0d2d269 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ Usage of cariddi: Write the output into a TXT file. -plain Print only the results. + -proxy string + Set a Proxy to be used (http and socks5 supported). -rua Use a random browser user agent on every request. -s Hunt for secrets. @@ -163,6 +165,7 @@ Examples 💡 - `cat urls | cariddi -t 5` (Set the timeout for the requests) - `cat urls | cariddi -intensive` (Crawl searching for any resource under 2nd level domain (`*.target.com`)) - `cat urls | cariddi -rua` (Use a random browser user agent on every request) + - `cat urls | cariddi -proxy http://127.0.0.1:8080` (Set a Proxy to be used (http and socks5 supported)) - For Windows: - use `powershell.exe -Command "cat urls | .\cariddi.exe"` inside the Command prompt @@ -185,11 +188,11 @@ A special thanks to: - [ ] Tests (😂) - [ ] Tor support - - - [ ] Proxy support - [ ] Cookie support + - [x] Proxy support + - [x] Ignore specific types of urls - [x] Plain output (print only results) diff --git a/crawler/colly.go b/crawler/colly.go index 08298b6..39bd7a5 100644 --- a/crawler/colly.go +++ b/crawler/colly.go @@ -40,8 +40,8 @@ import ( //Crawler it's the actual crawler core func Crawler(target string, txt string, html string, delayTime int, concurrency int, ignore string, - ignoreTxt string, cache bool, timeout int, intensive bool, rua bool, secrets bool, secretsFile []string, - plain bool, endpoints bool, endpointsFile []string, + ignoreTxt string, cache bool, timeout int, intensive bool, rua bool, proxy string, secrets bool, + secretsFile []string, plain bool, endpoints bool, endpointsFile []string, fileType int) ([]string, []scanner.SecretMatched, []scanner.EndpointMatched, []scanner.FileTypeMatched) { // This is to avoid to insert into the crawler target regular @@ -124,6 +124,15 @@ func Crawler(target string, txt string, html string, delayTime int, concurrency extensions.RandomUserAgent(c) } + // Use a Proxy if needed + if proxy != "" { + err := c.SetProxy(proxy) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + } + // On every a element which has href attribute call callback c.OnHTML("a[href]", func(e *colly.HTMLElement) { link := e.Attr("href") diff --git a/input/flags.go b/input/flags.go index c44c294..35faf01 100644 --- a/input/flags.go +++ b/input/flags.go @@ -43,6 +43,7 @@ type Input struct { Timeout int Intensive bool Rua bool + Proxy string Secrets bool SecretsFile string Endpoints bool @@ -68,6 +69,7 @@ func ScanFlag() Input { timeoutPtr := flag.Int("t", 10, "Set timeout for the requests.") intensivePtr := flag.Bool("intensive", false, "Crawl searching for resources matching 2nd level domain.") ruaPtr := flag.Bool("rua", false, "Use a random browser user agent on every request.") + proxyPtr := flag.String("proxy", "", "Set a Proxy to be used (http and socks5 supported).") secretsPtr := flag.Bool("s", false, "Hunt for secrets.") secretsFilePtr := flag.String("sf", "", "Use an external file (txt, one per line) to use custom regexes for secrets hunting.") @@ -94,6 +96,7 @@ func ScanFlag() Input { *timeoutPtr, *intensivePtr, *ruaPtr, + *proxyPtr, *secretsPtr, *secretsFilePtr, *endpointsPtr, diff --git a/main.go b/main.go index 4cb95c0..1b91feb 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,7 @@ func main() { results, secrets, endpoints, extensions := crawler.Crawler(inp, ResultTxt, ResultHtml, flags.Delay, flags.Concurrency, flags.Ignore, flags.IgnoreTxt, flags.Cache, flags.Timeout, flags.Intensive, - flags.Rua, flags.Secrets, secretsFileSlice, flags.Plain, flags.Endpoints, endpointsFileSlice, + flags.Rua, flags.Proxy, flags.Secrets, secretsFileSlice, flags.Plain, flags.Endpoints, endpointsFileSlice, flags.Extensions) finalResults = append(finalResults, results...) diff --git a/output/examples.go b/output/examples.go index 0f0a471..ba3c7a2 100644 --- a/output/examples.go +++ b/output/examples.go @@ -65,5 +65,7 @@ func PrintExamples() { cat urls | cariddi -intensive (Crawl searching for resources matching 2nd level domain) - cat urls | cariddi -rua (Use a random browser user agent on every request)`) + cat urls | cariddi -rua (Use a random browser user agent on every request) + + cat urls | cariddi -proxy http://127.0.0.1:8080 (Set a Proxy to be used (http and socks5 supported))`) } diff --git a/output/help.go b/output/help.go index b089cc7..287f4d7 100644 --- a/output/help.go +++ b/output/help.go @@ -55,6 +55,8 @@ func PrintHelp() { Write the output into a TXT file. -plain Print only the results. + -proxy string + Set a Proxy to be used (http and socks5 supported). -rua Use a random browser user agent on every request. -s Hunt for secrets.