forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue with
-ms
option to scan non accessible host (projectdis…
…covery#5576) * fail if OnResult callback is not called * generate error message from error logs * try..parse.. * fix lint * add error message to last matcher event * fix network protocol error logging * log returned log from ExecuteWithResults * add back specific logging * clean up the msg * minor * init integration test for -ms * add tests for http,network,js,ws protocols * fix lint * fix network test * return err for dns protocol * add integration test for dns protocol
- Loading branch information
1 parent
bf58b4d
commit 6b71af4
Showing
7 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/projectdiscovery/nuclei/v3/pkg/output" | ||
"github.com/projectdiscovery/nuclei/v3/pkg/testutils" | ||
) | ||
|
||
var matcherStatusTestcases = []TestCaseInfo{ | ||
{Path: "protocols/http/get.yaml", TestCase: &httpNoAccess{}}, | ||
{Path: "protocols/network/net-https.yaml", TestCase: &networkNoAccess{}}, | ||
{Path: "protocols/headless/headless-basic.yaml", TestCase: &headlessNoAccess{}}, | ||
{Path: "protocols/javascript/net-https.yaml", TestCase: &javascriptNoAccess{}}, | ||
{Path: "protocols/websocket/basic.yaml", TestCase: &websocketNoAccess{}}, | ||
{Path: "protocols/dns/a.yaml", TestCase: &dnsNoAccess{}}, | ||
} | ||
|
||
type httpNoAccess struct{} | ||
|
||
func (h *httpNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "trust_me_bro.real", debug, "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error != "no address found for host" { | ||
return fmt.Errorf("unexpected result: expecting \"no address found for host\" error but got none") | ||
} | ||
return nil | ||
} | ||
|
||
type networkNoAccess struct{} | ||
|
||
// Execute executes a test case and returns an error if occurred | ||
func (h *networkNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "trust_me_bro.real", debug, "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error != "no address found for host" { | ||
return fmt.Errorf("unexpected result: expecting \"no address found for host\" error but got \"%s\"", event.Error) | ||
} | ||
return nil | ||
} | ||
|
||
type headlessNoAccess struct{} | ||
|
||
// Execute executes a test case and returns an error if occurred | ||
func (h *headlessNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "trust_me_bro.real", debug, "-headless", "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error == "" { | ||
return fmt.Errorf("unexpected result: expecting an error but got \"%s\"", event.Error) | ||
} | ||
return nil | ||
} | ||
|
||
type javascriptNoAccess struct{} | ||
|
||
// Execute executes a test case and returns an error if occurred | ||
func (h *javascriptNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "trust_me_bro.real", debug, "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error == "" { | ||
return fmt.Errorf("unexpected result: expecting an error but got \"%s\"", event.Error) | ||
} | ||
return nil | ||
} | ||
|
||
type websocketNoAccess struct{} | ||
|
||
// Execute executes a test case and returns an error if occurred | ||
func (h *websocketNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "ws://trust_me_bro.real", debug, "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error == "" { | ||
return fmt.Errorf("unexpected result: expecting an error but got \"%s\"", event.Error) | ||
} | ||
return nil | ||
} | ||
|
||
type dnsNoAccess struct{} | ||
|
||
// Execute executes a test case and returns an error if occurred | ||
func (h *dnsNoAccess) Execute(filePath string) error { | ||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "trust_me_bro.real", debug, "-ms", "-j") | ||
if err != nil { | ||
return err | ||
} | ||
event := &output.ResultEvent{} | ||
_ = json.Unmarshal([]byte(results[0]), event) | ||
|
||
if event.Error == "" { | ||
return fmt.Errorf("unexpected result: expecting an error but got \"%s\"", event.Error) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters