mirror of https://github.com/daffainfo/nuclei.git
interactsh stopAtFirstMatch intergration test
parent
911045ae9a
commit
c0f9c1da70
|
@ -0,0 +1,23 @@
|
|||
id: interactsh-stop-at-first-match-integration-test
|
||||
|
||||
info:
|
||||
name: Interactsh StopAtFirstMatch Integration Test
|
||||
author: pdteam
|
||||
severity: info
|
||||
|
||||
requests:
|
||||
- method: GET
|
||||
path:
|
||||
- "{{BaseURL}}"
|
||||
- "{{BaseURL}}"
|
||||
- "{{BaseURL}}"
|
||||
headers:
|
||||
url: 'http://{{interactsh-url}}'
|
||||
|
||||
stop-at-first-match: true
|
||||
|
||||
matchers:
|
||||
- type: word
|
||||
part: interactsh_protocol # Confirms the HTTP Interaction
|
||||
words:
|
||||
- "http"
|
|
@ -35,6 +35,7 @@ var httpTestcases = map[string]testutils.TestCase{
|
|||
"http/request-condition.yaml": &httpRequestCondition{},
|
||||
"http/request-condition-new.yaml": &httpRequestCondition{},
|
||||
"http/interactsh.yaml": &httpInteractshRequest{},
|
||||
"http/interactsh-stop-at-first-match.yaml": &httpInteractshStopAtFirstMatchRequest{},
|
||||
"http/self-contained.yaml": &httpRequestSelContained{},
|
||||
"http/get-case-insensitive.yaml": &httpGetCaseInsensitive{},
|
||||
"http/get.yaml,http/get-case-insensitive.yaml": &httpGetCaseInsensitiveCluster{},
|
||||
|
@ -67,6 +68,29 @@ func (h *httpInteractshRequest) Execute(filePath string) error {
|
|||
return expectResultsCount(results, 1)
|
||||
}
|
||||
|
||||
type httpInteractshStopAtFirstMatchRequest struct{}
|
||||
|
||||
// Execute executes a test case and returns an error if occurred
|
||||
func (h *httpInteractshStopAtFirstMatchRequest) Execute(filePath string) error {
|
||||
router := httprouter.New()
|
||||
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
value := r.Header.Get("url")
|
||||
if value != "" {
|
||||
if resp, _ := http.DefaultClient.Get(value); resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
}
|
||||
})
|
||||
ts := httptest.NewServer(router)
|
||||
defer ts.Close()
|
||||
|
||||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return expectResultsCount(results, 1)
|
||||
}
|
||||
|
||||
type httpGetHeaders struct{}
|
||||
|
||||
// Execute executes a test case and returns an error if occurred
|
||||
|
|
|
@ -233,9 +233,9 @@ func (c *Client) ReplaceMarkers(data string, interactshURLs []string) (string, [
|
|||
return data, interactshURLs
|
||||
}
|
||||
|
||||
// SetStopAtFirstMatch sets StopAtFirstMatch for interactsh client options
|
||||
func (c *Client) SetStopAtFirstMatch(stopAtFirstMatch bool) {
|
||||
c.options.StopAtFirstMatch = stopAtFirstMatch
|
||||
// SetStopAtFirstMatch sets StopAtFirstMatch true for interactsh client options
|
||||
func (c *Client) SetStopAtFirstMatch() {
|
||||
c.options.StopAtFirstMatch = true
|
||||
}
|
||||
|
||||
// MakeResultEventFunc is a result making function for nuclei
|
||||
|
|
|
@ -62,7 +62,7 @@ func (r *requestGenerator) Make(baseURL, data string, payloads, dynamicValues ma
|
|||
|
||||
if r.options.Interactsh != nil {
|
||||
if r.options.StopAtFirstMatch || r.request.StopAtFirstMatch {
|
||||
r.options.Interactsh.SetStopAtFirstMatch(true)
|
||||
r.options.Interactsh.SetStopAtFirstMatch()
|
||||
}
|
||||
|
||||
data, r.interactshURLs = r.options.Interactsh.ReplaceMarkers(data, r.interactshURLs)
|
||||
|
|
|
@ -143,7 +143,7 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
|
|||
|
||||
if request.options.Interactsh != nil {
|
||||
if request.options.StopAtFirstMatch {
|
||||
request.options.Interactsh.SetStopAtFirstMatch(true)
|
||||
request.options.Interactsh.SetStopAtFirstMatch()
|
||||
}
|
||||
var transformedData string
|
||||
transformedData, interactshURLs = request.options.Interactsh.ReplaceMarkers(string(data), []string{})
|
||||
|
|
Loading…
Reference in New Issue