mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 09:05:25 +00:00
Misc work on protocols
This commit is contained in:
parent
8a64578890
commit
10642c6c77
@ -10,8 +10,6 @@ import (
|
|||||||
func responseToDSLMap(msg *dns.Msg) map[string]interface{} {
|
func responseToDSLMap(msg *dns.Msg) map[string]interface{} {
|
||||||
data := make(map[string]interface{}, 6)
|
data := make(map[string]interface{}, 6)
|
||||||
|
|
||||||
data["rcode"] = msg.Rcode
|
|
||||||
|
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
for _, question := range msg.Question {
|
for _, question := range msg.Question {
|
||||||
buffer.WriteString(question.String())
|
buffer.WriteString(question.String())
|
||||||
@ -38,5 +36,6 @@ func responseToDSLMap(msg *dns.Msg) map[string]interface{} {
|
|||||||
buffer.Reset()
|
buffer.Reset()
|
||||||
|
|
||||||
data["raw"] = msg.String()
|
data["raw"] = msg.String()
|
||||||
|
data["status_code"] = msg.Rcode
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,64 +1,52 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Request contains a http request to be made from a template
|
// Request contains a http request to be made from a template
|
||||||
type Request struct {
|
type Request struct {
|
||||||
// Number of same request to send in race condition attack
|
|
||||||
RaceNumberRequests int `yaml:"race_count,omitempty"`
|
|
||||||
// MaxRedirects is the maximum number of redirects that should be followed.
|
|
||||||
MaxRedirects int `yaml:"max-redirects,omitempty"`
|
|
||||||
PipelineConcurrentConnections int `yaml:"pipeline-concurrent-connections,omitempty"`
|
|
||||||
PipelineRequestsPerConnection int `yaml:"pipeline-requests-per-connection,omitempty"`
|
|
||||||
Threads int `yaml:"threads,omitempty"`
|
|
||||||
// attackType is internal attack type
|
|
||||||
attackType generators.Type
|
|
||||||
// matchersCondition is internal condition for the matchers.
|
|
||||||
matchersCondition matchers.ConditionType
|
|
||||||
// CookieReuse is an optional setting that makes cookies shared within requests
|
|
||||||
CookieReuse bool `yaml:"cookie-reuse,omitempty"`
|
|
||||||
// Redirects specifies whether redirects should be followed.
|
|
||||||
Redirects bool `yaml:"redirects,omitempty"`
|
|
||||||
// Pipeline defines if the attack should be performed with HTTP 1.1 Pipelining (race conditions/billions requests)
|
|
||||||
// All requests must be indempotent (GET/POST)
|
|
||||||
Pipeline bool `yaml:"pipeline,omitempty"`
|
|
||||||
// Specify in order to skip request RFC normalization
|
|
||||||
Unsafe bool `yaml:"unsafe,omitempty"`
|
|
||||||
// DisableAutoHostname Enable/Disable Host header for unsafe raw requests
|
|
||||||
DisableAutoHostname bool `yaml:"disable-automatic-host-header,omitempty"`
|
|
||||||
// DisableAutoContentLength Enable/Disable Content-Length header for unsafe raw requests
|
|
||||||
DisableAutoContentLength bool `yaml:"disable-automatic-content-length-header,omitempty"`
|
|
||||||
// Race determines if all the request have to be attempted at the same time
|
|
||||||
// The minimum number fof requests is determined by threads
|
|
||||||
Race bool `yaml:"race,omitempty"`
|
|
||||||
// Name is the name of the request
|
// Name is the name of the request
|
||||||
Name string `yaml:"Name,omitempty"`
|
Name string `yaml:"Name"`
|
||||||
// AttackType is the attack type
|
// AttackType is the attack type
|
||||||
// Sniper, PitchFork and ClusterBomb. Default is Sniper
|
// Sniper, PitchFork and ClusterBomb. Default is Sniper
|
||||||
AttackType string `yaml:"attack,omitempty"`
|
AttackType string `yaml:"attack"`
|
||||||
// Method is the request method, whether GET, POST, PUT, etc
|
// Method is the request method, whether GET, POST, PUT, etc
|
||||||
Method string `yaml:"method"`
|
Method string `yaml:"method"`
|
||||||
// Body is an optional parameter which contains the request body for POST methods, etc
|
// Body is an optional parameter which contains the request body for POST methods, etc
|
||||||
Body string `yaml:"body,omitempty"`
|
Body string `yaml:"body"`
|
||||||
// MatchersCondition is the condition of the matchers
|
|
||||||
// whether to use AND or OR. Default is OR.
|
|
||||||
MatchersCondition string `yaml:"matchers-condition,omitempty"`
|
|
||||||
// Path contains the path/s for the request
|
// Path contains the path/s for the request
|
||||||
Path []string `yaml:"path"`
|
Path []string `yaml:"path"`
|
||||||
// Raw contains raw requests
|
// Raw contains raw requests
|
||||||
Raw []string `yaml:"raw,omitempty"`
|
Raw []string `yaml:"raw"`
|
||||||
// Matchers contains the detection mechanism for the request to identify
|
|
||||||
// whether the request was successful
|
|
||||||
Matchers []*matchers.Matcher `yaml:"matchers,omitempty"`
|
|
||||||
// Extractors contains the extraction mechanism for the request to identify
|
|
||||||
// and extract parts of the response.
|
|
||||||
Extractors []*extractors.Extractor `yaml:"extractors,omitempty"`
|
|
||||||
// Path contains the path/s for the request variables
|
// Path contains the path/s for the request variables
|
||||||
Payloads map[string]interface{} `yaml:"payloads,omitempty"`
|
Payloads map[string]interface{} `yaml:"payloads"`
|
||||||
// Headers contains headers to send with the request
|
// Headers contains headers to send with the request
|
||||||
Headers map[string]string `yaml:"headers,omitempty"`
|
Headers map[string]string `yaml:"headers"`
|
||||||
|
// RaceNumberRequests is the number of same request to send in race condition attack
|
||||||
|
RaceNumberRequests int `yaml:"race_count"`
|
||||||
|
// MaxRedirects is the maximum number of redirects that should be followed.
|
||||||
|
MaxRedirects int `yaml:"max-redirects"`
|
||||||
|
// PipelineConcurrentConnections is number of connections in pipelining
|
||||||
|
PipelineConcurrentConnections int `yaml:"pipeline-concurrent-connections"`
|
||||||
|
// PipelineRequestsPerConnection is number of requests in pipelining
|
||||||
|
PipelineRequestsPerConnection int `yaml:"pipeline-requests-per-connection"`
|
||||||
|
// Threads specifies number of threads for sending requests
|
||||||
|
Threads int `yaml:"threads"`
|
||||||
|
// CookieReuse is an optional setting that makes cookies shared within requests
|
||||||
|
CookieReuse bool `yaml:"cookie-reuse"`
|
||||||
|
// Redirects specifies whether redirects should be followed.
|
||||||
|
Redirects bool `yaml:"redirects"`
|
||||||
|
// Pipeline defines if the attack should be performed with HTTP 1.1 Pipelining (race conditions/billions requests)
|
||||||
|
// All requests must be indempotent (GET/POST)
|
||||||
|
Pipeline bool `yaml:"pipeline"`
|
||||||
|
// Specify in order to skip request RFC normalization
|
||||||
|
Unsafe bool `yaml:"unsafe"`
|
||||||
|
// DisableAutoHostname Enable/Disable Host header for unsafe raw requests
|
||||||
|
DisableAutoHostname bool `yaml:"disable-automatic-host-header"`
|
||||||
|
// DisableAutoContentLength Enable/Disable Content-Length header for unsafe raw requests
|
||||||
|
DisableAutoContentLength bool `yaml:"disable-automatic-content-length-header"`
|
||||||
|
// Race determines if all the request have to be attempted at the same time
|
||||||
|
// The minimum number fof requests is determined by threads
|
||||||
|
Race bool `yaml:"race"`
|
||||||
|
|
||||||
|
attackType generators.Type
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,12 +17,12 @@ func responseToDSLMap(resp *http.Response, body, headers string, duration time.D
|
|||||||
data["content_length"] = resp.ContentLength
|
data["content_length"] = resp.ContentLength
|
||||||
data["status_code"] = resp.StatusCode
|
data["status_code"] = resp.StatusCode
|
||||||
|
|
||||||
|
data["body"] = body
|
||||||
for k, v := range resp.Header {
|
for k, v := range resp.Header {
|
||||||
k = strings.ToLower(strings.TrimSpace(strings.ReplaceAll(k, "-", "_")))
|
k = strings.ToLower(strings.TrimSpace(strings.ReplaceAll(k, "-", "_")))
|
||||||
data[k] = strings.Join(v, " ")
|
data[k] = strings.Join(v, " ")
|
||||||
}
|
}
|
||||||
data["all_headers"] = headers
|
data["headers"] = headers
|
||||||
data["body"] = body
|
|
||||||
|
|
||||||
if r, err := httputil.DumpResponse(resp, true); err == nil {
|
if r, err := httputil.DumpResponse(resp, true); err == nil {
|
||||||
data["raw"] = string(r)
|
data["raw"] = string(r)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package protocols
|
|||||||
import (
|
import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
|
"go.uber.org/ratelimit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Executer is an interface implemented any protocol based request generator.
|
// Executer is an interface implemented any protocol based request generator.
|
||||||
@ -21,6 +22,8 @@ type Executer interface {
|
|||||||
type ExecuterOptions struct {
|
type ExecuterOptions struct {
|
||||||
// Output is a writer interface for writing output events from executer.
|
// Output is a writer interface for writing output events from executer.
|
||||||
Output output.Writer
|
Output output.Writer
|
||||||
// Options contains configuration options for the executer
|
// Options contains configuration options for the executer.
|
||||||
Options *types.Options
|
Options *types.Options
|
||||||
|
// RateLimiter is a rate-limiter for limiting sent number of requests.
|
||||||
|
RateLimiter ratelimit.Limiter
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user