nuclei/v2/pkg/collaborator/collaborator.go

60 lines
1.3 KiB
Go
Raw Normal View History

2020-10-23 10:13:34 +02:00
package collaborator
import (
"strings"
"time"
"github.com/projectdiscovery/collaborator"
)
const (
2020-10-23 12:37:30 +02:00
PollSeconds = 5
2020-10-23 10:13:34 +02:00
DefaultMaxBufferLimit = 150
)
2020-10-23 12:37:30 +02:00
var DefaultPollInterval time.Duration = time.Second * time.Duration(PollSeconds)
2020-10-23 10:13:34 +02:00
var DefaultCollaborator BurpCollaborator = BurpCollaborator{Collab: collaborator.NewBurpCollaborator()}
type BurpCollaborator struct {
2020-10-23 12:37:30 +02:00
options *Options // unused
2020-10-23 10:13:34 +02:00
Collab *collaborator.BurpCollaborator
}
type Options struct {
BIID string
PollInterval time.Duration
MaxBufferLimit int
}
2020-10-23 12:37:30 +02:00
func New(options *Options) *BurpCollaborator {
2020-10-23 10:13:34 +02:00
collab := collaborator.NewBurpCollaborator()
collab.AddBIID(options.BIID)
collab.MaxBufferLimit = options.MaxBufferLimit
2020-10-23 12:37:30 +02:00
return &BurpCollaborator{Collab: collab, options: options}
2020-10-23 10:13:34 +02:00
}
func (b *BurpCollaborator) Poll() {
// if no valid biids were provided just return
if len(b.Collab.BIIDs) > 0 {
go b.Collab.PollEach(DefaultPollInterval)
}
}
func (b *BurpCollaborator) Has(s string) bool {
for _, r := range b.Collab.RespBuffer {
2020-10-23 12:37:30 +02:00
for i := 0; i < len(r.Responses); i++ {
2020-10-23 10:13:34 +02:00
// search in dns
2020-10-23 12:37:30 +02:00
if strings.Contains(r.Responses[i].Data.RawRequestDecoded, s) {
2020-10-23 10:13:34 +02:00
return true
}
// search in http
2020-10-23 12:37:30 +02:00
if strings.Contains(r.Responses[i].Data.RequestDecoded, s) {
2020-10-23 10:13:34 +02:00
return true
}
}
}
return false
}