Skip to content

Commit

Permalink
Final updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ameenmaali committed Mar 20, 2020
1 parent 3753446 commit 59ce76e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
38 changes: 20 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
)

type CliOptions struct {
ConfigFile string
Cookies string
Headers string
Verbose bool
Concurrency int
ConfigFile string
Cookies string
Headers string
Debug bool
Concurrency int
DecodedParams bool
SilentMode bool
SilentMode bool
}

type Config struct {
Expand Down Expand Up @@ -53,15 +53,15 @@ type RuleEvaluation struct {
}

type EvaluationResult struct {
RuleName string
RuleName string
RuleDescription string
InjectedUrl string
InjectedUrl string
}

type TaskData struct {
InjectedUrl string
RuleData Rule
RuleName string
RuleData Rule
RuleName string
}

var requestsSent int
Expand Down Expand Up @@ -133,6 +133,7 @@ func runEvaluation(resp Response, ruleData Rule, injectedUrl string, ruleName st
func main() {
printGreen := color.New(color.FgGreen).PrintfFunc()
printRed := color.New(color.FgRed).PrintfFunc()
printCyan := color.New(color.FgCyan).FprintfFunc()

err := VerifyFlags(&opts)
if err != nil {
Expand All @@ -153,7 +154,7 @@ func main() {
}

if !opts.SilentMode {
fmt.Fprintf(os.Stderr, "There are %v unique URL/Query String combinations. Time to inject each query string, 1 at a time!\n", len(urls))
printCyan(os.Stderr, "There are %v unique URL/Query String combinations. Time to inject each query string, 1 at a time!\n", len(urls))
}

tasks := make(chan TaskData)
Expand All @@ -168,7 +169,7 @@ func main() {
defer wg.Done()

for {
task, ok := <- tasks
task, ok := <-tasks
// Return if tasks are complete
if !ok {
return
Expand All @@ -178,20 +179,18 @@ func main() {
if err != nil {
continue
}
//fmt.Println(task.InjectedUrl)

requestsSent += 1

// Send an update every 1,000 requests
if !opts.SilentMode {
if requestsSent % 1000 == 0 {
if requestsSent%1000 == 0 {
secondsElapsed := time.Since(startTime).Seconds()
fmt.Fprintf(os.Stderr, "%v requests sent: %v requests per second\n", requestsSent, int(float64(requestsSent) / secondsElapsed))
fmt.Fprintf(os.Stderr, "%v requests sent: %v requests per second\n", requestsSent, int(float64(requestsSent)/secondsElapsed))
}
}

if err != nil {
if opts.Verbose {
if opts.Debug {
printRed("error sending HTTP request (%v)\n", task.InjectedUrl)
}
continue
Expand All @@ -209,7 +208,7 @@ func main() {
for rule, ruleData := range config.Rules {
injectedUrls, err := getInjectedUrls(u, ruleData.Injections)
if err != nil {
if opts.Verbose {
if opts.Debug {
printRed("[%v] error parsing URL or query parameters for\n", rule)
}
continue
Expand All @@ -225,4 +224,7 @@ func main() {

close(tasks)
wg.Wait()

secondsElapsed := time.Since(startTime).Seconds()
printCyan(os.Stderr, "Evaluations complete! %v requests sent: %v requests per second\n", requestsSent, int(float64(requestsSent)/secondsElapsed))
}
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func VerifyFlags(options *CliOptions) error {
flag.StringVar(&options.Headers, "H", "", "Headers to add in all requests. Multiple should be separated by semi-colon")
flag.StringVar(&options.Headers, "headers", "", "Headers to add in all requests. Multiple should be separated by semi-colon")

flag.BoolVar(&options.Verbose, "debug", false, "Debug/verbose mode to print more info for failed/malformed URLs or requests")
flag.BoolVar(&options.Debug, "debug", false, "Debug/verbose mode to print more info for failed/malformed URLs or requests")

flag.BoolVar(&options.SilentMode, "s", false, "Only print successful evaluations (i.e. mute status updates). Note these updates print to stderr, and won't be saved if saving stdout to files")
flag.BoolVar(&options.SilentMode, "silent", false, "Only print successful evaluations (i.e. mute status updates). Note these updates print to stderr, and won't be saved if saving stdout to files")
Expand Down

0 comments on commit 59ce76e

Please sign in to comment.