Skip to content

Commit

Permalink
Adding retry + timeout flag
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ssie committed Nov 27, 2022
1 parent 351411d commit 3974823
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ func init() {
}
// scan options
scanCmd.Flags().StringVarP(&options.Scan.Ports, "ports", "p", "0-65535", "Port range for previous command")
scanCmd.Flags().StringVarP(&options.Scan.Rate, "rate", "r", "3000", "rate limit for masscan command")
scanCmd.Flags().StringVarP(&options.Scan.Rate, "rate", "r", "3000", "rate limit for rustscan command")
scanCmd.Flags().StringVar(&options.Scan.Retry, "retry", "", "retry limit for rustscan command")
scanCmd.Flags().StringVar(&options.Scan.Timeout, "timeout", "", "timeout for rustscan command")
scanCmd.Flags().BoolVarP(&options.Scan.All, "join", "A", false, "Join all inputs to a file first then do a scan")
// scan strategy option
scanCmd.Flags().BoolVarP(&options.Scan.Flat, "flat", "f", true, "format output like this: 1.2.3.4:443")
Expand Down
2 changes: 2 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type CertOptions struct {
type ScanOptions struct {
Ports string
Rate string
Retry string
Timeout string
NmapTemplate string
NmapOverview bool
ZmapOverview bool
Expand Down
13 changes: 12 additions & 1 deletion modules/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ func RunRustScan(input string, options core.Options) (results []string) {
if strings.Contains(options.Scan.Ports, ",") || !strings.Contains(options.Scan.Ports, "-") {
ports = fmt.Sprintf("--ports %v", options.Scan.Ports)
}
rustscanCmd := fmt.Sprintf("rustscan --timeout 3000 -b %v --scripts None %v -a %v -g >> %v", options.Scan.Rate, ports, input, tmpOutput)

prefix := fmt.Sprintf("rustscan -b %v", options.Scan.Rate)
if options.Scan.Timeout != "" {
prefix += fmt.Sprintf(" --timeout %v", options.Scan.Timeout)
} else {
prefix += " --timeout 3000 "
}
if options.Scan.Retry != "" {
prefix += fmt.Sprintf(" --tries %v", options.Scan.Retry)
}

rustscanCmd := fmt.Sprintf("%v %v --scripts None -a %v -g >> %v", prefix, ports, input, tmpOutput)
runOSCommand(rustscanCmd)

core.InforF("Parsing result from: %v", tmpOutput)
Expand Down

0 comments on commit 3974823

Please sign in to comment.