mirror of https://github.com/daffainfo/nuclei.git
Merge branch 'dev' into interactsh-server-support
commit
33f1e23e87
|
@ -7,11 +7,11 @@ const banner = `
|
|||
____ __ _______/ /__ (_)
|
||||
/ __ \/ / / / ___/ / _ \/ /
|
||||
/ / / / /_/ / /__/ / __/ /
|
||||
/_/ /_/\__,_/\___/_/\___/_/ v2.3.4
|
||||
/_/ /_/\__,_/\___/_/\___/_/ v2.3.5
|
||||
`
|
||||
|
||||
// Version is the current version of nuclei
|
||||
const Version = `2.3.4`
|
||||
const Version = `2.3.5`
|
||||
|
||||
// showBanner is used to show the banner to the user
|
||||
func showBanner() {
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/clusterer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/interactsh"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolinit"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/headless/engine"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/disk"
|
||||
|
@ -237,6 +238,7 @@ func (r *Runner) Close() {
|
|||
if r.projectFile != nil {
|
||||
r.projectFile.Close()
|
||||
}
|
||||
protocolinit.Close()
|
||||
}
|
||||
|
||||
// RunEnumeration sets up the input layer for giving input nuclei.
|
||||
|
|
|
@ -2,6 +2,7 @@ package protocolinit
|
|||
|
||||
import (
|
||||
"github.com/corpix/uarand"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/dns/dnsclientpool"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/httpclientpool"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/network/networkclientpool"
|
||||
|
@ -12,6 +13,9 @@ import (
|
|||
func Init(options *types.Options) error {
|
||||
uarand.Default = uarand.NewWithCustomList(userAgents)
|
||||
|
||||
if err := protocolstate.Init(options); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := dnsclientpool.Init(options); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -58,3 +62,7 @@ var userAgents = []string{
|
|||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/4E423F",
|
||||
}
|
||||
|
||||
func Close() {
|
||||
protocolstate.Dialer.Close()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package protocolstate
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
var Dialer *fastdialer.Dialer
|
||||
|
||||
func Init(options *types.Options) error {
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.SystemResolvers {
|
||||
opts.EnableFallback = true
|
||||
}
|
||||
if options.ResolversFile != "" {
|
||||
opts.BaseResolvers = options.InternalResolversList
|
||||
}
|
||||
dialer, err := fastdialer.NewDialer(opts)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create dialer")
|
||||
}
|
||||
Dialer = dialer
|
||||
return nil
|
||||
}
|
||||
|
||||
func Close() {
|
||||
if Dialer != nil {
|
||||
Dialer.Close()
|
||||
}
|
||||
}
|
|
@ -76,10 +76,7 @@ func New(options *types.Options) (*Browser, error) {
|
|||
if customAgent == "" {
|
||||
customAgent = uarand.GetRandom()
|
||||
}
|
||||
httpclient, err := newhttpClient(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
httpclient := newhttpClient(options)
|
||||
engine := &Browser{
|
||||
tempDir: dataStore,
|
||||
customAgent: customAgent,
|
||||
|
|
|
@ -5,25 +5,13 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
// newhttpClient creates a new http client for headless communication with a timeout
|
||||
func newhttpClient(options *types.Options) (*http.Client, error) {
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.SystemResolvers {
|
||||
opts.EnableFallback = true
|
||||
}
|
||||
if options.ResolversFile != "" {
|
||||
opts.BaseResolvers = options.InternalResolversList
|
||||
}
|
||||
dialer, err := fastdialer.NewDialer(opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create dialer")
|
||||
}
|
||||
|
||||
func newhttpClient(options *types.Options) *http.Client {
|
||||
dialer := protocolstate.Dialer
|
||||
transport := &http.Transport{
|
||||
DialContext: dialer.Dial,
|
||||
MaxIdleConns: 500,
|
||||
|
@ -34,5 +22,5 @@ func newhttpClient(options *types.Options) (*http.Client, error) {
|
|||
InsecureSkipVerify: true,
|
||||
},
|
||||
}
|
||||
return &http.Client{Transport: transport, Timeout: time.Duration(options.Timeout*3) * time.Second}, nil
|
||||
return &http.Client{Transport: transport, Timeout: time.Duration(options.Timeout*3) * time.Second}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,14 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestActionNavigate(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
@ -46,6 +49,8 @@ func TestActionNavigate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestActionScript(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
@ -113,6 +118,8 @@ func TestActionScript(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestActionClick(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
@ -151,6 +158,8 @@ func TestActionClick(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestActionRightClick(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
@ -197,6 +206,8 @@ func TestActionRightClick(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestActionTextInput(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
@ -236,6 +247,8 @@ func TestActionTextInput(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestActionHeadersChange(t *testing.T) {
|
||||
_ = protocolstate.Init(&types.Options{})
|
||||
|
||||
browser, err := New(&types.Options{ShowBrowser: false})
|
||||
require.Nil(t, err, "could not create browser")
|
||||
defer browser.Close()
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
"github.com/projectdiscovery/retryablehttp-go"
|
||||
|
@ -97,14 +98,7 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
|
|||
var err error
|
||||
|
||||
if Dialer == nil {
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.SystemResolvers {
|
||||
opts.EnableFallback = true
|
||||
}
|
||||
if options.ResolversFile != "" {
|
||||
opts.BaseResolvers = options.InternalResolversList
|
||||
}
|
||||
Dialer, err = fastdialer.NewDialer(opts)
|
||||
Dialer = protocolstate.Dialer
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create dialer")
|
||||
|
|
|
@ -388,6 +388,9 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
finalEvent := make(output.InternalEvent)
|
||||
|
||||
outputEvent := r.responseToDSLMap(resp, reqURL, matchedURL, tostring.UnsafeToString(dumpedRequest), tostring.UnsafeToString(dumpedResponse), tostring.UnsafeToString(data), headersToString(resp.Header), duration, request.meta)
|
||||
if i := strings.LastIndex(hostname, ":"); i != -1 {
|
||||
hostname = hostname[:i]
|
||||
}
|
||||
outputEvent["ip"] = httpclientpool.Dialer.GetDialedIP(hostname)
|
||||
outputEvent["redirect-chain"] = tostring.UnsafeToString(redirectedResponse)
|
||||
for k, v := range previous {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package networkclientpool
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
|
@ -16,18 +16,7 @@ func Init(options *types.Options) error {
|
|||
if normalClient != nil {
|
||||
return nil
|
||||
}
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.SystemResolvers {
|
||||
opts.EnableFallback = true
|
||||
}
|
||||
if options.ResolversFile != "" {
|
||||
opts.BaseResolvers = options.InternalResolversList
|
||||
}
|
||||
dialer, err := fastdialer.NewDialer(opts)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create dialer")
|
||||
}
|
||||
normalClient = dialer
|
||||
normalClient = protocolstate.Dialer
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue