Projects STRLCPY csprecon Commits 2e281892
🤬
  • ■ ■ ■ ■
    go.mod
    skipped 12 lines
    13 13  require (
    14 14   github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
    15 15   github.com/aymerick/douceur v0.2.0 // indirect
    16  - github.com/edoardottt/golazy v0.1.2-dev
     16 + github.com/edoardottt/golazy v0.1.3-dev
    17 17   github.com/gorilla/css v1.0.0 // indirect
    18 18   github.com/json-iterator/go v1.1.10 // indirect
    19 19   github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
    skipped 11 lines
  • ■ ■ ■ ■ ■ ■
    go.sum
    skipped 9 lines
    10 10  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
    11 11  github.com/edoardottt/golazy v0.1.2-dev h1:P2MEUKVKJi42DPihjmjddinw2oALmGa6c20K1aouTNA=
    12 12  github.com/edoardottt/golazy v0.1.2-dev/go.mod h1:uZRa3TRYvQSxmbAc7O9+3RelkMu+ACbKiUoy+uPsGVM=
     13 +github.com/edoardottt/golazy v0.1.3-dev h1:RRnMtrc1Z5xkFXOfsXQNTN7qwmjcLZw49li7Bn5xWVA=
     14 +github.com/edoardottt/golazy v0.1.3-dev/go.mod h1:uZRa3TRYvQSxmbAc7O9+3RelkMu+ACbKiUoy+uPsGVM=
    13 15  github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
    14 16  github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
    15 17  github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
    skipped 59 lines
  • ■ ■ ■ ■
    pkg/csprecon/csp.go
    skipped 16 lines
    17 17   DomainRegex = `.*[a-zA-Z\_\-0-9]+\.[a-z]+`
    18 18  )
    19 19   
    20  -func checkCSP(url string, rCSP *regexp.Regexp, client *http.Client) ([]string, error) {
     20 +func checkCSP(url, ua string, rCSP *regexp.Regexp, client *http.Client) ([]string, error) {
    21 21   var (
    22 22   result = []string{}
    23 23   headerCSP []string
    skipped 3 lines
    27 27   if err != nil {
    28 28   return result, err
    29 29   }
     30 + 
     31 + req.Header.Add("User-Agent", ua)
    30 32   
    31 33   resp, err := client.Do(req)
    32 34   if err != nil {
    skipped 36 lines
    69 71  func customClient(timeout int) *http.Client {
    70 72   transport := http.Transport{
    71 73   TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
     74 + Proxy: http.ProxyFromEnvironment,
    72 75   Dial: (&net.Dialer{
    73 76   Timeout: time.Duration(timeout) * time.Second,
    74 77   KeepAlive: KeepAlive * time.Second,
    skipped 28 lines
  • ■ ■ ■ ■ ■ ■
    pkg/csprecon/csprecon.go
    skipped 14 lines
    15 15  )
    16 16   
    17 17  type Runner struct {
    18  - Input chan string
    19  - Output chan string
    20  - Result output.Result
    21  - InWg *sync.WaitGroup
    22  - OutWg *sync.WaitGroup
    23  - Options input.Options
     18 + Input chan string
     19 + Output chan string
     20 + Result output.Result
     21 + UserAgent string
     22 + InWg *sync.WaitGroup
     23 + OutWg *sync.WaitGroup
     24 + Options input.Options
    24 25  }
    25 26   
    26 27  func New(options *input.Options) Runner {
    27 28   return Runner{
    28  - Input: make(chan string, options.Concurrency),
    29  - Output: make(chan string, options.Concurrency),
    30  - Result: output.New(),
    31  - InWg: &sync.WaitGroup{},
    32  - OutWg: &sync.WaitGroup{},
    33  - Options: *options,
     29 + Input: make(chan string, options.Concurrency),
     30 + Output: make(chan string, options.Concurrency),
     31 + Result: output.New(),
     32 + UserAgent: golazy.GenerateRandomUserAgent(),
     33 + InWg: &sync.WaitGroup{},
     34 + OutWg: &sync.WaitGroup{},
     35 + Options: *options,
    34 36   }
    35 37  }
    36 38   
    skipped 50 lines
    87 89   for value := range r.Input {
    88 90   client := customClient(r.Options.Timeout)
    89 91   
    90  - result, err := checkCSP(value, dregex, client)
     92 + result, err := checkCSP(value, r.UserAgent, dregex, client)
    91 93   if err != nil {
    92 94   if r.Options.Verbose {
    93 95   gologger.Error().Msgf("%s", err)
    skipped 54 lines
Please wait...
Page is in error, reload to recover