|
|
|
@ -47,16 +47,16 @@ type httpGetHeaders struct{}
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *httpGetHeaders) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if strings.EqualFold(r.Header.Get("test"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "This is test headers matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -71,16 +71,16 @@ type httpGetQueryString struct{}
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *httpGetQueryString) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if strings.EqualFold(r.URL.Query().Get("test"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "This is test querystring matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -95,18 +95,18 @@ type httpGetRedirects struct{}
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *httpGetRedirects) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
http.Redirect(w, r, "/redirected", http.StatusFound)
|
|
|
|
|
}))
|
|
|
|
|
router.GET("/redirected", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
})
|
|
|
|
|
router.GET("/redirected", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
fmt.Fprintf(w, "This is test redirects matcher text")
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -121,14 +121,14 @@ type httpGet struct{}
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *httpGet) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
fmt.Fprintf(w, "This is test matcher text")
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -145,7 +145,7 @@ func (h *httpPostBody) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -154,11 +154,11 @@ func (h *httpPostBody) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(r.Form.Get("username"), "test") && strings.EqualFold(r.Form.Get("password"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "This is test post-body matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -178,7 +178,7 @@ func (h *httpPostJSONBody) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
|
|
|
|
|
type doc struct {
|
|
|
|
@ -193,11 +193,11 @@ func (h *httpPostJSONBody) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(obj.Username, "test") && strings.EqualFold(obj.Password, "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "This is test post-json-body matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -217,7 +217,7 @@ func (h *httpPostMultipartBody) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseMultipartForm(1 * 1024); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -236,11 +236,11 @@ func (h *httpPostMultipartBody) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(password[0], "nuclei") && strings.EqualFold(file[0].Filename, "username") {
|
|
|
|
|
fmt.Fprintf(w, "This is test post-multipart matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -260,7 +260,7 @@ func (h *httpRawDynamicExtractor) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -269,17 +269,17 @@ func (h *httpRawDynamicExtractor) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(r.Form.Get("testing"), "parameter") {
|
|
|
|
|
fmt.Fprintf(w, "Token: 'nuclei'")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
})
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if strings.EqualFold(r.URL.Query().Get("username"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "Test is test-dynamic-extractor-raw matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -299,16 +299,16 @@ func (h *httpRawGetQuery) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if strings.EqualFold(r.URL.Query().Get("test"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "Test is test raw-get-query-matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -328,15 +328,15 @@ func (h *httpRawGet) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(w, "Test is test raw-get-matcher text")
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -356,7 +356,7 @@ func (h *httpRawPayload) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -368,11 +368,11 @@ func (h *httpRawPayload) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(r.Form.Get("username"), "test") && (strings.EqualFold(r.Form.Get("password"), "nuclei") || strings.EqualFold(r.Form.Get("password"), "guest")) {
|
|
|
|
|
fmt.Fprintf(w, "Test is raw-payload matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -392,7 +392,7 @@ func (h *httpRawPostBody) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -401,11 +401,11 @@ func (h *httpRawPostBody) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(r.Form.Get("username"), "test") && strings.EqualFold(r.Form.Get("password"), "nuclei") {
|
|
|
|
|
fmt.Fprintf(w, "Test is test raw-post-body-matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -425,7 +425,7 @@ func (h *httpRawCookieReuse) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.POST("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -434,8 +434,8 @@ func (h *httpRawCookieReuse) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(r.Form.Get("testing"), "parameter") {
|
|
|
|
|
http.SetCookie(w, &http.Cookie{Name: "nuclei", Value: "test"})
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
})
|
|
|
|
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
|
routerErr = err
|
|
|
|
@ -450,11 +450,11 @@ func (h *httpRawCookieReuse) Execute(filePath string) error {
|
|
|
|
|
if strings.EqualFold(cookie.Value, "test") {
|
|
|
|
|
fmt.Fprintf(w, "Test is test-cookie-reuse matcher text")
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -479,7 +479,7 @@ func (h *httpRawUnsafeRequest) Execute(filePath string) error {
|
|
|
|
|
})
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, "http://"+ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "http://"+ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -499,18 +499,18 @@ func (h *httpRequestCondition) Execute(filePath string) error {
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
var routerErr error
|
|
|
|
|
|
|
|
|
|
router.GET("/200", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
router.GET("/200", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
w.WriteHeader(200)
|
|
|
|
|
}))
|
|
|
|
|
router.GET("/400", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
})
|
|
|
|
|
router.GET("/400", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|
|
|
|
httpDebugRequestDump(r)
|
|
|
|
|
w.WriteHeader(400)
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
ts := httptest.NewServer(router)
|
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
|
|
results, err := testutils.RunNucleiAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|