Projects STRLCPY csprecon Commits ddd72bdf
🤬
  • ■ ■ ■ ■
    README.md
    skipped 51 lines
    52 52   File to write output results
    53 53   -s Print only results
    54 54   -t int
    55  - Connection timeout in seconds (default 4)
     55 + Connection timeout in seconds (default 10)
    56 56   -u string
    57 57   Input domain
    58 58   -v Verbose output
    skipped 45 lines
  • ■ ■ ■ ■ ■ ■
    pkg/csprecon/csp.go
    skipped 8 lines
    9 9   "strings"
    10 10   "time"
    11 11   
     12 + "github.com/edoardottt/golazy"
    12 13   "golang.org/x/net/html"
    13 14  )
    14 15   
    skipped 39 lines
    54 55  func parseCSP(input string, r *regexp.Regexp) []string {
    55 56   result := []string{}
    56 57   
     58 + var err error
     59 + 
    57 60   splitted := strings.Split(input, ";")
    58 61   
    59 62   for _, elem := range splitted {
    60 63   spaceSplit := strings.Split(elem, " ")
    61 64   for _, spaceElem := range spaceSplit {
    62 65   if r.Match([]byte(spaceElem)) {
     66 + if strings.Contains(spaceElem, "://") {
     67 + spaceElem, err = golazy.GetHost(spaceElem)
     68 + if err != nil {
     69 + continue
     70 + }
     71 + }
    63 72   result = append(result, spaceElem)
    64 73   }
    65 74   }
    skipped 65 lines
  • ■ ■ ■ ■ ■ ■
    pkg/csprecon/csprecon.go
    skipped 2 lines
    3 3  import (
    4 4   "bufio"
    5 5   "fmt"
    6  - "net/http"
    7 6   "os"
    8 7   "regexp"
    9 8   "strings"
    skipped 7 lines
    17 16  )
    18 17   
    19 18  type Runner struct {
    20  - Client *http.Client
    21 19   Input chan string
    22 20   Output chan string
    23 21   InWg *sync.WaitGroup
    skipped 3 lines
    27 25   
    28 26  func New(options *input.Options) Runner {
    29 27   return Runner{
    30  - Client: customClient(options.Timeout),
    31 28   Input: make(chan string, options.Concurrency),
    32 29   Output: make(chan string, options.Concurrency),
    33 30   InWg: &sync.WaitGroup{},
    skipped 52 lines
    86 83   
    87 84   dregex := CompileRegex(DomainRegex)
    88 85   
    89  - for value := range r.Input {
     86 + for i := 0; i < r.Options.Concurrency; i++ {
    90 87   r.InWg.Add(1)
    91 88   
    92  - go func(value string) {
     89 + go func() {
    93 90   defer r.InWg.Done()
    94  - result, err := checkCSP(value, dregex, r.Client)
    95 91   
    96  - if err == nil {
     92 + for value := range r.Input {
     93 + client := customClient(r.Options.Timeout)
     94 + 
     95 + result, err := checkCSP(value, dregex, client)
     96 + if err != nil {
     97 + if r.Options.Verbose {
     98 + gologger.Error().Msgf("%s", err)
     99 + }
     100 + 
     101 + return
     102 + }
     103 + 
    97 104   for _, res := range result {
    98 105   if resTrimmed := strings.TrimSpace(res); resTrimmed != "" {
    99 106   if r.Options.Domain != "" {
    skipped 5 lines
    105 112   }
    106 113   }
    107 114   }
    108  - } else {
    109  - if r.Options.Verbose {
    110  - gologger.Error().Msgf("%s", err)
    111  - }
    112 115   }
    113  - }(value)
     116 + }()
    114 117   }
    115 118  }
    116 119   
    skipped 35 lines
  • ■ ■ ■ ■
    pkg/input/flags.go
    skipped 12 lines
    13 13  )
    14 14   
    15 15  const (
    16  - DefaultTimeout = 4
     16 + DefaultTimeout = 10
    17 17   DefaultConcurrency = 100
    18 18  )
    19 19   
    skipped 66 lines
  • ■ ■ ■ ■ ■
    pkg/output/banner.go
    skipped 6 lines
    7 7   
    8 8  const (
    9 9   Version = "v0.0.1"
    10  - banner = `
    11  - ______________ ________ _________ ____
     10 + banner = ` ______________ ________ _________ ____
    12 11   / ___/ ___/ __ \/ ___/ _ \/ ___/ __ \/ __ \
    13 12   / /__(__ ) /_/ / / / __/ /__/ /_/ / / / /
    14 13   \___/____/ .___/_/ \___/\___/\____/_/ /_/
    skipped 13 lines
Please wait...
Page is in error, reload to recover