mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-11-07 17:43:04 -10:00
Compare commits
77
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bac917428b | ||
|
|
59e936399b | ||
|
|
d776dbb2dd | ||
|
|
0433c83730 | ||
|
|
f1253e16c9 | ||
|
|
efc01c90c5 | ||
|
|
6c32eb7d1e | ||
|
|
6cbd73f780 | ||
|
|
ebbfcadb9a | ||
|
|
7f3c5e5083 | ||
|
|
26e6127755 | ||
|
|
2e78b50f80 | ||
|
|
455a900a96 | ||
|
|
ceea533681 | ||
|
|
f50d39b28a | ||
|
|
deb0dd2a5f | ||
|
|
3e1cd27943 | ||
|
|
0b71d983a5 | ||
|
|
bc229a46ca | ||
|
|
49d8579662 | ||
|
|
f080d614c3 | ||
|
|
8f22eb596e | ||
|
|
d4e81fd9e6 | ||
|
|
d7997e47ec | ||
|
|
cdb39d851b | ||
|
|
860507bbe9 | ||
|
|
2bd68993e7 | ||
|
|
3c2af0e47c | ||
|
|
ead444b88b | ||
|
|
c9a9bd3bfc | ||
|
|
1c24ceda45 | ||
|
|
5cb32a4310 | ||
|
|
42bb6d705f | ||
|
|
ec89a23bc5 | ||
|
|
e90554443e | ||
|
|
3ff085c5ed | ||
|
|
1e3cfd75ea | ||
|
|
34599eabb9 | ||
|
|
68cac06818 | ||
|
|
b4b106db99 | ||
|
|
2b89a2e1a0 | ||
|
|
c7006a9168 | ||
|
|
5018673c0c | ||
|
|
71628cc897 | ||
|
|
7f51de3090 | ||
|
|
491233667d | ||
|
|
7f556f8e33 | ||
|
|
bce3e7f518 | ||
|
|
5957381c02 | ||
|
|
3f82fc6d00 | ||
|
|
4d12271ccf | ||
|
|
39b6ca9bb7 | ||
|
|
9957003113 | ||
|
|
930f51fcf0 | ||
|
|
af2284b741 | ||
|
|
cda1fc0ba5 | ||
|
|
0f4ad124e4 | ||
|
|
7d031d9833 | ||
|
|
669eee24bd | ||
|
|
1f38d6b459 | ||
|
|
b38bcdfd81 | ||
|
|
7f2558fc12 | ||
|
|
5eac841424 | ||
|
|
c3b39be605 | ||
|
|
6072a2fcee | ||
|
|
2a7e15ddfa | ||
|
|
3a7a073d52 | ||
|
|
918b62bd35 | ||
|
|
106ab84259 | ||
|
|
85d888b01a | ||
|
|
9f18a99db7 | ||
|
|
9606591dc9 | ||
|
|
19567fb77b | ||
|
|
2d14849674 | ||
|
|
cc46f57d4d | ||
|
|
75357b1eea | ||
|
|
5aa929ac7f |
No files matched your search
@@ -203,7 +203,6 @@ CONFIGURATIONS:
|
||||
-sml, -show-match-line show match lines for file templates, works with extractors only
|
||||
-ztls use ztls library with autofallback to standard one for tls13 [Deprecated] autofallback to ztls is enabled by default
|
||||
-sni string tls sni hostname to use (default: input domain name)
|
||||
-dt, -dialer-timeout value timeout for network requests.
|
||||
-dka, -dialer-keep-alive value keep-alive duration for network requests.
|
||||
-lfa, -allow-local-file-access allows file (payload) access anywhere on the system
|
||||
-lna, -restrict-local-network-access blocks connections to the local / private network
|
||||
@@ -212,7 +211,6 @@ CONFIGURATIONS:
|
||||
-sip, -source-ip string source ip address to use for network scan
|
||||
-rsr, -response-size-read int max response size to read in bytes
|
||||
-rss, -response-size-save int max response size to read in bytes (default 1048576)
|
||||
-rrt, -response-read-timeout value response read timeout in seconds (default 5s)
|
||||
-reset reset removes all nuclei configuration and data files (including nuclei-templates)
|
||||
-tlsi, -tls-impersonate enable experimental client hello (ja3) tls randomization
|
||||
-hae, -http-api-endpoint string experimental http api endpoint
|
||||
@@ -238,7 +236,7 @@ FUZZING:
|
||||
UNCOVER:
|
||||
-uc, -uncover enable uncover engine
|
||||
-uq, -uncover-query string[] uncover search query
|
||||
-ue, -uncover-engine string[] uncover search engine (shodan,censys,fofa,shodan-idb,quake,hunter,zoomeye,netlas,criminalip,publicwww,hunterhow) (default shodan)
|
||||
-ue, -uncover-engine string[] uncover search engine (shodan,censys,fofa,shodan-idb,quake,hunter,zoomeye,netlas,criminalip,publicwww,hunterhow,google) (default shodan)
|
||||
-uf, -uncover-field string uncover fields to return (ip,port,host) (default "ip:port")
|
||||
-ul, -uncover-limit int uncover results to return (default 100)
|
||||
-ur, -uncover-ratelimit int override ratelimit of engines with unknown ratelimit (default 60 req/min) (default 60)
|
||||
@@ -311,9 +309,10 @@ STATISTICS:
|
||||
-mp, -metrics-port int port to expose nuclei metrics on (default 9092)
|
||||
|
||||
CLOUD:
|
||||
-auth configure projectdiscovery cloud (pdcp) api key
|
||||
-cup, -cloud-upload upload scan results to pdcp dashboard
|
||||
-sid, -scan-id string upload scan results to given scan id
|
||||
-auth configure projectdiscovery cloud (pdcp) api key (default true)
|
||||
-cup, -cloud-upload upload scan results to pdcp dashboard
|
||||
-sid, -scan-id string upload scan results to existing scan id (optional)
|
||||
-sname, -scan-name string scan name to set (optional)
|
||||
|
||||
AUTHENTICATION:
|
||||
-sf, -secret-file string[] path to config file containing secrets for nuclei authenticated scan
|
||||
|
||||
@@ -4339,19 +4339,6 @@ Code contains code to execute for the javascript request.
|
||||
|
||||
<div class="dd">
|
||||
|
||||
<code>timeout</code> <i>int</i>
|
||||
|
||||
</div>
|
||||
<div class="dt">
|
||||
|
||||
Timeout in seconds is optional timeout for each javascript script execution (i.e init, pre-condition, code)
|
||||
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="dd">
|
||||
|
||||
<code>stop-at-first-match</code> <i>bool</i>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -172,7 +172,14 @@ func (h *nonExistentTemplateList) Execute(nonExistingTemplateList string) error
|
||||
ts := httptest.NewServer(router)
|
||||
defer ts.Close()
|
||||
|
||||
_, err := testutils.RunNucleiBareArgsAndGetResults(debug, nil, "-target", ts.URL, "-template-url", ts.URL+"/404")
|
||||
configFileData := `remote-template-domain: [ "` + ts.Listener.Addr().String() + `" ]`
|
||||
err := os.WriteFile("test-config.yaml", []byte(configFileData), permissionutil.ConfigFilePermission)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove("test-config.yaml")
|
||||
|
||||
_, err = testutils.RunNucleiBareArgsAndGetResults(debug, nil, "-target", ts.URL, "-template-url", ts.URL+"/404", "-config", "test-config.yaml")
|
||||
if err == nil {
|
||||
return fmt.Errorf("expected error for nonexisting workflow url")
|
||||
}
|
||||
@@ -188,7 +195,14 @@ func (h *nonExistentWorkflowList) Execute(nonExistingWorkflowList string) error
|
||||
ts := httptest.NewServer(router)
|
||||
defer ts.Close()
|
||||
|
||||
_, err := testutils.RunNucleiBareArgsAndGetResults(debug, nil, "-target", ts.URL, "-workflow-url", ts.URL+"/404")
|
||||
configFileData := `remote-template-domain: [ "` + ts.Listener.Addr().String() + `" ]`
|
||||
err := os.WriteFile("test-config.yaml", []byte(configFileData), permissionutil.ConfigFilePermission)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove("test-config.yaml")
|
||||
|
||||
_, err = testutils.RunNucleiBareArgsAndGetResults(debug, nil, "-target", ts.URL, "-workflow-url", ts.URL+"/404", "-config", "test-config.yaml")
|
||||
if err == nil {
|
||||
return fmt.Errorf("expected error for nonexisting workflow url")
|
||||
}
|
||||
|
||||
@@ -297,7 +297,6 @@ on extensive configurability, massive extensibility and ease of use.`)
|
||||
flagSet.BoolVarP(&options.ShowMatchLine, "show-match-line", "sml", false, "show match lines for file templates, works with extractors only"),
|
||||
flagSet.BoolVar(&options.ZTLS, "ztls", false, "use ztls library with autofallback to standard one for tls13 [Deprecated] autofallback to ztls is enabled by default"), //nolint:all
|
||||
flagSet.StringVar(&options.SNI, "sni", "", "tls sni hostname to use (default: input domain name)"),
|
||||
flagSet.DurationVarP(&options.DialerTimeout, "dialer-timeout", "dt", 0, "timeout for network requests."),
|
||||
flagSet.DurationVarP(&options.DialerKeepAlive, "dialer-keep-alive", "dka", 0, "keep-alive duration for network requests."),
|
||||
flagSet.BoolVarP(&options.AllowLocalFileAccess, "allow-local-file-access", "lfa", false, "allows file (payload) access anywhere on the system"),
|
||||
flagSet.BoolVarP(&options.RestrictLocalNetworkAccess, "restrict-local-network-access", "lna", false, "blocks connections to the local / private network"),
|
||||
@@ -306,7 +305,6 @@ on extensive configurability, massive extensibility and ease of use.`)
|
||||
flagSet.StringVarP(&options.SourceIP, "source-ip", "sip", "", "source ip address to use for network scan"),
|
||||
flagSet.IntVarP(&options.ResponseReadSize, "response-size-read", "rsr", 0, "max response size to read in bytes"),
|
||||
flagSet.IntVarP(&options.ResponseSaveSize, "response-size-save", "rss", unitutils.Mega, "max response size to read in bytes"),
|
||||
flagSet.DurationVarP(&options.ResponseReadTimeout, "response-read-timeout", "rrt", time.Duration(5*time.Second), "response read timeout in seconds"),
|
||||
flagSet.CallbackVar(resetCallback, "reset", "reset removes all nuclei configuration and data files (including nuclei-templates)"),
|
||||
flagSet.BoolVarP(&options.TlsImpersonate, "tls-impersonate", "tlsi", false, "enable experimental client hello (ja3) tls randomization"),
|
||||
flagSet.StringVarP(&options.HttpApiEndpoint, "http-api-endpoint", "hae", "", "experimental http api endpoint"),
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package main
|
||||
|
||||
import nuclei "github.com/projectdiscovery/nuclei/v3/lib"
|
||||
import (
|
||||
"context"
|
||||
|
||||
nuclei "github.com/projectdiscovery/nuclei/v3/lib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ne, err := nuclei.NewNucleiEngine(
|
||||
ne, err := nuclei.NewNucleiEngineCtx(context.Background(),
|
||||
nuclei.WithTemplateFilters(nuclei.TemplateFilters{Tags: []string{"oast"}}),
|
||||
nuclei.EnableStatsWithOpts(nuclei.StatsOptions{MetricServerPort: 6064}), // optionally enable metrics server for better observability
|
||||
)
|
||||
|
||||
@@ -20,12 +20,12 @@ require (
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/projectdiscovery/clistats v0.0.20
|
||||
github.com/projectdiscovery/fastdialer v0.1.5
|
||||
github.com/projectdiscovery/hmap v0.0.47
|
||||
github.com/projectdiscovery/fastdialer v0.1.6
|
||||
github.com/projectdiscovery/hmap v0.0.49
|
||||
github.com/projectdiscovery/interactsh v1.2.0
|
||||
github.com/projectdiscovery/rawhttp v0.1.51
|
||||
github.com/projectdiscovery/retryabledns v1.0.65
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.66
|
||||
github.com/projectdiscovery/rawhttp v0.1.57
|
||||
github.com/projectdiscovery/retryabledns v1.0.66
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.68
|
||||
github.com/projectdiscovery/yamldoc-go v1.0.4
|
||||
github.com/remeh/sizedwaitgroup v1.0.0
|
||||
github.com/rs/xid v1.5.0
|
||||
@@ -58,6 +58,7 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.13.27
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.72
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.37.0
|
||||
github.com/cespare/xxhash v1.1.0
|
||||
github.com/charmbracelet/glamour v0.6.0
|
||||
github.com/clbanning/mxj/v2 v2.7.0
|
||||
github.com/denisenkom/go-mssqldb v0.12.3
|
||||
@@ -78,11 +79,11 @@ require (
|
||||
github.com/mholt/archiver v3.1.1+incompatible
|
||||
github.com/ory/dockertest/v3 v3.10.0
|
||||
github.com/praetorian-inc/fingerprintx v1.1.9
|
||||
github.com/projectdiscovery/dsl v0.1.3
|
||||
github.com/projectdiscovery/dsl v0.1.6
|
||||
github.com/projectdiscovery/fasttemplate v0.0.2
|
||||
github.com/projectdiscovery/go-smb2 v0.0.0-20240129202741-052cc450c6cb
|
||||
github.com/projectdiscovery/goflags v0.1.56
|
||||
github.com/projectdiscovery/gologger v1.1.12
|
||||
github.com/projectdiscovery/goflags v0.1.59
|
||||
github.com/projectdiscovery/gologger v1.1.14
|
||||
github.com/projectdiscovery/gostruct v0.0.2
|
||||
github.com/projectdiscovery/gozero v0.0.2
|
||||
github.com/projectdiscovery/httpx v1.6.3
|
||||
@@ -93,9 +94,9 @@ require (
|
||||
github.com/projectdiscovery/sarif v0.0.1
|
||||
github.com/projectdiscovery/tlsx v1.1.6
|
||||
github.com/projectdiscovery/uncover v1.0.8
|
||||
github.com/projectdiscovery/useragent v0.0.56
|
||||
github.com/projectdiscovery/utils v0.1.4
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.6
|
||||
github.com/projectdiscovery/useragent v0.0.60
|
||||
github.com/projectdiscovery/utils v0.2.1
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.10
|
||||
github.com/redis/go-redis/v9 v9.1.0
|
||||
github.com/seh-msft/burpxml v1.0.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
@@ -129,7 +130,6 @@ require (
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/bytedance/sonic v1.9.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/cheggaaa/pb/v3 v3.1.4 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
@@ -200,8 +200,8 @@ require (
|
||||
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/projectdiscovery/asnmap v1.1.0 // indirect
|
||||
github.com/projectdiscovery/cdncheck v1.0.9 // indirect
|
||||
github.com/projectdiscovery/asnmap v1.1.1 // indirect
|
||||
github.com/projectdiscovery/cdncheck v1.1.0 // indirect
|
||||
github.com/projectdiscovery/freeport v0.0.5 // indirect
|
||||
github.com/projectdiscovery/ldapserver v1.0.2-0.20240219154113-dcc758ebc0cb // indirect
|
||||
github.com/projectdiscovery/machineid v0.0.0-20240226150047-2e2c51e35983 // indirect
|
||||
@@ -293,7 +293,6 @@ require (
|
||||
github.com/trivago/tgo v1.0.7
|
||||
github.com/ulikunitz/xz v0.5.12 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/yl2chen/cidranger v1.0.2 // indirect
|
||||
github.com/ysmood/goob v0.4.0 // indirect
|
||||
github.com/ysmood/gson v0.7.3 // indirect
|
||||
github.com/ysmood/leakless v0.8.0 // indirect
|
||||
|
||||
@@ -826,34 +826,34 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/praetorian-inc/fingerprintx v1.1.9 h1:zWbG/Fdan0s/dvXkeaHb/CdFTz/yEEzrAF4iCzok3r8=
|
||||
github.com/praetorian-inc/fingerprintx v1.1.9/go.mod h1:k6EJIHe/Da4DH5e4JuoZHe+qSGq/KPUmXGaK+xW74OI=
|
||||
github.com/projectdiscovery/asnmap v1.1.0 h1:ynvbLB5cNpyQ2+k9IP0Rpla+0JmCJpd3mw6KLAW13m0=
|
||||
github.com/projectdiscovery/asnmap v1.1.0/go.mod h1:QNjBnGLxUBEZAgaYk/Av5cjKKWFY3i/FOfoIWCUApoY=
|
||||
github.com/projectdiscovery/asnmap v1.1.1 h1:ImJiKIaACOT7HPx4Pabb5dksolzaFYsD1kID2iwsDqI=
|
||||
github.com/projectdiscovery/asnmap v1.1.1/go.mod h1:QT7jt9nQanj+Ucjr9BqGr1Q2veCCKSAVyUzLXfEcQ60=
|
||||
github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ=
|
||||
github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss=
|
||||
github.com/projectdiscovery/cdncheck v1.0.9 h1:BS15gzj9gb5AVSKqTDzPamfSgStu7nJQOocUvrssFlg=
|
||||
github.com/projectdiscovery/cdncheck v1.0.9/go.mod h1:18SSl1w7rMj53CGeRIZTbDoa286a6xZIxGbaiEo4Fxs=
|
||||
github.com/projectdiscovery/cdncheck v1.1.0 h1:qDITidmJsejzpk3rMkauCh6sjI2GH9hW/snk0cQ3kXE=
|
||||
github.com/projectdiscovery/cdncheck v1.1.0/go.mod h1:sZ8U4MjHSsyaTVjBbYWHT1cwUVvUYwDX1W+WvWRicIc=
|
||||
github.com/projectdiscovery/clistats v0.0.20 h1:5jO5SLiRJ7f0nDV0ndBNmBeesbROouPooH+DGMgoWq4=
|
||||
github.com/projectdiscovery/clistats v0.0.20/go.mod h1:GJ2av0KnOvK0AISQnP8hyDclYIji1LVkx2l0pwnzAu4=
|
||||
github.com/projectdiscovery/dsl v0.1.3 h1:Lxlgpx8lwq/CaBjVUmwF6KmkMDnYf9IVKlMsWCF72OE=
|
||||
github.com/projectdiscovery/dsl v0.1.3/go.mod h1:WAuQLD4KQ/94RASotE7cvk7X6kY7JQG9Fcqc3lRQfpI=
|
||||
github.com/projectdiscovery/fastdialer v0.1.5 h1:5rNJ8I+GVzDsUqRSVLUqGTm7LsshfNYmCh20lLn1aaI=
|
||||
github.com/projectdiscovery/fastdialer v0.1.5/go.mod h1:oVoMl9Y6da2timhszy0okyBvhbKDSk+zqFazGV4y6pU=
|
||||
github.com/projectdiscovery/dsl v0.1.6 h1:6TUYMwbjcYJ5OoRoawPX1SYD7wgubX/1FreC8SwFqgc=
|
||||
github.com/projectdiscovery/dsl v0.1.6/go.mod h1:1PAV9A6X+fdyMXW0SY4i0BHrO8yN2+FB2jp25+0AT04=
|
||||
github.com/projectdiscovery/fastdialer v0.1.6 h1:dtdE7WjaydpndKPcUYWms5iOhBSC0nvBAHyZd6I4pdQ=
|
||||
github.com/projectdiscovery/fastdialer v0.1.6/go.mod h1:a5XOjvaO4b+ddO/YLoM4nvK3CPPviW6HmoAd+AoszMw=
|
||||
github.com/projectdiscovery/fasttemplate v0.0.2 h1:h2cISk5xDhlJEinlBQS6RRx0vOlOirB2y3Yu4PJzpiA=
|
||||
github.com/projectdiscovery/fasttemplate v0.0.2/go.mod h1:XYWWVMxnItd+r0GbjA1GCsUopMw1/XusuQxdyAIHMCw=
|
||||
github.com/projectdiscovery/freeport v0.0.5 h1:jnd3Oqsl4S8n0KuFkE5Hm8WGDP24ITBvmyw5pFTHS8Q=
|
||||
github.com/projectdiscovery/freeport v0.0.5/go.mod h1:PY0bxSJ34HVy67LHIeF3uIutiCSDwOqKD8ruBkdiCwE=
|
||||
github.com/projectdiscovery/go-smb2 v0.0.0-20240129202741-052cc450c6cb h1:rutG906Drtbpz4DwU5mhGIeOhRcktDH4cGQitGUMAsg=
|
||||
github.com/projectdiscovery/go-smb2 v0.0.0-20240129202741-052cc450c6cb/go.mod h1:FLjF1DmZ+POoGEiIQdWuYVwS++C/GwpX8YaCsTSm1RY=
|
||||
github.com/projectdiscovery/goflags v0.1.56 h1:tJYiZN7s9Jk9DxfYOUiqOoybaIDlXyX4ZgT4B/06SyU=
|
||||
github.com/projectdiscovery/goflags v0.1.56/go.mod h1:DsGF0NPpM5hGg75N3MTSvWJ4MIT7HFEAOEeWZ074+Fg=
|
||||
github.com/projectdiscovery/gologger v1.1.12 h1:uX/QkQdip4PubJjjG0+uk5DtyAi1ANPJUvpmimXqv4A=
|
||||
github.com/projectdiscovery/gologger v1.1.12/go.mod h1:DI8nywPLERS5mo8QEA9E7gd5HZ3Je14SjJBH3F5/kLw=
|
||||
github.com/projectdiscovery/goflags v0.1.59 h1:rFScpC57L0Ln0dJmBtstyxHUH7K9H4UmHACXcSkdqqk=
|
||||
github.com/projectdiscovery/goflags v0.1.59/go.mod h1:dj67QGp/D81WRLtzU0HsWR20zgoGZ0cnk3Wbt9xJcuo=
|
||||
github.com/projectdiscovery/gologger v1.1.14 h1:8SS9qDCisCFffKHzWMX+GDDArxBJ9A7DhYrESEixAYo=
|
||||
github.com/projectdiscovery/gologger v1.1.14/go.mod h1:CPk1nAZ3PqgspKBuSJR+xwY2i/Rm+P/ovahpP30EJy8=
|
||||
github.com/projectdiscovery/gostruct v0.0.2 h1:s8gP8ApugGM4go1pA+sVlPDXaWqNP5BBDDSv7VEdG1M=
|
||||
github.com/projectdiscovery/gostruct v0.0.2/go.mod h1:H86peL4HKwMXcQQtEa6lmC8FuD9XFt6gkNR0B/Mu5PE=
|
||||
github.com/projectdiscovery/gozero v0.0.2 h1:8fJeaCjxL9tpm33uG/RsCQs6HGM/NE6eA3cjkilRQ+E=
|
||||
github.com/projectdiscovery/gozero v0.0.2/go.mod h1:d8bZvDWW07LWNYWrwjZ4OO1I0cpkfqaysyDfSs9ibK8=
|
||||
github.com/projectdiscovery/hmap v0.0.47 h1:NdakfvlFruevnOvehdllofg/hc0CQn2WQaLHaRcsGAk=
|
||||
github.com/projectdiscovery/hmap v0.0.47/go.mod h1:/9V6EnyTY33hAy71Quox6Ggu9ZkKp36tgepBh/NzNSg=
|
||||
github.com/projectdiscovery/hmap v0.0.49 h1:QNW98JDqd0nmaIFRMbn0sLocRIGXAud1liGip4iPdvc=
|
||||
github.com/projectdiscovery/hmap v0.0.49/go.mod h1:BA4cyYTrWKMUa78815R6p3tuGiYu2MJHYnjwXmefdbU=
|
||||
github.com/projectdiscovery/httpx v1.6.3 h1:TSu3zEKOHGFfMsGeB0lZEFRl6Tq4nPuIgKDXi9NnYpg=
|
||||
github.com/projectdiscovery/httpx v1.6.3/go.mod h1:9FmsmkT71aTa4WnOyBIPzB8I9c0QAJ9PSVUqs2NkHRQ=
|
||||
github.com/projectdiscovery/interactsh v1.2.0 h1:Al6jHiR+Usl9egYJDLJaWNHOcH8Rugk8gWMasc8Cmw8=
|
||||
@@ -870,14 +870,14 @@ github.com/projectdiscovery/networkpolicy v0.0.9 h1:IrlDoYZagNNO8y+7iZeHT8k5izE+
|
||||
github.com/projectdiscovery/networkpolicy v0.0.9/go.mod h1:XFJ2Lnv8BE/ziQCFjBHMsH1w6VmkPiQtk+NlBpdMU7M=
|
||||
github.com/projectdiscovery/ratelimit v0.0.45 h1:h28oF+hJ0CHcdBZozT1Go7ppWmzTxSXDKNNh2G1Ot9Q=
|
||||
github.com/projectdiscovery/ratelimit v0.0.45/go.mod h1:1vSJUseDS7SjNwIBi9wNRcgsMKNTLxy/GfdlLFVbgI4=
|
||||
github.com/projectdiscovery/rawhttp v0.1.51 h1:T4sskU2fsX9zNR7nyae0tD/0fliIs73KwBzyoJwBs10=
|
||||
github.com/projectdiscovery/rawhttp v0.1.51/go.mod h1:ejBaw3dCfJSfbtFv0ib6YfFSjQzt7ZdRVpQWJASxIUs=
|
||||
github.com/projectdiscovery/rawhttp v0.1.57 h1:2vCT2i1NSZbTBH+uUBrxOJjxDPKgIl2q6BGtQjs/Hko=
|
||||
github.com/projectdiscovery/rawhttp v0.1.57/go.mod h1:qtthyaU0k8eqcEdza1R/fTqwyxSK4BZ511ThxgkiQtE=
|
||||
github.com/projectdiscovery/rdap v0.9.1-0.20221108103045-9865884d1917 h1:m03X4gBVSorSzvmm0bFa7gDV4QNSOWPL/fgZ4kTXBxk=
|
||||
github.com/projectdiscovery/rdap v0.9.1-0.20221108103045-9865884d1917/go.mod h1:JxXtZC9e195awe7EynrcnBJmFoad/BNDzW9mzFkK8Sg=
|
||||
github.com/projectdiscovery/retryabledns v1.0.65 h1:wOtMuVkrcrGkzaT8Jixb3BtUcJODXLRz+z9EjftmFsQ=
|
||||
github.com/projectdiscovery/retryabledns v1.0.65/go.mod h1:lf3xRdFhGh55fWVlzK1oAaDPrsKliqH3gGvsFNAOkCk=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.66 h1:dY+sGVf/O8CvKcSdTx0rxJoKG+HyOScz5T89TijZohU=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.66/go.mod h1:3QJt06j4hEZVpJOr31u49I3mDnqbAzhcjJX8Yvn/xnY=
|
||||
github.com/projectdiscovery/retryabledns v1.0.66 h1:OzKcR+TqIYdSDEED2JWJA90ZNFCEKRv+hOvpMHEZEOY=
|
||||
github.com/projectdiscovery/retryabledns v1.0.66/go.mod h1:ODpvZ6kXXB2uqK7GPyfkd/tR+4wkeIm1DR5TkRQv7KE=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.68 h1:MN/kfccDnebmp1kNcCnGlGuCfvet6y5eN1Y1hIKBB1I=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.68/go.mod h1:F3QNCoJExPFT59AACrVgYVhNiDW5Fp8s5HbXc+8CaaU=
|
||||
github.com/projectdiscovery/sarif v0.0.1 h1:C2Tyj0SGOKbCLgHrx83vaE6YkzXEVrMXYRGLkKCr/us=
|
||||
github.com/projectdiscovery/sarif v0.0.1/go.mod h1:cEYlDu8amcPf6b9dSakcz2nNnJsoz4aR6peERwV+wuQ=
|
||||
github.com/projectdiscovery/stringsutil v0.0.2 h1:uzmw3IVLJSMW1kEg8eCStG/cGbYYZAja8BH3LqqJXMA=
|
||||
@@ -886,12 +886,12 @@ github.com/projectdiscovery/tlsx v1.1.6 h1:iw2zwKbd2+kRQ8J1G4dLmS0CLyemd/tKz1Uzc
|
||||
github.com/projectdiscovery/tlsx v1.1.6/go.mod h1:s7SRRFdrwIZBK/RXXZi4CR/CubqFSvp8h5Bk1srEZIo=
|
||||
github.com/projectdiscovery/uncover v1.0.8 h1:nE8bYJuwhqk0BEMRQRhNbjPGMy40A9gkiMk5xq6U4u0=
|
||||
github.com/projectdiscovery/uncover v1.0.8/go.mod h1:1SwsNqjwMkJEzJQ7lQr5AHIdYd+BQlyqhO5IwIYmIAM=
|
||||
github.com/projectdiscovery/useragent v0.0.56 h1:KpUtOgq1vUerPrgRFZAIr1hF0lDxA2RF6YkT2PLwSoQ=
|
||||
github.com/projectdiscovery/useragent v0.0.56/go.mod h1:LAh9vudxXPA5JfNN3+1g/Unqvulq0BDkjxK7IrE+e/s=
|
||||
github.com/projectdiscovery/utils v0.1.4 h1:VSULN/RBEXbkgWuhrDey84ZDnSXtYMSev9p+QHXXDeI=
|
||||
github.com/projectdiscovery/utils v0.1.4/go.mod h1:mXs6OOeG9l/dVchjB2PGvQO3+wuMiE14Y/kmHeKogoM=
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.6 h1:4iZDEnytsnAqjQgD5K6lmAzVx++KSQeMCDfomDtQM1M=
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.6/go.mod h1:wBYGKmA5BQp/NWsAy1q/jSH8N1LHWQ/LV26DuR+KzPM=
|
||||
github.com/projectdiscovery/useragent v0.0.60 h1:qDU1rwA+XOKmSqp7yoijAN4PuvLQc2ZvuaoWH7QIkuc=
|
||||
github.com/projectdiscovery/useragent v0.0.60/go.mod h1:05IDiJEy2dWl3x6dnsWtJYPwT40oWha144Us7+Fwr6w=
|
||||
github.com/projectdiscovery/utils v0.2.1 h1:XcOUJtR5ReXDWqxDkJWPVpC2lSqIYTs8z8YNILcPiqk=
|
||||
github.com/projectdiscovery/utils v0.2.1/go.mod h1:h3o2zmJguUm9FKvel1F9jYCLxoWhFakyytRMjqb7Dg4=
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.10 h1:cUTMw8xYXyKTAxUiGYltJxEh4OtJyCvaahj+RG3mHSY=
|
||||
github.com/projectdiscovery/wappalyzergo v0.1.10/go.mod h1:/hzgxkBFTMe2wDbA93nFfoMjULw7/vIZ9QPSAnCgUa8=
|
||||
github.com/projectdiscovery/yamldoc-go v1.0.4 h1:eZoESapnMw6WAHiVgRwNqvbJEfNHEH148uthhFbG5jE=
|
||||
github.com/projectdiscovery/yamldoc-go v1.0.4/go.mod h1:8PIPRcUD55UbtQdcfFR1hpIGRWG0P7alClXNGt1TBik=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
|
||||
@@ -23,4 +23,4 @@ code:
|
||||
- type: dsl
|
||||
dsl:
|
||||
- true
|
||||
# digest: 490a004630440220192fb8f704b078c2885047b85ac1a0491be86485c033a976d201599683a35aab0220604b1c3781e9d97079d0e5c23c18e6a2d87493c8e2b930536e692ee7d06e9247:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4a0a0047304502200307590191cb7c766b6c21e5777d345bdddf7adf9d6da8f7d336d585d9ac4a8b022100fd30fb0c7722778eb3d861d60e721d805925b8d8df2b979ef2104c35ec57d5cb:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -20,4 +20,4 @@ code:
|
||||
- type: word
|
||||
words:
|
||||
- "hello from input baz"
|
||||
# digest: 4a0a00473045022033f72f1b9d5143f58a2dc79c2597000f34080251ac3702c36c3fad00917dfeeb0221009ba05c715c9e2e36dba471be6c0106a09ae3822d8a3e9e4bcf377e9f4a395a01:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4a0a0047304502203fe1d7d52bc2a41886d576a90c82c3be42078baaa4b46e1f3d8519665d6f88b202210081feb82c41150c5b218e226fc4f299ded19f42ba01ef34ba60b0634b4ea6ee12:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -18,4 +18,4 @@ code:
|
||||
- type: word
|
||||
words:
|
||||
- "hello from input"
|
||||
# digest: 4a0a004730450220377128cb11d9f6f0fee1f4dbd841e46783de26e90a216fa55a7609ee2bc823c60221009166ee0f85e3a1811588ab19e73ea96ab3d582dc8180dbcbbad0ea9ab7e9025d:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4b0a00483046022100afb5ebff14a40e7f9b679ffc4d93ce7849e33eb398ebb47f2e757cd24831f9dd02210089ffa21b2763e99ebce95dfc5b91e1e62da4ccdc9d2ad5c48584fa350ba335af:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -26,4 +26,4 @@ code:
|
||||
part: interactsh_protocol
|
||||
words:
|
||||
- "http"
|
||||
# digest: 4b0a00483046022100d472d50bd83117d334f5217c7a40dcdf34138e90029eaace51697d902296bf37022100a393b49420a96f60d6d89b79b5135ee2233b2468d374851890eea114b08195d1:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4b0a00483046022100939f83e74d43932a5bd792b1fd2c100eec2df60f2b2a8dd56b5c8ef5faa92b17022100f93031b0de373af7d78e623968ea5a2d67c4561ef70e3e6da15aef7e5c853115:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -21,4 +21,4 @@ code:
|
||||
- type: word
|
||||
words:
|
||||
- "hello from input"
|
||||
# digest: 4b0a004830460221008886054bb5dd6345e434e30f31c8fddce3c484a4f33aa6321b5185675866029d022100d188a83d0fde029f8b586061c65ab72b43755c3fb10fdd59501bb9bbadbb1ff7:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4a0a00473045022100b8e676ce0c57b60c233a0203539dec20457bbb5f1790d351a5d45405b6668b2602204b1f2fa18e7db099f05329009597ceb2d9b7337562c1a676e8d50ea2f1c6fcbe:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -19,4 +19,4 @@ code:
|
||||
regex:
|
||||
- 'hello from (.*)'
|
||||
group: 1
|
||||
# digest: 490a0046304402202c63d47bb0acdd40b3b852d95490d492ff5741b84071b2a8a40371be7797c13602202b6b977e157edf2ef70a402a2e57d4eb5a67c5ca91f0a2f9a10a966e8485ebaf:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 490a00463044022050da011362cf08c2cb81e812c7f86d7282afe0562d4bf00d390f1300d19bc910022029e9d305da69e941ac18797645aecb217abde6557f891e141301b48e89a3c0cd:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -18,4 +18,4 @@ code:
|
||||
- type: word
|
||||
words:
|
||||
- "hello from first"
|
||||
# digest: 490a00463044022025661eab353b7f359c0d428a86b6287545d7f759375e8025cc8c9c77b616ca6502200bc2c019059622df3c88e7caa6dd7d1fb9b956010aa0de2ee2b9f7dd0a3c4954:4a3eb6b4988d95847d4203be25ed1d46
|
||||
# digest: 4b0a00483046022100b3b8759c0df028455eb59b1433ac240e5d4604b011bb0c63680bd3cc159ac6f0022100f44aa11b640d11ad0e2902897f4eb51666ab3cd83c31dfd2590f6e43391e39b0:4a3eb6b4988d95847d4203be25ed1d46
|
||||
@@ -440,3 +440,11 @@ func WithCatalog(cat catalog.Catalog) NucleiSDKOptions {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DisableUpdateCheck disables nuclei update check
|
||||
func DisableUpdateCheck() NucleiSDKOptions {
|
||||
return func(e *NucleiEngine) error {
|
||||
DefaultConfig.DisableUpdateCheck()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -108,6 +108,14 @@ func (e *NucleiEngine) init(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if e.opts.ProxyInternal && types.ProxyURL != "" || types.ProxySocksURL != "" {
|
||||
httpclient, err := httpclientpool.Get(e.opts, &httpclientpool.Configuration{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.httpClient = httpclient
|
||||
}
|
||||
|
||||
e.parser = templates.NewParser()
|
||||
|
||||
if sharedInit == nil || protocolstate.ShouldInit() {
|
||||
@@ -121,14 +129,6 @@ func (e *NucleiEngine) init(ctx context.Context) error {
|
||||
e.applyRequiredDefaults(ctx)
|
||||
var err error
|
||||
|
||||
if e.opts.ProxyInternal && types.ProxyURL != "" || types.ProxySocksURL != "" {
|
||||
httpclient, err := httpclientpool.Get(e.opts, &httpclientpool.Configuration{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.httpClient = httpclient
|
||||
}
|
||||
|
||||
// setup progressbar
|
||||
if e.enableStats {
|
||||
progressInstance, progressErr := progress.NewStatsTicker(e.opts.StatsInterval, e.enableStats, e.opts.StatsJSON, false, e.opts.MetricsPort)
|
||||
|
||||
@@ -941,11 +941,6 @@
|
||||
"title": "code to execute in javascript",
|
||||
"description": "Executes inline javascript code for the request"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "integer",
|
||||
"title": "timeout for javascript execution",
|
||||
"description": "Timeout in seconds is optional timeout for entire javascript script execution"
|
||||
},
|
||||
"stop-at-first-match": {
|
||||
"type": "boolean",
|
||||
"title": "stop at first match",
|
||||
|
||||
@@ -31,7 +31,7 @@ const (
|
||||
CLIConfigFileName = "config.yaml"
|
||||
ReportingConfigFilename = "reporting-config.yaml"
|
||||
// Version is the current version of nuclei
|
||||
Version = `v3.2.9`
|
||||
Version = `v3.3.0`
|
||||
// Directory Names of custom templates
|
||||
CustomS3TemplatesDirName = "s3"
|
||||
CustomGitHubTemplatesDirName = "github"
|
||||
|
||||
@@ -27,7 +27,7 @@ func (e *Engine) executeAllSelfContained(ctx context.Context, alltemplates []*te
|
||||
var match bool
|
||||
ctx := scan.NewScanContext(ctx, contextargs.New(ctx))
|
||||
if e.Callback != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err == nil {
|
||||
for _, result := range results {
|
||||
e.Callback(result)
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
|
||||
match = e.executeWorkflow(ctx, template.CompiledWorkflow)
|
||||
default:
|
||||
if e.Callback != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err == nil {
|
||||
for _, result := range results {
|
||||
e.Callback(result)
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func (e *Engine) executeTemplatesOnTarget(ctx context.Context, alltemplates []*t
|
||||
match = e.executeWorkflow(ctx, template.CompiledWorkflow)
|
||||
default:
|
||||
if e.Callback != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err != nil {
|
||||
if results, err := template.Executer.ExecuteWithResults(ctx); err == nil {
|
||||
for _, result := range results {
|
||||
e.Callback(result)
|
||||
}
|
||||
|
||||
@@ -66,9 +66,10 @@ func (i *HttpInputProvider) Count() int64 {
|
||||
// Iterate over all inputs in order
|
||||
func (i *HttpInputProvider) Iterate(callback func(value *contextargs.MetaInput) bool) {
|
||||
err := i.format.Parse(i.inputFile, func(request *types.RequestResponse) bool {
|
||||
return callback(&contextargs.MetaInput{
|
||||
ReqResp: request,
|
||||
})
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.ReqResp = request
|
||||
metaInput.Input = request.URL.String()
|
||||
return callback(metaInput)
|
||||
})
|
||||
if err != nil {
|
||||
gologger.Warning().Msgf("Could not parse input file while iterating: %s\n", err)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
|
||||
configTypes "github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||
errorutil "github.com/projectdiscovery/utils/errors"
|
||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -32,7 +33,7 @@ func IsErrNotImplemented(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
if strings.Contains(err.Error(), "provider") && strings.Contains(err.Error(), "does not implement") {
|
||||
if stringsutil.ContainsAll(err.Error(), "provider", "does not implement") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -122,7 +122,7 @@ func (i *ListInputProvider) Iterate(callback func(value *contextargs.MetaInput)
|
||||
})
|
||||
}
|
||||
callbackFunc := func(k, _ []byte) error {
|
||||
metaInput := &contextargs.MetaInput{}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
if err := metaInput.Unmarshal(string(k)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -153,14 +153,16 @@ func (i *ListInputProvider) Set(value string) {
|
||||
}
|
||||
return fmt.Sprintf("got empty hostname for %v skipping ip selection", URL)
|
||||
})
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = URL
|
||||
i.setItem(metaInput)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if input is ip or hostname
|
||||
if iputil.IsIP(urlx.Hostname()) {
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = URL
|
||||
i.setItem(metaInput)
|
||||
return
|
||||
}
|
||||
@@ -181,7 +183,9 @@ func (i *ListInputProvider) Set(value string) {
|
||||
if ip == "" {
|
||||
continue
|
||||
}
|
||||
metaInput := &contextargs.MetaInput{Input: value, CustomIP: ip}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = value
|
||||
metaInput.CustomIP = ip
|
||||
i.setItem(metaInput)
|
||||
}
|
||||
return
|
||||
@@ -211,11 +215,13 @@ func (i *ListInputProvider) Set(value string) {
|
||||
}
|
||||
|
||||
for _, ip := range ips {
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
if ip != "" {
|
||||
metaInput := &contextargs.MetaInput{Input: URL, CustomIP: ip}
|
||||
metaInput.Input = URL
|
||||
metaInput.CustomIP = ip
|
||||
i.setItem(metaInput)
|
||||
} else {
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput.Input = URL
|
||||
i.setItem(metaInput)
|
||||
}
|
||||
}
|
||||
@@ -353,7 +359,8 @@ func (i *ListInputProvider) scanInputFromReader(reader io.Reader) {
|
||||
|
||||
// isExcluded checks if a URL is in the exclusion list
|
||||
func (i *ListInputProvider) isExcluded(URL string) bool {
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = URL
|
||||
key, err := metaInput.MarshalString()
|
||||
if err != nil {
|
||||
gologger.Warning().Msgf("%s\n", err)
|
||||
@@ -378,14 +385,16 @@ func (i *ListInputProvider) Del(value string) {
|
||||
}
|
||||
return fmt.Sprintf("got empty hostname for %v skipping ip selection", URL)
|
||||
})
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = URL
|
||||
i.delItem(metaInput)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if input is ip or hostname
|
||||
if iputil.IsIP(urlx.Hostname()) {
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = URL
|
||||
i.delItem(metaInput)
|
||||
return
|
||||
}
|
||||
@@ -406,7 +415,9 @@ func (i *ListInputProvider) Del(value string) {
|
||||
if ip == "" {
|
||||
continue
|
||||
}
|
||||
metaInput := &contextargs.MetaInput{Input: value, CustomIP: ip}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = value
|
||||
metaInput.CustomIP = ip
|
||||
i.delItem(metaInput)
|
||||
}
|
||||
return
|
||||
@@ -436,11 +447,13 @@ func (i *ListInputProvider) Del(value string) {
|
||||
}
|
||||
|
||||
for _, ip := range ips {
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
if ip != "" {
|
||||
metaInput := &contextargs.MetaInput{Input: URL, CustomIP: ip}
|
||||
metaInput.Input = URL
|
||||
metaInput.CustomIP = ip
|
||||
i.delItem(metaInput)
|
||||
} else {
|
||||
metaInput := &contextargs.MetaInput{Input: URL}
|
||||
metaInput.Input = URL
|
||||
i.delItem(metaInput)
|
||||
}
|
||||
}
|
||||
@@ -514,7 +527,8 @@ func (i *ListInputProvider) addTargets(targets []string) {
|
||||
|
||||
func (i *ListInputProvider) removeTargets(targets []string) {
|
||||
for _, target := range targets {
|
||||
metaInput := &contextargs.MetaInput{Input: target}
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = target
|
||||
i.delItem(metaInput)
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func Test_expandCIDR(t *testing.T) {
|
||||
// scan
|
||||
got := []string{}
|
||||
input.hostMap.Scan(func(k, _ []byte) error {
|
||||
var metainput contextargs.MetaInput
|
||||
metainput := contextargs.NewMetaInput()
|
||||
if err := metainput.Unmarshal(string(k)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func Test_scanallips_normalizeStoreInputValue(t *testing.T) {
|
||||
// scan
|
||||
got := []string{}
|
||||
input.hostMap.Scan(func(k, v []byte) error {
|
||||
var metainput contextargs.MetaInput
|
||||
metainput := contextargs.NewMetaInput()
|
||||
if err := metainput.Unmarshal(string(k)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func Test_expandASNInputValue(t *testing.T) {
|
||||
// scan the hmap
|
||||
got := []string{}
|
||||
input.hostMap.Scan(func(k, v []byte) error {
|
||||
var metainput contextargs.MetaInput
|
||||
metainput := contextargs.NewMetaInput()
|
||||
if err := metainput.Unmarshal(string(k)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ func (s *SimpleInputProvider) Iterate(callback func(value *contextargs.MetaInput
|
||||
|
||||
// Set adds an item to the input provider
|
||||
func (s *SimpleInputProvider) Set(value string) {
|
||||
s.Inputs = append(s.Inputs, &contextargs.MetaInput{Input: value})
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = value
|
||||
s.Inputs = append(s.Inputs, metaInput)
|
||||
}
|
||||
|
||||
// SetWithProbe adds an item to the input provider with HTTP probing
|
||||
@@ -52,13 +54,17 @@ func (s *SimpleInputProvider) SetWithProbe(value string, probe types.InputLivene
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Inputs = append(s.Inputs, &contextargs.MetaInput{Input: probedValue})
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = probedValue
|
||||
s.Inputs = append(s.Inputs, metaInput)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetWithExclusions adds an item to the input provider if it doesn't match any of the exclusions
|
||||
func (s *SimpleInputProvider) SetWithExclusions(value string) error {
|
||||
s.Inputs = append(s.Inputs, &contextargs.MetaInput{Input: value})
|
||||
metaInput := contextargs.NewMetaInput()
|
||||
metaInput.Input = value
|
||||
s.Inputs = append(s.Inputs, metaInput)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ package compiler
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||
contextutil "github.com/projectdiscovery/utils/context"
|
||||
"github.com/projectdiscovery/utils/errkit"
|
||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||
@@ -38,13 +38,13 @@ type ExecuteOptions struct {
|
||||
// Cleanup is extra cleanup function to be called after execution
|
||||
Cleanup func(runtime *goja.Runtime)
|
||||
|
||||
/// Timeout for this script execution
|
||||
Timeout int
|
||||
// Source is original source of the script
|
||||
Source *string
|
||||
|
||||
Context context.Context
|
||||
|
||||
TimeoutVariants *types.Timeouts
|
||||
|
||||
// Manually exported objects
|
||||
exports map[string]interface{}
|
||||
}
|
||||
@@ -79,15 +79,6 @@ func (e ExecuteResult) GetSuccess() bool {
|
||||
return val
|
||||
}
|
||||
|
||||
// Execute executes a script with the default options.
|
||||
func (c *Compiler) Execute(code string, args *ExecuteArgs) (ExecuteResult, error) {
|
||||
p, err := WrapScriptNCompile(code, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.ExecuteWithOptions(p, args, &ExecuteOptions{Context: context.Background()})
|
||||
}
|
||||
|
||||
// ExecuteWithOptions executes a script with the provided options.
|
||||
func (c *Compiler) ExecuteWithOptions(program *goja.Program, args *ExecuteArgs, opts *ExecuteOptions) (ExecuteResult, error) {
|
||||
if opts == nil {
|
||||
@@ -106,14 +97,9 @@ func (c *Compiler) ExecuteWithOptions(program *goja.Program, args *ExecuteArgs,
|
||||
// merge all args into templatectx
|
||||
args.TemplateCtx = generators.MergeMaps(args.TemplateCtx, args.Args)
|
||||
|
||||
if opts.Timeout <= 0 || opts.Timeout > 180 {
|
||||
// some js scripts can take longer time so allow configuring timeout
|
||||
// from template but keep it within sane limits (180s)
|
||||
opts.Timeout = JsProtocolTimeout
|
||||
}
|
||||
|
||||
// execute with context and timeout
|
||||
ctx, cancel := context.WithTimeoutCause(opts.Context, time.Duration(opts.Timeout)*time.Second, ErrJSExecDeadline)
|
||||
|
||||
ctx, cancel := context.WithTimeoutCause(opts.Context, opts.TimeoutVariants.JsCompilerExecutionTimeout, ErrJSExecDeadline)
|
||||
defer cancel()
|
||||
// execute the script
|
||||
results, err := contextutil.ExecFuncWithTwoReturns(ctx, func() (val goja.Value, err error) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/gologger/levels"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||
)
|
||||
|
||||
func TestNewCompilerConsoleDebug(t *testing.T) {
|
||||
@@ -18,7 +21,14 @@ func TestNewCompilerConsoleDebug(t *testing.T) {
|
||||
})
|
||||
|
||||
compiler := New()
|
||||
_, err := compiler.Execute("console.log('hello world');", NewExecuteArgs())
|
||||
p, err := WrapScriptNCompile("console.log('hello world');", false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = compiler.ExecuteWithOptions(p, NewExecuteArgs(), &ExecuteOptions{Context: context.Background(),
|
||||
TimeoutVariants: &types.Timeouts{JsCompilerExecutionTimeout: time.Duration(20) * time.Second}},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -27,17 +37,6 @@ func TestNewCompilerConsoleDebug(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteResultGetSuccess(t *testing.T) {
|
||||
compiler := New()
|
||||
result, err := compiler.Execute("1+1 == 2", NewExecuteArgs())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.GetSuccess() != true {
|
||||
t.Fatalf("expected true, got=%v", result.GetSuccess())
|
||||
}
|
||||
}
|
||||
|
||||
type noopWriter struct {
|
||||
Callback func(data []byte, level levels.Level)
|
||||
}
|
||||
|
||||
+1
-10
@@ -7,26 +7,17 @@ import (
|
||||
// jsprotocolInit
|
||||
|
||||
var (
|
||||
// Per Execution Javascript timeout in seconds
|
||||
JsProtocolTimeout = 10
|
||||
PoolingJsVmConcurrency = 100
|
||||
NonPoolingVMConcurrency = 20
|
||||
JsTimeoutMultiplier = 1.5
|
||||
)
|
||||
|
||||
// Init initializes the javascript protocol
|
||||
func Init(opts *types.Options) error {
|
||||
if opts.Timeout < 10 {
|
||||
// keep existing 10s timeout
|
||||
return nil
|
||||
}
|
||||
|
||||
if opts.JsConcurrency < 100 {
|
||||
// 100 is reasonable default
|
||||
opts.JsConcurrency = 100
|
||||
}
|
||||
// we have dialer timeout set to 10s so js needs to be at least
|
||||
// 15s to return the actual error if not it will be a dialer timeout
|
||||
JsProtocolTimeout = int(float64(opts.Timeout) * JsTimeoutMultiplier)
|
||||
PoolingJsVmConcurrency = opts.JsConcurrency
|
||||
PoolingJsVmConcurrency -= NonPoolingVMConcurrency
|
||||
return nil
|
||||
|
||||
@@ -241,5 +241,5 @@ func stringify(gojaValue goja.Value, runtime *goja.Runtime) string {
|
||||
}
|
||||
}
|
||||
// for everything else stringify
|
||||
return fmt.Sprintf("%v", value)
|
||||
return fmt.Sprintf("%+v", value)
|
||||
}
|
||||
@@ -42,7 +42,11 @@ Description: getNetworkPort registers defaultPort and returns defaultPort if it
|
||||
|
||||
Name: isPortOpen
|
||||
Signatures: "isPortOpen(host string, port string, [timeout int]) bool"
|
||||
Description: isPortOpen checks if given port is open on host. timeout is optional and defaults to 5 seconds
|
||||
Description: isPortOpen checks if given TCP port is open on host. timeout is optional and defaults to 5 seconds
|
||||
|
||||
Name: isUDPPortOpen
|
||||
Signatures: "isUDPPortOpen(host string, port string, [timeout int]) bool"
|
||||
Description: isUDPPortOpen checks if the given UDP port is open on the host. Timeout is optional and defaults to 5 seconds.
|
||||
|
||||
Name: ToBytes
|
||||
Signatures: "ToBytes(...interface{}) []byte"
|
||||
|
||||
@@ -53,10 +53,12 @@ func init() {
|
||||
"FilterWorkstationTrustAccount": lib_ldap.FilterWorkstationTrustAccount,
|
||||
|
||||
// Objects / Classes
|
||||
"ADObject": gojs.GetClassConstructor[lib_ldap.ADObject](&lib_ldap.ADObject{}),
|
||||
"Client": lib_ldap.NewClient,
|
||||
"Config": gojs.GetClassConstructor[lib_ldap.Config](&lib_ldap.Config{}),
|
||||
"Metadata": gojs.GetClassConstructor[lib_ldap.Metadata](&lib_ldap.Metadata{}),
|
||||
"Client": lib_ldap.NewClient,
|
||||
"Config": gojs.GetClassConstructor[lib_ldap.Config](&lib_ldap.Config{}),
|
||||
"LdapAttributes": gojs.GetClassConstructor[lib_ldap.LdapAttributes](&lib_ldap.LdapAttributes{}),
|
||||
"LdapEntry": gojs.GetClassConstructor[lib_ldap.LdapEntry](&lib_ldap.LdapEntry{}),
|
||||
"Metadata": gojs.GetClassConstructor[lib_ldap.Metadata](&lib_ldap.Metadata{}),
|
||||
"SearchResult": gojs.GetClassConstructor[lib_ldap.SearchResult](&lib_ldap.SearchResult{}),
|
||||
},
|
||||
).Register()
|
||||
}
|
||||
|
||||
@@ -188,9 +188,9 @@ export class Config {
|
||||
*/
|
||||
export interface AuthorizationDataEntry {
|
||||
|
||||
ADType?: number,
|
||||
|
||||
ADData?: Uint8Array,
|
||||
|
||||
ADType?: number,
|
||||
}
|
||||
|
||||
|
||||
@@ -200,9 +200,9 @@ export interface AuthorizationDataEntry {
|
||||
*/
|
||||
export interface BitString {
|
||||
|
||||
BitLength?: number,
|
||||
|
||||
Bytes?: Uint8Array,
|
||||
|
||||
BitLength?: number,
|
||||
}
|
||||
|
||||
|
||||
@@ -212,9 +212,9 @@ export interface BitString {
|
||||
*/
|
||||
export interface BitString {
|
||||
|
||||
BitLength?: number,
|
||||
|
||||
Bytes?: Uint8Array,
|
||||
|
||||
BitLength?: number,
|
||||
}
|
||||
|
||||
|
||||
@@ -236,19 +236,15 @@ export interface Config {
|
||||
*/
|
||||
export interface EncTicketPart {
|
||||
|
||||
AuthTime?: Date,
|
||||
|
||||
StartTime?: Date,
|
||||
|
||||
EndTime?: Date,
|
||||
|
||||
RenewTill?: Date,
|
||||
|
||||
CRealm?: string,
|
||||
|
||||
CAddr?: HostAddress,
|
||||
AuthTime?: Date,
|
||||
|
||||
AuthorizationData?: AuthorizationDataEntry,
|
||||
StartTime?: Date,
|
||||
|
||||
Flags?: BitString,
|
||||
|
||||
@@ -257,6 +253,10 @@ export interface EncTicketPart {
|
||||
CName?: PrincipalName,
|
||||
|
||||
Transited?: TransitedEncoding,
|
||||
|
||||
CAddr?: HostAddress,
|
||||
|
||||
AuthorizationData?: AuthorizationDataEntry,
|
||||
}
|
||||
|
||||
|
||||
@@ -266,11 +266,11 @@ export interface EncTicketPart {
|
||||
*/
|
||||
export interface EncryptedData {
|
||||
|
||||
EType?: number,
|
||||
|
||||
KVNO?: number,
|
||||
|
||||
Cipher?: Uint8Array,
|
||||
|
||||
EType?: number,
|
||||
}
|
||||
|
||||
|
||||
@@ -318,41 +318,33 @@ export interface HostAddress {
|
||||
*/
|
||||
export interface LibDefaults {
|
||||
|
||||
NoAddresses?: boolean,
|
||||
|
||||
RealmTryDomains?: number,
|
||||
|
||||
DNSLookupKDC?: boolean,
|
||||
|
||||
DefaultRealm?: string,
|
||||
|
||||
SafeChecksumType?: number,
|
||||
|
||||
VerifyAPReqNofail?: boolean,
|
||||
|
||||
AllowWeakCrypto?: boolean,
|
||||
|
||||
DefaultTGSEnctypes?: string[],
|
||||
|
||||
DefaultTktEnctypeIDs?: number[],
|
||||
|
||||
IgnoreAcceptorHostname?: boolean,
|
||||
CCacheType?: number,
|
||||
|
||||
K5LoginAuthoritative?: boolean,
|
||||
|
||||
PermittedEnctypes?: string[],
|
||||
Proxiable?: boolean,
|
||||
|
||||
RDNS?: boolean,
|
||||
|
||||
K5LoginDirectory?: string,
|
||||
|
||||
KDCTimeSync?: number,
|
||||
|
||||
VerifyAPReqNofail?: boolean,
|
||||
|
||||
DefaultTGSEnctypes?: string[],
|
||||
|
||||
DefaultTGSEnctypeIDs?: number[],
|
||||
|
||||
DNSCanonicalizeHostname?: boolean,
|
||||
|
||||
Forwardable?: boolean,
|
||||
|
||||
/**
|
||||
* time in nanoseconds
|
||||
*/
|
||||
|
||||
Clockskew?: number,
|
||||
|
||||
DNSCanonicalizeHostname?: boolean,
|
||||
|
||||
Proxiable?: boolean,
|
||||
|
||||
RDNS?: boolean,
|
||||
RenewLifetime?: number,
|
||||
|
||||
/**
|
||||
* time in nanoseconds
|
||||
@@ -362,37 +354,45 @@ export interface LibDefaults {
|
||||
|
||||
DefaultClientKeytabName?: string,
|
||||
|
||||
PermittedEnctypeIDs?: number[],
|
||||
|
||||
UDPPreferenceLimit?: number,
|
||||
|
||||
DefaultTGSEnctypeIDs?: number[],
|
||||
|
||||
DefaultTktEnctypes?: string[],
|
||||
|
||||
CCacheType?: number,
|
||||
DefaultTktEnctypeIDs?: number[],
|
||||
|
||||
DNSLookupRealm?: boolean,
|
||||
|
||||
ExtraAddresses?: Uint8Array,
|
||||
|
||||
DefaultRealm?: string,
|
||||
|
||||
NoAddresses?: boolean,
|
||||
|
||||
PreferredPreauthTypes?: number[],
|
||||
|
||||
PermittedEnctypeIDs?: number[],
|
||||
|
||||
RealmTryDomains?: number,
|
||||
|
||||
DefaultKeytabName?: string,
|
||||
|
||||
DefaultTktEnctypes?: string[],
|
||||
|
||||
DNSLookupKDC?: boolean,
|
||||
|
||||
IgnoreAcceptorHostname?: boolean,
|
||||
|
||||
AllowWeakCrypto?: boolean,
|
||||
|
||||
Canonicalize?: boolean,
|
||||
|
||||
Forwardable?: boolean,
|
||||
SafeChecksumType?: number,
|
||||
|
||||
K5LoginDirectory?: string,
|
||||
|
||||
KDCTimeSync?: number,
|
||||
UDPPreferenceLimit?: number,
|
||||
|
||||
/**
|
||||
* time in nanoseconds
|
||||
*/
|
||||
|
||||
RenewLifetime?: number,
|
||||
Clockskew?: number,
|
||||
|
||||
DefaultKeytabName?: string,
|
||||
PermittedEnctypes?: string[],
|
||||
|
||||
KDCDefaultOptions?: BitString,
|
||||
}
|
||||
@@ -416,6 +416,8 @@ export interface PrincipalName {
|
||||
*/
|
||||
export interface Realm {
|
||||
|
||||
Realm?: string,
|
||||
|
||||
AdminServer?: string[],
|
||||
|
||||
DefaultDomain?: string,
|
||||
@@ -425,8 +427,6 @@ export interface Realm {
|
||||
KPasswdServer?: string[],
|
||||
|
||||
MasterKDC?: string[],
|
||||
|
||||
Realm?: string,
|
||||
}
|
||||
|
||||
|
||||
|
||||
+214
-62
@@ -209,8 +209,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public FindADObjects(filter: string): ADObject[] {
|
||||
return [];
|
||||
public FindADObjects(filter: string): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,8 +225,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public GetADUsers(): ADObject[] {
|
||||
return [];
|
||||
public GetADUsers(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -241,8 +241,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public GetADActiveUsers(): ADObject[] {
|
||||
return [];
|
||||
public GetADActiveUsers(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,8 +257,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public GetADUserWithNeverExpiringPasswords(): ADObject[] {
|
||||
return [];
|
||||
public GetADUserWithNeverExpiringPasswords(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,8 +273,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public GetADUserTrustedForDelegation(): ADObject[] {
|
||||
return [];
|
||||
public GetADUserTrustedForDelegation(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -289,8 +289,8 @@ export class Client {
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
public GetADUserWithPasswordNotRequired(): ADObject[] {
|
||||
return [];
|
||||
public GetADUserWithPasswordNotRequired(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -305,8 +305,8 @@ export class Client {
|
||||
* log(to_json(groups));
|
||||
* ```
|
||||
*/
|
||||
public GetADGroups(): ADObject[] {
|
||||
return [];
|
||||
public GetADGroups(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,8 +321,8 @@ export class Client {
|
||||
* log(to_json(dcs));
|
||||
* ```
|
||||
*/
|
||||
public GetADDCList(): ADObject[] {
|
||||
return [];
|
||||
public GetADDCList(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -337,8 +337,8 @@ export class Client {
|
||||
* log(to_json(admins));
|
||||
* ```
|
||||
*/
|
||||
public GetADAdmins(): ADObject[] {
|
||||
return [];
|
||||
public GetADAdmins(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -353,8 +353,8 @@ export class Client {
|
||||
* log(to_json(kerberoastable));
|
||||
* ```
|
||||
*/
|
||||
public GetADUserKerberoastable(): ADObject[] {
|
||||
return [];
|
||||
public GetADUserKerberoastable(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -369,8 +369,8 @@ export class Client {
|
||||
* log(to_json(AsRepRoastable));
|
||||
* ```
|
||||
*/
|
||||
public GetADUserAsRepRoastable(): ADObject[] {
|
||||
return [];
|
||||
public GetADUserAsRepRoastable(): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -428,8 +428,8 @@ export class Client {
|
||||
* const results = client.Search('(objectClass=*)', 'cn', 'mail');
|
||||
* ```
|
||||
*/
|
||||
public Search(filter: string, attributes: any): Record<string, string[]>[] {
|
||||
return [];
|
||||
public Search(filter: string, attributes: any): SearchResult | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -481,33 +481,6 @@ export class Client {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ADObject represents an Active Directory object
|
||||
* @example
|
||||
* ```javascript
|
||||
* const ldap = require('nuclei/ldap');
|
||||
* const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
|
||||
* const users = client.GetADUsers();
|
||||
* log(to_json(users));
|
||||
* ```
|
||||
*/
|
||||
export interface ADObject {
|
||||
|
||||
DistinguishedName?: string,
|
||||
|
||||
SAMAccountName?: string,
|
||||
|
||||
PWDLastSet?: string,
|
||||
|
||||
LastLogon?: string,
|
||||
|
||||
MemberOf?: string[],
|
||||
|
||||
ServicePrincipalName?: string[],
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Config is extra configuration for the ldap client
|
||||
* @example
|
||||
@@ -535,27 +508,186 @@ export interface Config {
|
||||
|
||||
|
||||
/**
|
||||
* Entry Interface
|
||||
* LdapAttributes represents all LDAP attributes of a particular
|
||||
* ldap entry
|
||||
*/
|
||||
export interface Entry {
|
||||
export interface LdapAttributes {
|
||||
|
||||
DN?: string,
|
||||
/**
|
||||
* CurrentTime contains current time
|
||||
*/
|
||||
|
||||
Attributes?: EntryAttribute,
|
||||
CurrentTime?: string[],
|
||||
|
||||
/**
|
||||
* SubschemaSubentry contains subschema subentry
|
||||
*/
|
||||
|
||||
SubschemaSubentry?: string[],
|
||||
|
||||
/**
|
||||
* DsServiceName contains ds service name
|
||||
*/
|
||||
|
||||
DsServiceName?: string[],
|
||||
|
||||
/**
|
||||
* NamingContexts contains naming contexts
|
||||
*/
|
||||
|
||||
NamingContexts?: string[],
|
||||
|
||||
/**
|
||||
* DefaultNamingContext contains default naming context
|
||||
*/
|
||||
|
||||
DefaultNamingContext?: string[],
|
||||
|
||||
/**
|
||||
* SchemaNamingContext contains schema naming context
|
||||
*/
|
||||
|
||||
SchemaNamingContext?: string[],
|
||||
|
||||
/**
|
||||
* ConfigurationNamingContext contains configuration naming context
|
||||
*/
|
||||
|
||||
ConfigurationNamingContext?: string[],
|
||||
|
||||
/**
|
||||
* RootDomainNamingContext contains root domain naming context
|
||||
*/
|
||||
|
||||
RootDomainNamingContext?: string[],
|
||||
|
||||
/**
|
||||
* SupportedLDAPVersion contains supported LDAP version
|
||||
*/
|
||||
|
||||
SupportedLDAPVersion?: string[],
|
||||
|
||||
/**
|
||||
* HighestCommittedUSN contains highest committed USN
|
||||
*/
|
||||
|
||||
HighestCommittedUSN?: string[],
|
||||
|
||||
/**
|
||||
* SupportedSASLMechanisms contains supported SASL mechanisms
|
||||
*/
|
||||
|
||||
SupportedSASLMechanisms?: string[],
|
||||
|
||||
/**
|
||||
* DnsHostName contains DNS host name
|
||||
*/
|
||||
|
||||
DnsHostName?: string[],
|
||||
|
||||
/**
|
||||
* LdapServiceName contains LDAP service name
|
||||
*/
|
||||
|
||||
LdapServiceName?: string[],
|
||||
|
||||
/**
|
||||
* ServerName contains server name
|
||||
*/
|
||||
|
||||
ServerName?: string[],
|
||||
|
||||
/**
|
||||
* IsSynchronized contains is synchronized
|
||||
*/
|
||||
|
||||
IsSynchronized?: string[],
|
||||
|
||||
/**
|
||||
* IsGlobalCatalogReady contains is global catalog ready
|
||||
*/
|
||||
|
||||
IsGlobalCatalogReady?: string[],
|
||||
|
||||
/**
|
||||
* DomainFunctionality contains domain functionality
|
||||
*/
|
||||
|
||||
DomainFunctionality?: string[],
|
||||
|
||||
/**
|
||||
* ForestFunctionality contains forest functionality
|
||||
*/
|
||||
|
||||
ForestFunctionality?: string[],
|
||||
|
||||
/**
|
||||
* DomainControllerFunctionality contains domain controller functionality
|
||||
*/
|
||||
|
||||
DomainControllerFunctionality?: string[],
|
||||
|
||||
/**
|
||||
* DistinguishedName contains the distinguished name
|
||||
*/
|
||||
|
||||
DistinguishedName?: string[],
|
||||
|
||||
/**
|
||||
* SAMAccountName contains the SAM account name
|
||||
*/
|
||||
|
||||
SAMAccountName?: string[],
|
||||
|
||||
/**
|
||||
* PWDLastSet contains the password last set time
|
||||
*/
|
||||
|
||||
PWDLastSet?: string[],
|
||||
|
||||
/**
|
||||
* LastLogon contains the last logon time
|
||||
*/
|
||||
|
||||
LastLogon?: string[],
|
||||
|
||||
/**
|
||||
* MemberOf contains the groups the entry is a member of
|
||||
*/
|
||||
|
||||
MemberOf?: string[],
|
||||
|
||||
/**
|
||||
* ServicePrincipalName contains the service principal names
|
||||
*/
|
||||
|
||||
ServicePrincipalName?: string[],
|
||||
|
||||
/**
|
||||
* Extra contains other extra fields which might be present
|
||||
*/
|
||||
|
||||
Extra?: Record<string, any>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* EntryAttribute Interface
|
||||
* LdapEntry represents a single LDAP entry
|
||||
*/
|
||||
export interface EntryAttribute {
|
||||
export interface LdapEntry {
|
||||
|
||||
Name?: string,
|
||||
/**
|
||||
* DN contains distinguished name
|
||||
*/
|
||||
|
||||
Values?: string[],
|
||||
DN?: string,
|
||||
|
||||
ByteValues?: Uint8Array,
|
||||
/**
|
||||
* Attributes contains list of attributes
|
||||
*/
|
||||
|
||||
Attributes?: LdapAttributes,
|
||||
}
|
||||
|
||||
|
||||
@@ -584,12 +716,32 @@ export interface Metadata {
|
||||
|
||||
|
||||
/**
|
||||
* SearchResult Interface
|
||||
* SearchResult contains search result of any / all ldap search request
|
||||
* @example
|
||||
* ```javascript
|
||||
* const ldap = require('nuclei/ldap');
|
||||
* const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
|
||||
* const results = client.Search('(objectinterface=*)', 'cn', 'mail');
|
||||
* ```
|
||||
*/
|
||||
export interface SearchResult {
|
||||
|
||||
/**
|
||||
* Referrals contains list of referrals
|
||||
*/
|
||||
|
||||
Referrals?: string[],
|
||||
|
||||
Entries?: Entry,
|
||||
/**
|
||||
* Controls contains list of controls
|
||||
*/
|
||||
|
||||
Controls?: string[],
|
||||
|
||||
/**
|
||||
* Entries contains list of entries
|
||||
*/
|
||||
|
||||
Entries?: LdapEntry[],
|
||||
}
|
||||
|
||||
@@ -78,8 +78,6 @@ export interface IsRDPResponse {
|
||||
*/
|
||||
export interface ServiceRDP {
|
||||
|
||||
DNSDomainName?: string,
|
||||
|
||||
ForestName?: string,
|
||||
|
||||
OSFingerprint?: string,
|
||||
@@ -93,5 +91,7 @@ export interface ServiceRDP {
|
||||
NetBIOSDomainName?: string,
|
||||
|
||||
DNSComputerName?: string,
|
||||
|
||||
DNSDomainName?: string,
|
||||
}
|
||||
|
||||
+12
-12
@@ -137,6 +137,10 @@ export interface NegotiationLog {
|
||||
*/
|
||||
export interface SMBCapabilities {
|
||||
|
||||
DFSSupport?: boolean,
|
||||
|
||||
Leasing?: boolean,
|
||||
|
||||
LargeMTU?: boolean,
|
||||
|
||||
MultiChan?: boolean,
|
||||
@@ -146,10 +150,6 @@ export interface SMBCapabilities {
|
||||
DirLeasing?: boolean,
|
||||
|
||||
Encryption?: boolean,
|
||||
|
||||
DFSSupport?: boolean,
|
||||
|
||||
Leasing?: boolean,
|
||||
}
|
||||
|
||||
|
||||
@@ -159,16 +159,16 @@ export interface SMBCapabilities {
|
||||
*/
|
||||
export interface SMBLog {
|
||||
|
||||
SupportV1?: boolean,
|
||||
|
||||
NativeOs?: string,
|
||||
|
||||
NTLM?: string,
|
||||
|
||||
GroupName?: string,
|
||||
|
||||
HasNTLM?: boolean,
|
||||
|
||||
SupportV1?: boolean,
|
||||
|
||||
NativeOs?: string,
|
||||
|
||||
Version?: SMBVersions,
|
||||
|
||||
Capabilities?: SMBCapabilities,
|
||||
@@ -185,13 +185,13 @@ export interface SMBLog {
|
||||
*/
|
||||
export interface SMBVersions {
|
||||
|
||||
VerString?: string,
|
||||
|
||||
Major?: number,
|
||||
|
||||
Minor?: number,
|
||||
|
||||
Revision?: number,
|
||||
|
||||
VerString?: string,
|
||||
}
|
||||
|
||||
|
||||
@@ -225,12 +225,12 @@ export interface ServiceSMB {
|
||||
*/
|
||||
export interface SessionSetupLog {
|
||||
|
||||
NegotiateFlags?: number,
|
||||
|
||||
SetupFlags?: number,
|
||||
|
||||
TargetName?: string,
|
||||
|
||||
NegotiateFlags?: number,
|
||||
|
||||
HeaderLog?: HeaderLog,
|
||||
}
|
||||
|
||||
+22
-22
@@ -133,9 +133,9 @@ export interface Algorithms {
|
||||
|
||||
HostKey?: string,
|
||||
|
||||
R?: DirectionAlgorithms,
|
||||
|
||||
W?: DirectionAlgorithms,
|
||||
|
||||
R?: DirectionAlgorithms,
|
||||
}
|
||||
|
||||
|
||||
@@ -159,13 +159,13 @@ export interface DirectionAlgorithms {
|
||||
*/
|
||||
export interface EndpointId {
|
||||
|
||||
Raw?: string,
|
||||
|
||||
ProtoVersion?: string,
|
||||
|
||||
SoftwareVersion?: string,
|
||||
|
||||
Comment?: string,
|
||||
|
||||
Raw?: string,
|
||||
|
||||
ProtoVersion?: string,
|
||||
}
|
||||
|
||||
|
||||
@@ -197,34 +197,34 @@ export interface HandshakeLog {
|
||||
*/
|
||||
export interface KexInitMsg {
|
||||
|
||||
KexAlgos?: string[],
|
||||
|
||||
CiphersClientServer?: string[],
|
||||
|
||||
MACsServerClient?: string[],
|
||||
|
||||
LanguagesClientServer?: string[],
|
||||
|
||||
CompressionClientServer?: string[],
|
||||
|
||||
CompressionServerClient?: string[],
|
||||
|
||||
Reserved?: number,
|
||||
|
||||
MACsClientServer?: string[],
|
||||
|
||||
/**
|
||||
* fixed size array of length: [16]
|
||||
*/
|
||||
|
||||
Cookie?: Uint8Array,
|
||||
|
||||
CiphersClientServer?: string[],
|
||||
|
||||
MACsClientServer?: string[],
|
||||
|
||||
MACsServerClient?: string[],
|
||||
|
||||
CompressionServerClient?: string[],
|
||||
|
||||
LanguagesClientServer?: string[],
|
||||
|
||||
FirstKexFollows?: boolean,
|
||||
|
||||
KexAlgos?: string[],
|
||||
ServerHostKeyAlgos?: string[],
|
||||
|
||||
CiphersServerClient?: string[],
|
||||
|
||||
CompressionClientServer?: string[],
|
||||
|
||||
LanguagesServerClient?: string[],
|
||||
|
||||
ServerHostKeyAlgos?: string[],
|
||||
FirstKexFollows?: boolean,
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func initBuiltInFunc(runtime *goja.Runtime) {
|
||||
Signatures: []string{
|
||||
"isPortOpen(host string, port string, [timeout int]) bool",
|
||||
},
|
||||
Description: "isPortOpen checks if given port is open on host. timeout is optional and defaults to 5 seconds",
|
||||
Description: "isPortOpen checks if given TCP port is open on host. timeout is optional and defaults to 5 seconds",
|
||||
FuncDecl: func(host string, port string, timeout ...int) (bool, error) {
|
||||
timeoutInSec := 5
|
||||
if len(timeout) > 0 {
|
||||
@@ -124,6 +124,27 @@ func initBuiltInFunc(runtime *goja.Runtime) {
|
||||
},
|
||||
})
|
||||
|
||||
_ = gojs.RegisterFuncWithSignature(runtime, gojs.FuncOpts{
|
||||
Name: "isUDPPortOpen",
|
||||
Signatures: []string{
|
||||
"isUDPPortOpen(host string, port string, [timeout int]) bool",
|
||||
},
|
||||
Description: "isUDPPortOpen checks if the given UDP port is open on the host. Timeout is optional and defaults to 5 seconds.",
|
||||
FuncDecl: func(host string, port string, timeout ...int) (bool, error) {
|
||||
timeoutInSec := 5
|
||||
if len(timeout) > 0 {
|
||||
timeoutInSec = timeout[0]
|
||||
}
|
||||
conn, err := net.DialTimeout("udp", net.JoinHostPort(host, port), time.Duration(timeoutInSec)*time.Second)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
_ = conn.Close()
|
||||
|
||||
return true, nil
|
||||
},
|
||||
})
|
||||
|
||||
_ = gojs.RegisterFuncWithSignature(runtime, gojs.FuncOpts{
|
||||
Name: "ToBytes",
|
||||
Signatures: []string{
|
||||
|
||||
+24
-46
@@ -74,25 +74,6 @@ func NegativeFilter(filter string) string {
|
||||
return fmt.Sprintf("(!%s)", filter)
|
||||
}
|
||||
|
||||
type (
|
||||
// ADObject represents an Active Directory object
|
||||
// @example
|
||||
// ```javascript
|
||||
// const ldap = require('nuclei/ldap');
|
||||
// const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
|
||||
// const users = client.GetADUsers();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
ADObject struct {
|
||||
DistinguishedName string
|
||||
SAMAccountName string
|
||||
PWDLastSet string
|
||||
LastLogon string
|
||||
MemberOf []string
|
||||
ServicePrincipalName []string
|
||||
}
|
||||
)
|
||||
|
||||
// FindADObjects finds AD objects based on a filter
|
||||
// and returns them as a list of ADObject
|
||||
// @example
|
||||
@@ -102,7 +83,7 @@ type (
|
||||
// const users = client.FindADObjects(ldap.FilterIsPerson);
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) FindADObjects(filter string) []ADObject {
|
||||
func (c *Client) FindADObjects(filter string) SearchResult {
|
||||
c.nj.Require(c.conn != nil, "no existing connection")
|
||||
sr := ldap.NewSearchRequest(
|
||||
c.BaseDN, ldap.ScopeWholeSubtree,
|
||||
@@ -121,19 +102,7 @@ func (c *Client) FindADObjects(filter string) []ADObject {
|
||||
|
||||
res, err := c.conn.Search(sr)
|
||||
c.nj.HandleError(err, "ldap search request failed")
|
||||
|
||||
var objects []ADObject
|
||||
for _, obj := range res.Entries {
|
||||
objects = append(objects, ADObject{
|
||||
DistinguishedName: obj.GetAttributeValue("distinguishedName"),
|
||||
SAMAccountName: obj.GetAttributeValue("sAMAccountName"),
|
||||
PWDLastSet: DecodeADTimestamp(obj.GetAttributeValue("pwdLastSet")),
|
||||
LastLogon: DecodeADTimestamp(obj.GetAttributeValue("lastLogon")),
|
||||
MemberOf: obj.GetAttributeValues("memberOf"),
|
||||
ServicePrincipalName: obj.GetAttributeValues("servicePrincipalName"),
|
||||
})
|
||||
}
|
||||
return objects
|
||||
return *getSearchResult(res)
|
||||
}
|
||||
|
||||
// GetADUsers returns all AD users
|
||||
@@ -145,7 +114,7 @@ func (c *Client) FindADObjects(filter string) []ADObject {
|
||||
// const users = client.GetADUsers();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) GetADUsers() []ADObject {
|
||||
func (c *Client) GetADUsers() SearchResult {
|
||||
return c.FindADObjects(FilterIsPerson)
|
||||
}
|
||||
|
||||
@@ -158,7 +127,7 @@ func (c *Client) GetADUsers() []ADObject {
|
||||
// const users = client.GetADActiveUsers();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) GetADActiveUsers() []ADObject {
|
||||
func (c *Client) GetADActiveUsers() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterAccountEnabled))
|
||||
}
|
||||
|
||||
@@ -171,7 +140,7 @@ func (c *Client) GetADActiveUsers() []ADObject {
|
||||
// const users = client.GetADUserWithNeverExpiringPasswords();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) GetADUserWithNeverExpiringPasswords() []ADObject {
|
||||
func (c *Client) GetADUserWithNeverExpiringPasswords() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterDontExpirePassword))
|
||||
}
|
||||
|
||||
@@ -184,7 +153,7 @@ func (c *Client) GetADUserWithNeverExpiringPasswords() []ADObject {
|
||||
// const users = client.GetADUserTrustedForDelegation();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) GetADUserTrustedForDelegation() []ADObject {
|
||||
func (c *Client) GetADUserTrustedForDelegation() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterTrustedForDelegation))
|
||||
}
|
||||
|
||||
@@ -197,7 +166,7 @@ func (c *Client) GetADUserTrustedForDelegation() []ADObject {
|
||||
// const users = client.GetADUserWithPasswordNotRequired();
|
||||
// log(to_json(users));
|
||||
// ```
|
||||
func (c *Client) GetADUserWithPasswordNotRequired() []ADObject {
|
||||
func (c *Client) GetADUserWithPasswordNotRequired() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterPasswordNotRequired))
|
||||
}
|
||||
|
||||
@@ -210,7 +179,7 @@ func (c *Client) GetADUserWithPasswordNotRequired() []ADObject {
|
||||
// const groups = client.GetADGroups();
|
||||
// log(to_json(groups));
|
||||
// ```
|
||||
func (c *Client) GetADGroups() []ADObject {
|
||||
func (c *Client) GetADGroups() SearchResult {
|
||||
return c.FindADObjects(FilterIsGroup)
|
||||
}
|
||||
|
||||
@@ -223,7 +192,7 @@ func (c *Client) GetADGroups() []ADObject {
|
||||
// const dcs = client.GetADDCList();
|
||||
// log(to_json(dcs));
|
||||
// ```
|
||||
func (c *Client) GetADDCList() []ADObject {
|
||||
func (c *Client) GetADDCList() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsComputer, FilterAccountEnabled, FilterServerTrustAccount))
|
||||
}
|
||||
|
||||
@@ -236,7 +205,7 @@ func (c *Client) GetADDCList() []ADObject {
|
||||
// const admins = client.GetADAdmins();
|
||||
// log(to_json(admins));
|
||||
// ```
|
||||
func (c *Client) GetADAdmins() []ADObject {
|
||||
func (c *Client) GetADAdmins() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterAccountEnabled, FilterIsAdmin))
|
||||
}
|
||||
|
||||
@@ -249,7 +218,7 @@ func (c *Client) GetADAdmins() []ADObject {
|
||||
// const kerberoastable = client.GetADUserKerberoastable();
|
||||
// log(to_json(kerberoastable));
|
||||
// ```
|
||||
func (c *Client) GetADUserKerberoastable() []ADObject {
|
||||
func (c *Client) GetADUserKerberoastable() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterAccountEnabled, FilterHasServicePrincipalName))
|
||||
}
|
||||
|
||||
@@ -262,7 +231,7 @@ func (c *Client) GetADUserKerberoastable() []ADObject {
|
||||
// const AsRepRoastable = client.GetADUserAsRepRoastable();
|
||||
// log(to_json(AsRepRoastable));
|
||||
// ```
|
||||
func (c *Client) GetADUserAsRepRoastable() []ADObject {
|
||||
func (c *Client) GetADUserAsRepRoastable() SearchResult {
|
||||
return c.FindADObjects(JoinFilters(FilterIsPerson, FilterDontRequirePreauth))
|
||||
}
|
||||
|
||||
@@ -276,7 +245,16 @@ func (c *Client) GetADUserAsRepRoastable() []ADObject {
|
||||
// ```
|
||||
func (c *Client) GetADDomainSID() string {
|
||||
r := c.Search(FilterServerTrustAccount, "objectSid")
|
||||
c.nj.Require(len(r) > 0, "no result from GetADDomainSID query")
|
||||
c.nj.Require(len(r[0]["objectSid"]) > 0, "could not grab DomainSID")
|
||||
return DecodeSID(r[0]["objectSid"][0])
|
||||
c.nj.Require(len(r.Entries) > 0, "no result from GetADDomainSID query")
|
||||
for _, entry := range r.Entries {
|
||||
if sid, ok := entry.Attributes.Extra["objectSid"]; ok {
|
||||
if sid, ok := sid.([]string); ok {
|
||||
return DecodeSID(sid[0])
|
||||
} else {
|
||||
c.nj.HandleError(fmt.Errorf("invalid objectSid type: %T", entry.Attributes.Extra["objectSid"]), "invalid objectSid type")
|
||||
}
|
||||
}
|
||||
}
|
||||
c.nj.HandleError(fmt.Errorf("no objectSid found"), "no objectSid found")
|
||||
return ""
|
||||
}
|
||||
+14
-28
@@ -203,38 +203,24 @@ func (c *Client) AuthenticateWithNTLMHash(username, hash string) {
|
||||
// const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
|
||||
// const results = client.Search('(objectClass=*)', 'cn', 'mail');
|
||||
// ```
|
||||
func (c *Client) Search(filter string, attributes ...string) []map[string][]string {
|
||||
func (c *Client) Search(filter string, attributes ...string) SearchResult {
|
||||
c.nj.Require(c.conn != nil, "no existing connection")
|
||||
c.nj.Require(c.BaseDN != "", "base dn cannot be empty")
|
||||
c.nj.Require(len(attributes) > 0, "attributes cannot be empty")
|
||||
|
||||
res, err := c.conn.Search(
|
||||
ldap.NewSearchRequest(
|
||||
c.BaseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases,
|
||||
0, 0, false, filter, attributes, nil,
|
||||
"",
|
||||
ldap.ScopeWholeSubtree,
|
||||
ldap.NeverDerefAliases,
|
||||
0, 0, false,
|
||||
filter,
|
||||
attributes,
|
||||
nil,
|
||||
),
|
||||
)
|
||||
c.nj.HandleError(err, "ldap search request failed")
|
||||
if len(res.Entries) == 0 {
|
||||
// return empty list
|
||||
return nil
|
||||
}
|
||||
|
||||
// convert ldap.Entry to []map[string][]string
|
||||
var out []map[string][]string
|
||||
for _, r := range res.Entries {
|
||||
app := make(map[string][]string)
|
||||
empty := true
|
||||
for _, a := range attributes {
|
||||
v := r.GetAttributeValues(a)
|
||||
if len(v) > 0 {
|
||||
app[a] = v
|
||||
empty = false
|
||||
}
|
||||
}
|
||||
if !empty {
|
||||
out = append(out, app)
|
||||
}
|
||||
}
|
||||
return out
|
||||
return *getSearchResult(res)
|
||||
}
|
||||
|
||||
// AdvancedSearch accepts all values of search request type and return Ldap Entry
|
||||
@@ -250,7 +236,7 @@ func (c *Client) AdvancedSearch(
|
||||
TypesOnly bool,
|
||||
Filter string,
|
||||
Attributes []string,
|
||||
Controls []ldap.Control) ldap.SearchResult {
|
||||
Controls []ldap.Control) SearchResult {
|
||||
c.nj.Require(c.conn != nil, "no existing connection")
|
||||
if c.BaseDN == "" {
|
||||
c.BaseDN = fmt.Sprintf("dc=%s", strings.Join(strings.Split(c.Realm, "."), ",dc="))
|
||||
@@ -259,7 +245,7 @@ func (c *Client) AdvancedSearch(
|
||||
res, err := c.conn.Search(req)
|
||||
c.nj.HandleError(err, "ldap search request failed")
|
||||
c.nj.Require(res != nil, "ldap search request failed got nil response")
|
||||
return *res
|
||||
return *getSearchResult(res)
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -295,7 +281,7 @@ func (c *Client) CollectMetadata() Metadata {
|
||||
|
||||
srMetadata := ldap.NewSearchRequest(
|
||||
"",
|
||||
ldap.ScopeBaseObject,
|
||||
ldap.ScopeWholeSubtree,
|
||||
ldap.NeverDerefAliases,
|
||||
0, 0, false,
|
||||
"(objectClass=*)",
|
||||
|
||||
@@ -5,8 +5,189 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
)
|
||||
|
||||
type (
|
||||
// SearchResult contains search result of any / all ldap search request
|
||||
// @example
|
||||
// ```javascript
|
||||
// const ldap = require('nuclei/ldap');
|
||||
// const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
|
||||
// const results = client.Search('(objectClass=*)', 'cn', 'mail');
|
||||
// ```
|
||||
SearchResult struct {
|
||||
// Referrals contains list of referrals
|
||||
Referrals []string `json:"referrals"`
|
||||
// Controls contains list of controls
|
||||
Controls []string `json:"controls"`
|
||||
// Entries contains list of entries
|
||||
Entries []LdapEntry `json:"entries"`
|
||||
}
|
||||
|
||||
// LdapEntry represents a single LDAP entry
|
||||
LdapEntry struct {
|
||||
// DN contains distinguished name
|
||||
DN string `json:"dn"`
|
||||
// Attributes contains list of attributes
|
||||
Attributes LdapAttributes `json:"attributes"`
|
||||
}
|
||||
|
||||
// LdapAttributes represents all LDAP attributes of a particular
|
||||
// ldap entry
|
||||
LdapAttributes struct {
|
||||
// CurrentTime contains current time
|
||||
CurrentTime []string `json:"currentTime,omitempty"`
|
||||
// SubschemaSubentry contains subschema subentry
|
||||
SubschemaSubentry []string `json:"subschemaSubentry,omitempty"`
|
||||
// DsServiceName contains ds service name
|
||||
DsServiceName []string `json:"dsServiceName,omitempty"`
|
||||
// NamingContexts contains naming contexts
|
||||
NamingContexts []string `json:"namingContexts,omitempty"`
|
||||
// DefaultNamingContext contains default naming context
|
||||
DefaultNamingContext []string `json:"defaultNamingContext,omitempty"`
|
||||
// SchemaNamingContext contains schema naming context
|
||||
SchemaNamingContext []string `json:"schemaNamingContext,omitempty"`
|
||||
// ConfigurationNamingContext contains configuration naming context
|
||||
ConfigurationNamingContext []string `json:"configurationNamingContext,omitempty"`
|
||||
// RootDomainNamingContext contains root domain naming context
|
||||
RootDomainNamingContext []string `json:"rootDomainNamingContext,omitempty"`
|
||||
// SupportedLDAPVersion contains supported LDAP version
|
||||
SupportedLDAPVersion []string `json:"supportedLDAPVersion,omitempty"`
|
||||
// HighestCommittedUSN contains highest committed USN
|
||||
HighestCommittedUSN []string `json:"highestCommittedUSN,omitempty"`
|
||||
// SupportedSASLMechanisms contains supported SASL mechanisms
|
||||
SupportedSASLMechanisms []string `json:"supportedSASLMechanisms,omitempty"`
|
||||
// DnsHostName contains DNS host name
|
||||
DnsHostName []string `json:"dnsHostName,omitempty"`
|
||||
// LdapServiceName contains LDAP service name
|
||||
LdapServiceName []string `json:"ldapServiceName,omitempty"`
|
||||
// ServerName contains server name
|
||||
ServerName []string `json:"serverName,omitempty"`
|
||||
// IsSynchronized contains is synchronized
|
||||
IsSynchronized []string `json:"isSynchronized,omitempty"`
|
||||
// IsGlobalCatalogReady contains is global catalog ready
|
||||
IsGlobalCatalogReady []string `json:"isGlobalCatalogReady,omitempty"`
|
||||
// DomainFunctionality contains domain functionality
|
||||
DomainFunctionality []string `json:"domainFunctionality,omitempty"`
|
||||
// ForestFunctionality contains forest functionality
|
||||
ForestFunctionality []string `json:"forestFunctionality,omitempty"`
|
||||
// DomainControllerFunctionality contains domain controller functionality
|
||||
DomainControllerFunctionality []string `json:"domainControllerFunctionality,omitempty"`
|
||||
// DistinguishedName contains the distinguished name
|
||||
DistinguishedName []string `json:"distinguishedName,omitempty"`
|
||||
// SAMAccountName contains the SAM account name
|
||||
SAMAccountName []string `json:"sAMAccountName,omitempty"`
|
||||
// PWDLastSet contains the password last set time
|
||||
PWDLastSet []string `json:"pwdLastSet,omitempty"`
|
||||
// LastLogon contains the last logon time
|
||||
LastLogon []string `json:"lastLogon,omitempty"`
|
||||
// MemberOf contains the groups the entry is a member of
|
||||
MemberOf []string `json:"memberOf,omitempty"`
|
||||
// ServicePrincipalName contains the service principal names
|
||||
ServicePrincipalName []string `json:"servicePrincipalName,omitempty"`
|
||||
// Extra contains other extra fields which might be present
|
||||
Extra map[string]any `json:"extra,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
// getSearchResult converts a ldap.SearchResult to a SearchResult
|
||||
func getSearchResult(sr *ldap.SearchResult) *SearchResult {
|
||||
t := &SearchResult{
|
||||
Referrals: []string{},
|
||||
Controls: []string{},
|
||||
Entries: []LdapEntry{},
|
||||
}
|
||||
// add referrals
|
||||
t.Referrals = append(t.Referrals, sr.Referrals...)
|
||||
// add controls
|
||||
for _, ctrl := range sr.Controls {
|
||||
t.Controls = append(t.Controls, ctrl.String())
|
||||
}
|
||||
// add entries
|
||||
for _, entry := range sr.Entries {
|
||||
t.Entries = append(t.Entries, parseLdapEntry(entry))
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func parseLdapEntry(entry *ldap.Entry) LdapEntry {
|
||||
e := LdapEntry{
|
||||
DN: entry.DN,
|
||||
}
|
||||
attrs := LdapAttributes{
|
||||
Extra: make(map[string]any),
|
||||
}
|
||||
for _, attr := range entry.Attributes {
|
||||
switch attr.Name {
|
||||
case "currentTime":
|
||||
attrs.CurrentTime = decodeTimestamps(attr.Values)
|
||||
case "subschemaSubentry":
|
||||
attrs.SubschemaSubentry = attr.Values
|
||||
case "dsServiceName":
|
||||
attrs.DsServiceName = attr.Values
|
||||
case "namingContexts":
|
||||
attrs.NamingContexts = attr.Values
|
||||
case "defaultNamingContext":
|
||||
attrs.DefaultNamingContext = attr.Values
|
||||
case "schemaNamingContext":
|
||||
attrs.SchemaNamingContext = attr.Values
|
||||
case "configurationNamingContext":
|
||||
attrs.ConfigurationNamingContext = attr.Values
|
||||
case "rootDomainNamingContext":
|
||||
attrs.RootDomainNamingContext = attr.Values
|
||||
case "supportedLDAPVersion":
|
||||
attrs.SupportedLDAPVersion = attr.Values
|
||||
case "highestCommittedUSN":
|
||||
attrs.HighestCommittedUSN = attr.Values
|
||||
case "supportedSASLMechanisms":
|
||||
attrs.SupportedSASLMechanisms = attr.Values
|
||||
case "dnsHostName":
|
||||
attrs.DnsHostName = attr.Values
|
||||
case "ldapServiceName":
|
||||
attrs.LdapServiceName = attr.Values
|
||||
case "serverName":
|
||||
attrs.ServerName = attr.Values
|
||||
case "isSynchronized":
|
||||
attrs.IsSynchronized = attr.Values
|
||||
case "isGlobalCatalogReady":
|
||||
attrs.IsGlobalCatalogReady = attr.Values
|
||||
case "domainFunctionality":
|
||||
attrs.DomainFunctionality = attr.Values
|
||||
case "forestFunctionality":
|
||||
attrs.ForestFunctionality = attr.Values
|
||||
case "domainControllerFunctionality":
|
||||
attrs.DomainControllerFunctionality = attr.Values
|
||||
case "distinguishedName":
|
||||
attrs.DistinguishedName = attr.Values
|
||||
case "sAMAccountName":
|
||||
attrs.SAMAccountName = attr.Values
|
||||
case "pwdLastSet":
|
||||
attrs.PWDLastSet = decodeTimestamps(attr.Values)
|
||||
case "lastLogon":
|
||||
attrs.LastLogon = decodeTimestamps(attr.Values)
|
||||
case "memberOf":
|
||||
attrs.MemberOf = attr.Values
|
||||
case "servicePrincipalName":
|
||||
attrs.ServicePrincipalName = attr.Values
|
||||
default:
|
||||
attrs.Extra[attr.Name] = attr.Values
|
||||
}
|
||||
}
|
||||
e.Attributes = attrs
|
||||
return e
|
||||
}
|
||||
|
||||
// decodeTimestamps decodes multiple timestamps
|
||||
func decodeTimestamps(timestamps []string) []string {
|
||||
res := []string{}
|
||||
for _, timestamp := range timestamps {
|
||||
res = append(res, DecodeADTimestamp(timestamp))
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// DecodeSID decodes a SID string
|
||||
// @example
|
||||
// ```javascript
|
||||
|
||||
@@ -36,6 +36,7 @@ type (
|
||||
// const isMySQL = mysql.IsMySQL('acme.com', 3306);
|
||||
// ```
|
||||
func (c *MySQLClient) IsMySQL(host string, port int) (bool, error) {
|
||||
// todo: why this is exposed? Service fingerprint should be automatic
|
||||
return memoizedisMySQL(host, port)
|
||||
}
|
||||
|
||||
@@ -77,6 +78,16 @@ func (c *MySQLClient) Connect(host string, port int, username, password string)
|
||||
// host is not valid according to network policy
|
||||
return false, protocolstate.ErrHostDenied.Msgf(host)
|
||||
}
|
||||
|
||||
// executing queries implies the remote mysql service
|
||||
ok, err := c.IsMySQL(host, port)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a mysql service")
|
||||
}
|
||||
|
||||
dsn, err := BuildDSN(MySQLOptions{
|
||||
Host: host,
|
||||
Port: port,
|
||||
@@ -182,6 +193,16 @@ func (c *MySQLClient) ExecuteQueryWithOpts(opts MySQLOptions, query string) (*ut
|
||||
// host is not valid according to network policy
|
||||
return nil, protocolstate.ErrHostDenied.Msgf(opts.Host)
|
||||
}
|
||||
|
||||
// executing queries implies the remote mysql service
|
||||
ok, err := c.IsMySQL(opts.Host, opts.Port)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a mysql service")
|
||||
}
|
||||
|
||||
dsn, err := BuildDSN(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -220,6 +241,15 @@ func (c *MySQLClient) ExecuteQueryWithOpts(opts MySQLOptions, query string) (*ut
|
||||
// log(to_json(result));
|
||||
// ```
|
||||
func (c *MySQLClient) ExecuteQuery(host string, port int, username, password, query string) (*utils.SQLResult, error) {
|
||||
// executing queries implies the remote mysql service
|
||||
ok, err := c.IsMySQL(host, port)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a mysql service")
|
||||
}
|
||||
|
||||
return c.ExecuteQueryWithOpts(MySQLOptions{
|
||||
Host: host,
|
||||
Port: port,
|
||||
|
||||
@@ -37,6 +37,7 @@ type (
|
||||
// const isPostgres = postgres.IsPostgres('acme.com', 5432);
|
||||
// ```
|
||||
func (c *PGClient) IsPostgres(host string, port int) (bool, error) {
|
||||
// todo: why this is exposed? Service fingerprint should be automatic
|
||||
return memoizedisPostgres(host, port)
|
||||
}
|
||||
|
||||
@@ -74,6 +75,13 @@ func isPostgres(host string, port int) (bool, error) {
|
||||
// const connected = client.Connect('acme.com', 5432, 'username', 'password');
|
||||
// ```
|
||||
func (c *PGClient) Connect(host string, port int, username, password string) (bool, error) {
|
||||
ok, err := c.IsPostgres(host, port)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a postgres service")
|
||||
}
|
||||
return memoizedconnect(host, port, username, password, "postgres")
|
||||
}
|
||||
|
||||
@@ -88,6 +96,14 @@ func (c *PGClient) Connect(host string, port int, username, password string) (bo
|
||||
// log(to_json(result));
|
||||
// ```
|
||||
func (c *PGClient) ExecuteQuery(host string, port int, username, password, dbName, query string) (*utils.SQLResult, error) {
|
||||
ok, err := c.IsPostgres(host, port)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a postgres service")
|
||||
}
|
||||
|
||||
return memoizedexecuteQuery(host, port, username, password, dbName, query)
|
||||
}
|
||||
|
||||
@@ -129,6 +145,14 @@ func executeQuery(host string, port int, username string, password string, dbNam
|
||||
// const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname');
|
||||
// ```
|
||||
func (c *PGClient) ConnectWithDB(host string, port int, username, password, dbName string) (bool, error) {
|
||||
ok, err := c.IsPostgres(host, port)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a postgres service")
|
||||
}
|
||||
|
||||
return memoizedconnect(host, port, username, password, dbName)
|
||||
}
|
||||
|
||||
@@ -149,10 +173,10 @@ func connect(host string, port int, username string, password string, dbName str
|
||||
defer cancel()
|
||||
|
||||
db := pg.Connect(&pg.Options{
|
||||
Addr: target,
|
||||
User: username,
|
||||
Password: password,
|
||||
Database: dbName,
|
||||
Addr: target,
|
||||
User: username,
|
||||
Password: password,
|
||||
Database: dbName,
|
||||
Dialer: func(network, addr string) (net.Conn, error) {
|
||||
return protocolstate.Dialer.Dial(context.Background(), network, addr)
|
||||
},
|
||||
|
||||
@@ -37,8 +37,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
pythonEnvRegex = `os\.getenv\(['"]([^'"]+)['"]\)`
|
||||
TimeoutMultiplier = 6 // timeout multiplier for code protocol
|
||||
pythonEnvRegex = `os\.getenv\(['"]([^'"]+)['"]\)`
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -179,9 +178,6 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa
|
||||
metaSrc.AddVariable(gozerotypes.Variable{Name: name, Value: v})
|
||||
}
|
||||
|
||||
// set timeout using multiplier
|
||||
timeout := TimeoutMultiplier * request.options.Options.Timeout
|
||||
|
||||
if request.PreCondition != "" {
|
||||
if request.options.Options.Debug || request.options.Options.DebugRequests {
|
||||
gologger.Debug().Msgf("[%s] Executing Precondition for Code request\n", request.TemplateID)
|
||||
@@ -199,11 +195,11 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa
|
||||
|
||||
result, err := request.options.JsCompiler.ExecuteWithOptions(request.preConditionCompiled, args,
|
||||
&compiler.ExecuteOptions{
|
||||
Timeout: timeout,
|
||||
Source: &request.PreCondition,
|
||||
Callback: registerPreConditionFunctions,
|
||||
Cleanup: cleanUpPreConditionFunctions,
|
||||
Context: input.Context(),
|
||||
TimeoutVariants: request.options.Options.GetTimeouts(),
|
||||
Source: &request.PreCondition,
|
||||
Callback: registerPreConditionFunctions,
|
||||
Cleanup: cleanUpPreConditionFunctions,
|
||||
Context: input.Context(),
|
||||
})
|
||||
if err != nil {
|
||||
return errorutil.NewWithTag(request.TemplateID, "could not execute pre-condition: %s", err)
|
||||
@@ -218,7 +214,7 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeoutCause(input.Context(), time.Duration(timeout)*time.Second, ErrCodeExecutionDeadline)
|
||||
ctx, cancel := context.WithTimeoutCause(input.Context(), request.options.Options.GetTimeouts().CodeExecutionTimeout, ErrCodeExecutionDeadline)
|
||||
defer cancel()
|
||||
// Note: we use contextutil despite the fact that gozero accepts context as argument
|
||||
gOutput, err := contextutil.ExecFuncWithTwoReturns(ctx, func() (*gozerotypes.Result, error) {
|
||||
|
||||
@@ -50,9 +50,11 @@ func NewWithInput(ctx context.Context, input string) *Context {
|
||||
if err != nil {
|
||||
gologger.Error().Msgf("contextargs: could not create cookie jar: %s\n", err)
|
||||
}
|
||||
metaInput := NewMetaInput()
|
||||
metaInput.Input = input
|
||||
return &Context{
|
||||
ctx: ctx,
|
||||
MetaInput: &MetaInput{Input: input},
|
||||
MetaInput: metaInput,
|
||||
CookieJar: jar,
|
||||
args: &mapsutil.SyncLockMap[string, interface{}]{
|
||||
Map: make(map[string]interface{}),
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/input/types"
|
||||
@@ -24,6 +25,12 @@ type MetaInput struct {
|
||||
|
||||
// ReqResp is the raw request for the input
|
||||
ReqResp *types.RequestResponse `json:"raw-request,omitempty"`
|
||||
|
||||
mu *sync.Mutex
|
||||
}
|
||||
|
||||
func NewMetaInput() *MetaInput {
|
||||
return &MetaInput{mu: &sync.Mutex{}}
|
||||
}
|
||||
|
||||
func (metaInput *MetaInput) marshalToBuffer() (bytes.Buffer, error) {
|
||||
@@ -135,10 +142,9 @@ func (metaInput *MetaInput) Unmarshal(data string) error {
|
||||
}
|
||||
|
||||
func (metaInput *MetaInput) Clone() *MetaInput {
|
||||
input := &MetaInput{
|
||||
Input: metaInput.Input,
|
||||
CustomIP: metaInput.CustomIP,
|
||||
}
|
||||
input := NewMetaInput()
|
||||
input.Input = metaInput.Input
|
||||
input.CustomIP = metaInput.CustomIP
|
||||
if metaInput.ReqResp != nil {
|
||||
input.ReqResp = metaInput.ReqResp.Clone()
|
||||
}
|
||||
@@ -160,6 +166,9 @@ func (metaInput *MetaInput) GetScanHash(templateId string) string {
|
||||
// there may be some cases where metainput is changed ex: while executing self-contained template etc
|
||||
// but that totally changes the scanID/hash so to avoid that we compute hash only once
|
||||
// and reuse it for all subsequent calls
|
||||
metaInput.mu.Lock()
|
||||
defer metaInput.mu.Unlock()
|
||||
|
||||
if metaInput.hash == "" {
|
||||
var rawRequest string
|
||||
if metaInput.ReqResp != nil {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/contextargs"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/types/nucleierr"
|
||||
"github.com/projectdiscovery/utils/errkit"
|
||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||
)
|
||||
|
||||
// CacheInterface defines the signature of the hosterrorscache so that
|
||||
@@ -200,7 +201,7 @@ func (c *Cache) checkError(err error) bool {
|
||||
errX := errkit.FromError(err)
|
||||
tmp := errX.Cause()
|
||||
cause := tmp.Error()
|
||||
if strings.Contains(cause, "ReadStatusLine:") && strings.Contains(cause, "read: connection reset by peer") {
|
||||
if stringsutil.ContainsAll(cause, "ReadStatusLine:", "read: connection reset by peer") {
|
||||
// this is a FP and should not be counted as a host error
|
||||
// because server closes connection when it reads corrupted bytes which we send via rawhttp
|
||||
return false
|
||||
|
||||
@@ -34,9 +34,7 @@ func Init(options *types.Options) error {
|
||||
|
||||
lfaAllowed = options.AllowLocalFileAccess
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.DialerTimeout > 0 {
|
||||
opts.DialerTimeout = options.DialerTimeout
|
||||
}
|
||||
opts.DialerTimeout = options.GetTimeouts().DialTimeout
|
||||
if options.DialerKeepAlive > 0 {
|
||||
opts.DialerKeepAlive = options.DialerKeepAlive
|
||||
}
|
||||
|
||||
@@ -215,6 +215,10 @@ func (request *Request) executeRequestWithPayloads(input *contextargs.Context, p
|
||||
}
|
||||
|
||||
dumpResponse(event, request.options, responseBody, input.MetaInput.Input)
|
||||
shouldStopAtFirstMatch := request.StopAtFirstMatch || request.options.StopAtFirstMatch || request.options.Options.StopAtFirstMatch
|
||||
if shouldStopAtFirstMatch && event.HasOperatorResult() {
|
||||
return types.ErrNoMoreRequests
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
|
||||
request.Raw[i] = strings.ReplaceAll(raw, "\n", "\r\n")
|
||||
}
|
||||
}
|
||||
request.rawhttpClient = httpclientpool.GetRawHTTP(options.Options)
|
||||
request.rawhttpClient = httpclientpool.GetRawHTTP(options)
|
||||
}
|
||||
if len(request.Matchers) > 0 || len(request.Extractors) > 0 {
|
||||
compiled := &request.Operators
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"golang.org/x/net/publicsuffix"
|
||||
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer/ja3/impersonate"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/utils"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||
@@ -31,28 +32,14 @@ var (
|
||||
forceMaxRedirects int
|
||||
normalClient *retryablehttp.Client
|
||||
clientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
|
||||
// MaxResponseHeaderTimeout is the timeout for response headers
|
||||
// to be read from the server (this prevents infinite hang started by server if any)
|
||||
// Note: this will be overridden temporarily when using @timeout request annotation
|
||||
MaxResponseHeaderTimeout = time.Duration(10) * time.Second
|
||||
// HttpTimeoutMultiplier is the multiplier for the http timeout
|
||||
HttpTimeoutMultiplier = 3
|
||||
)
|
||||
|
||||
// GetHttpTimeout returns the http timeout for the client
|
||||
func GetHttpTimeout(opts *types.Options) time.Duration {
|
||||
return time.Duration(opts.Timeout*HttpTimeoutMultiplier) * time.Second
|
||||
}
|
||||
|
||||
// Init initializes the clientpool implementation
|
||||
func Init(options *types.Options) error {
|
||||
// Don't create clients if already created in the past.
|
||||
if normalClient != nil {
|
||||
return nil
|
||||
}
|
||||
if options.Timeout > 10 {
|
||||
MaxResponseHeaderTimeout = time.Duration(options.Timeout) * time.Second
|
||||
}
|
||||
if options.ShouldFollowHTTPRedirects() {
|
||||
forceMaxRedirects = options.MaxRedirects
|
||||
}
|
||||
@@ -143,7 +130,7 @@ func (c *Configuration) HasStandardOptions() bool {
|
||||
}
|
||||
|
||||
// GetRawHTTP returns the rawhttp request client
|
||||
func GetRawHTTP(options *types.Options) *rawhttp.Client {
|
||||
func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
||||
if rawHttpClient == nil {
|
||||
rawHttpOptions := rawhttp.DefaultOptions
|
||||
if types.ProxyURL != "" {
|
||||
@@ -153,7 +140,7 @@ func GetRawHTTP(options *types.Options) *rawhttp.Client {
|
||||
} else if protocolstate.Dialer != nil {
|
||||
rawHttpOptions.FastDialer = protocolstate.Dialer
|
||||
}
|
||||
rawHttpOptions.Timeout = GetHttpTimeout(options)
|
||||
rawHttpOptions.Timeout = options.Options.GetTimeouts().HttpTimeout
|
||||
rawHttpClient = rawhttp.NewClient(rawHttpOptions)
|
||||
}
|
||||
return rawHttpClient
|
||||
@@ -239,7 +226,7 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
|
||||
}
|
||||
|
||||
// responseHeaderTimeout is max timeout for response headers to be read
|
||||
responseHeaderTimeout := MaxResponseHeaderTimeout
|
||||
responseHeaderTimeout := options.GetTimeouts().HttpResponseHeaderTimeout
|
||||
if configuration.ResponseHeaderTimeout != 0 {
|
||||
responseHeaderTimeout = configuration.ResponseHeaderTimeout
|
||||
}
|
||||
@@ -308,7 +295,7 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
|
||||
CheckRedirect: makeCheckRedirectFunc(redirectFlow, maxRedirects),
|
||||
}
|
||||
if !configuration.NoTimeout {
|
||||
httpclient.Timeout = GetHttpTimeout(options)
|
||||
httpclient.Timeout = options.GetTimeouts().HttpTimeout
|
||||
}
|
||||
client := retryablehttp.NewWithHTTPClient(httpclient, retryableHttpOptions)
|
||||
if jar != nil {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||
urlutil "github.com/projectdiscovery/utils/url"
|
||||
)
|
||||
|
||||
@@ -36,7 +37,7 @@ func SendRawRequest(client *rawhttp.Client, opts *RawHttpRequestOpts) (*http.Res
|
||||
resp, err := client.DoRawWithOptions(opts.Method, opts.URL, opts.Path, opts.Headers, opts.Body, opts.Options)
|
||||
if err != nil {
|
||||
cause := err.Error()
|
||||
if strings.Contains(cause, "ReadStatusLine: ") && strings.Contains(cause, "read: connection reset by peer") {
|
||||
if stringsutil.ContainsAll(cause, "ReadStatusLine: ", "read: connection reset by peer") {
|
||||
// this error is caused when rawhttp client sends a corrupted or malformed request packet to server
|
||||
// some servers may attempt gracefully shutdown but most will just abruptly close the connection which results
|
||||
// in a connection reset by peer error and this can be safely assumed as 400 Bad Request in terms of normal http flow
|
||||
|
||||
@@ -483,7 +483,7 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa
|
||||
request.options.RateLimitTake()
|
||||
|
||||
ctx := request.newContext(input)
|
||||
ctxWithTimeout, cancel := context.WithTimeoutCause(ctx, httpclientpool.GetHttpTimeout(request.options.Options), ErrHttpEngineRequestDeadline)
|
||||
ctxWithTimeout, cancel := context.WithTimeoutCause(ctx, request.options.Options.GetTimeouts().HttpTimeout, ErrHttpEngineRequestDeadline)
|
||||
defer cancel()
|
||||
|
||||
generatedHttpRequest, err := generator.Make(ctxWithTimeout, input, data, payloads, dynamicValue)
|
||||
@@ -844,6 +844,8 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ
|
||||
outputEvent["ip"] = input.MetaInput.CustomIP
|
||||
} else {
|
||||
outputEvent["ip"] = protocolstate.Dialer.GetDialedIP(hostname)
|
||||
// try getting cname
|
||||
request.addCNameIfAvailable(hostname, outputEvent)
|
||||
}
|
||||
|
||||
if len(generatedRequest.interactshURLs) > 0 {
|
||||
@@ -940,6 +942,8 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ
|
||||
outputEvent["ip"] = input.MetaInput.CustomIP
|
||||
} else {
|
||||
outputEvent["ip"] = protocolstate.Dialer.GetDialedIP(hostname)
|
||||
// try getting cname
|
||||
request.addCNameIfAvailable(hostname, outputEvent)
|
||||
}
|
||||
if request.options.Interactsh != nil {
|
||||
request.options.Interactsh.MakePlaceholders(generatedRequest.interactshURLs, outputEvent)
|
||||
@@ -1031,6 +1035,23 @@ func (request *Request) validateNFixEvent(input *contextargs.Context, gr *genera
|
||||
}
|
||||
}
|
||||
|
||||
// addCNameIfAvailable adds the cname to the event if available
|
||||
func (request *Request) addCNameIfAvailable(hostname string, outputEvent map[string]interface{}) {
|
||||
data, err := protocolstate.Dialer.GetDNSData(hostname)
|
||||
if err == nil {
|
||||
switch len(data.CNAME) {
|
||||
case 0:
|
||||
return
|
||||
case 1:
|
||||
outputEvent["cname"] = data.CNAME[0]
|
||||
default:
|
||||
// add 1st and put others in cname_all
|
||||
outputEvent["cname"] = data.CNAME[0]
|
||||
outputEvent["cname_all"] = data.CNAME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handleSignature of the http request
|
||||
func (request *Request) handleSignature(generatedRequest *generatedRequest) error {
|
||||
switch request.Signature.Value {
|
||||
|
||||
@@ -130,6 +130,10 @@ func (r *Request) parseAnnotations(rawRequest string, request *retryablehttp.Req
|
||||
if duration := reTimeoutAnnotation.FindStringSubmatch(rawRequest); len(duration) > 0 {
|
||||
value := strings.TrimSpace(duration[1])
|
||||
if parsed, err := time.ParseDuration(value); err == nil {
|
||||
// to avoid dos via timeout request annotation in http template we set it to maximum of 2 minutes
|
||||
if parsed > 2*time.Minute {
|
||||
parsed = 2 * time.Minute
|
||||
}
|
||||
//nolint:govet // cancelled automatically by withTimeout
|
||||
// global timeout is overridden by annotation by replacing context
|
||||
ctx, overrides.cancelFunc = context.WithTimeoutCause(context.TODO(), parsed, ErrTimeoutAnnotationDeadline)
|
||||
@@ -140,7 +144,7 @@ func (r *Request) parseAnnotations(rawRequest string, request *retryablehttp.Req
|
||||
} else {
|
||||
//nolint:govet // cancelled automatically by withTimeout
|
||||
// global timeout is overridden by annotation by replacing context
|
||||
ctx, overrides.cancelFunc = context.WithTimeoutCause(context.TODO(), httpclientpool.GetHttpTimeout(r.options.Options), ErrRequestTimeoutDeadline)
|
||||
ctx, overrides.cancelFunc = context.WithTimeoutCause(context.TODO(), r.options.Options.GetTimeouts().HttpTimeout, ErrRequestTimeoutDeadline)
|
||||
request = request.Clone(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,6 @@ type Request struct {
|
||||
// Code contains code to execute for the javascript request.
|
||||
Code string `yaml:"code,omitempty" json:"code,omitempty" jsonschema:"title=code to execute in javascript,description=Executes inline javascript code for the request"`
|
||||
// description: |
|
||||
// Timeout in seconds is optional timeout for each javascript script execution (i.e init, pre-condition, code)
|
||||
Timeout int `yaml:"timeout,omitempty" json:"timeout,omitempty" jsonschema:"title=timeout for javascript execution,description=Timeout in seconds is optional timeout for entire javascript script execution"`
|
||||
// description: |
|
||||
// StopAtFirstMatch stops processing the request at first match.
|
||||
StopAtFirstMatch bool `yaml:"stop-at-first-match,omitempty" json:"stop-at-first-match,omitempty" jsonschema:"title=stop at first match,description=Stop the execution after a match is found"`
|
||||
// description: |
|
||||
@@ -153,9 +150,9 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
|
||||
}
|
||||
|
||||
opts := &compiler.ExecuteOptions{
|
||||
Timeout: request.Timeout,
|
||||
Source: &request.Init,
|
||||
Context: context.Background(),
|
||||
TimeoutVariants: request.options.Options.GetTimeouts(),
|
||||
Source: &request.Init,
|
||||
Context: context.Background(),
|
||||
}
|
||||
// register 'export' function to export variables from init code
|
||||
// these are saved in args and are available in pre-condition and request code
|
||||
@@ -345,7 +342,10 @@ func (request *Request) ExecuteWithResults(target *contextargs.Context, dynamicV
|
||||
argsCopy.TemplateCtx = templateCtx.GetAll()
|
||||
|
||||
result, err := request.options.JsCompiler.ExecuteWithOptions(request.preConditionCompiled, argsCopy,
|
||||
&compiler.ExecuteOptions{Timeout: request.Timeout, Source: &request.PreCondition, Context: target.Context()})
|
||||
&compiler.ExecuteOptions{
|
||||
TimeoutVariants: requestOptions.Options.GetTimeouts(),
|
||||
Source: &request.PreCondition, Context: target.Context(),
|
||||
})
|
||||
if err != nil {
|
||||
return errorutil.NewWithTag(request.TemplateID, "could not execute pre-condition: %s", err)
|
||||
}
|
||||
@@ -500,7 +500,11 @@ func (request *Request) executeRequestWithPayloads(hostPort string, input *conte
|
||||
}
|
||||
|
||||
results, err := request.options.JsCompiler.ExecuteWithOptions(request.scriptCompiled, argsCopy,
|
||||
&compiler.ExecuteOptions{Timeout: request.Timeout, Source: &request.Code, Context: input.Context()})
|
||||
&compiler.ExecuteOptions{
|
||||
TimeoutVariants: requestOptions.Options.GetTimeouts(),
|
||||
Source: &request.Code,
|
||||
Context: input.Context(),
|
||||
})
|
||||
if err != nil {
|
||||
// shouldn't fail even if it returned error instead create a failure event
|
||||
results = compiler.ExecuteResult{"success": false, "error": err.Error()}
|
||||
|
||||
@@ -327,7 +327,7 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
|
||||
}
|
||||
|
||||
if input.Read > 0 {
|
||||
buffer, err := ConnReadNWithTimeout(conn, int64(input.Read), request.options.Options.ResponseReadTimeout)
|
||||
buffer, err := ConnReadNWithTimeout(conn, int64(input.Read), request.options.Options.GetTimeouts().TcpReadTimeout)
|
||||
if err != nil {
|
||||
return errorutil.NewWithErr(err).Msgf("could not read response from connection")
|
||||
}
|
||||
@@ -377,7 +377,7 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
|
||||
bufferSize = -1
|
||||
}
|
||||
|
||||
final, err := ConnReadNWithTimeout(conn, int64(bufferSize), request.options.Options.ResponseReadTimeout)
|
||||
final, err := ConnReadNWithTimeout(conn, int64(bufferSize), request.options.Options.GetTimeouts().TcpReadTimeout)
|
||||
if err != nil {
|
||||
request.options.Output.Request(request.options.TemplatePath, address, request.Type().String(), err)
|
||||
gologger.Verbose().Msgf("could not read more data from %s: %s", actualAddress, err)
|
||||
|
||||
@@ -77,6 +77,9 @@ func (s *ScanContext) LogEvent(e *output.InternalWrappedEvent) {
|
||||
s.events = append(s.events, e)
|
||||
}
|
||||
|
||||
e.RLock()
|
||||
defer e.RUnlock()
|
||||
|
||||
s.results = append(s.results, e.Results...)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ func setup() {
|
||||
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
|
||||
|
||||
executerOpts = protocols.ExecutorOptions{
|
||||
Output: testutils.NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
Parser: templates.NewParser(),
|
||||
Output: testutils.NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
Parser: templates.NewParser(),
|
||||
}
|
||||
workflowLoader, err := workflow.NewLoader(&executerOpts)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||
"github.com/segmentio/ksuid"
|
||||
)
|
||||
|
||||
@@ -48,7 +49,7 @@ func (r *randStrPreprocessor) ProcessNReturnData(data []byte) ([]byte, map[strin
|
||||
continue
|
||||
}
|
||||
value := expression[1]
|
||||
if strings.Contains(value, "(") || strings.Contains(value, ")") {
|
||||
if stringsutil.ContainsAny(value, "(", ")") {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -1929,7 +1929,7 @@ func init() {
|
||||
Value: "Matched is the input which was matched upon",
|
||||
},
|
||||
}
|
||||
JAVASCRIPTRequestDoc.Fields = make([]encoder.Doc, 10)
|
||||
JAVASCRIPTRequestDoc.Fields = make([]encoder.Doc, 9)
|
||||
JAVASCRIPTRequestDoc.Fields[0].Name = "id"
|
||||
JAVASCRIPTRequestDoc.Fields[0].Type = "string"
|
||||
JAVASCRIPTRequestDoc.Fields[0].Note = ""
|
||||
@@ -1955,33 +1955,28 @@ func init() {
|
||||
JAVASCRIPTRequestDoc.Fields[4].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[4].Description = "Code contains code to execute for the javascript request."
|
||||
JAVASCRIPTRequestDoc.Fields[4].Comments[encoder.LineComment] = "Code contains code to execute for the javascript request."
|
||||
JAVASCRIPTRequestDoc.Fields[5].Name = "timeout"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Type = "int"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Name = "stop-at-first-match"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Type = "bool"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[5].Description = "Timeout in seconds is optional timeout for each javascript script execution (i.e init, pre-condition, code)"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Comments[encoder.LineComment] = "Timeout in seconds is optional timeout for each javascript script execution (i.e init, pre-condition, code)"
|
||||
JAVASCRIPTRequestDoc.Fields[6].Name = "stop-at-first-match"
|
||||
JAVASCRIPTRequestDoc.Fields[6].Type = "bool"
|
||||
JAVASCRIPTRequestDoc.Fields[5].Description = "StopAtFirstMatch stops processing the request at first match."
|
||||
JAVASCRIPTRequestDoc.Fields[5].Comments[encoder.LineComment] = "StopAtFirstMatch stops processing the request at first match."
|
||||
JAVASCRIPTRequestDoc.Fields[6].Name = "attack"
|
||||
JAVASCRIPTRequestDoc.Fields[6].Type = "generators.AttackTypeHolder"
|
||||
JAVASCRIPTRequestDoc.Fields[6].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[6].Description = "StopAtFirstMatch stops processing the request at first match."
|
||||
JAVASCRIPTRequestDoc.Fields[6].Comments[encoder.LineComment] = "StopAtFirstMatch stops processing the request at first match."
|
||||
JAVASCRIPTRequestDoc.Fields[7].Name = "attack"
|
||||
JAVASCRIPTRequestDoc.Fields[7].Type = "generators.AttackTypeHolder"
|
||||
JAVASCRIPTRequestDoc.Fields[6].Description = "Attack is the type of payload combinations to perform.\n\nSniper is each payload once, pitchfork combines multiple payload sets and clusterbomb generates\npermutations and combinations for all payloads."
|
||||
JAVASCRIPTRequestDoc.Fields[6].Comments[encoder.LineComment] = "Attack is the type of payload combinations to perform."
|
||||
JAVASCRIPTRequestDoc.Fields[7].Name = "threads"
|
||||
JAVASCRIPTRequestDoc.Fields[7].Type = "int"
|
||||
JAVASCRIPTRequestDoc.Fields[7].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[7].Description = "Attack is the type of payload combinations to perform.\n\nSniper is each payload once, pitchfork combines multiple payload sets and clusterbomb generates\npermutations and combinations for all payloads."
|
||||
JAVASCRIPTRequestDoc.Fields[7].Comments[encoder.LineComment] = "Attack is the type of payload combinations to perform."
|
||||
JAVASCRIPTRequestDoc.Fields[8].Name = "threads"
|
||||
JAVASCRIPTRequestDoc.Fields[8].Type = "int"
|
||||
JAVASCRIPTRequestDoc.Fields[8].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[8].Description = "Payload concurreny i.e threads for sending requests."
|
||||
JAVASCRIPTRequestDoc.Fields[8].Comments[encoder.LineComment] = "Payload concurreny i.e threads for sending requests."
|
||||
JAVASCRIPTRequestDoc.Fields[7].Description = "Payload concurreny i.e threads for sending requests."
|
||||
JAVASCRIPTRequestDoc.Fields[7].Comments[encoder.LineComment] = "Payload concurreny i.e threads for sending requests."
|
||||
|
||||
JAVASCRIPTRequestDoc.Fields[8].AddExample("Send requests using 10 concurrent threads", 10)
|
||||
JAVASCRIPTRequestDoc.Fields[9].Name = "payloads"
|
||||
JAVASCRIPTRequestDoc.Fields[9].Type = "map[string]interface{}"
|
||||
JAVASCRIPTRequestDoc.Fields[9].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[9].Description = "Payloads contains any payloads for the current request.\n\nPayloads support both key-values combinations where a list\nof payloads is provided, or optionally a single file can also\nbe provided as payload which will be read on run-time."
|
||||
JAVASCRIPTRequestDoc.Fields[9].Comments[encoder.LineComment] = "Payloads contains any payloads for the current request."
|
||||
JAVASCRIPTRequestDoc.Fields[7].AddExample("Send requests using 10 concurrent threads", 10)
|
||||
JAVASCRIPTRequestDoc.Fields[8].Name = "payloads"
|
||||
JAVASCRIPTRequestDoc.Fields[8].Type = "map[string]interface{}"
|
||||
JAVASCRIPTRequestDoc.Fields[8].Note = ""
|
||||
JAVASCRIPTRequestDoc.Fields[8].Description = "Payloads contains any payloads for the current request.\n\nPayloads support both key-values combinations where a list\nof payloads is provided, or optionally a single file can also\nbe provided as payload which will be read on run-time."
|
||||
JAVASCRIPTRequestDoc.Fields[8].Comments[encoder.LineComment] = "Payloads contains any payloads for the current request."
|
||||
|
||||
HTTPSignatureTypeHolderDoc.Type = "http.SignatureTypeHolder"
|
||||
HTTPSignatureTypeHolderDoc.Comments[encoder.LineComment] = " SignatureTypeHolder is used to hold internal type of the signature"
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/gobwas/ws"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/projectdiscovery/utils/conversion"
|
||||
)
|
||||
|
||||
// ExtraArgs
|
||||
@@ -70,20 +71,26 @@ func RunNucleiBareArgsAndGetResults(debug bool, env []string, extra ...string) (
|
||||
} else {
|
||||
cmd.Args = append(cmd.Args, "-silent")
|
||||
}
|
||||
data, err := cmd.Output()
|
||||
if debug {
|
||||
fmt.Println(string(data))
|
||||
output, err := cmd.Output()
|
||||
var data string
|
||||
if len(output) > 0 {
|
||||
data = strings.TrimSpace(conversion.String(output))
|
||||
}
|
||||
if len(data) < 1 && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), string(data))
|
||||
if debug {
|
||||
fmt.Println(data)
|
||||
}
|
||||
var parts []string
|
||||
items := strings.Split(string(data), "\n")
|
||||
items := strings.Split(data, "\n")
|
||||
for _, i := range items {
|
||||
if i != "" {
|
||||
parts = append(parts, i)
|
||||
}
|
||||
}
|
||||
|
||||
if (data == "" || len(parts) == 0) && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), data)
|
||||
}
|
||||
|
||||
return parts, nil
|
||||
}
|
||||
|
||||
@@ -98,20 +105,25 @@ func RunNucleiWithArgsAndGetResults(debug bool, args ...string) ([]string, error
|
||||
} else {
|
||||
cmd.Args = append(cmd.Args, "-silent")
|
||||
}
|
||||
data, err := cmd.Output()
|
||||
if debug {
|
||||
fmt.Println(string(data))
|
||||
output, err := cmd.Output()
|
||||
var data string
|
||||
if len(output) > 0 {
|
||||
data = strings.TrimSpace(conversion.String(output))
|
||||
}
|
||||
if len(data) < 1 && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), string(data))
|
||||
if debug {
|
||||
fmt.Println(data)
|
||||
}
|
||||
var parts []string
|
||||
items := strings.Split(string(data), "\n")
|
||||
items := strings.Split(data, "\n")
|
||||
for _, i := range items {
|
||||
if i != "" {
|
||||
parts = append(parts, i)
|
||||
}
|
||||
}
|
||||
|
||||
if (data == "" || len(parts) == 0) && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), data)
|
||||
}
|
||||
return parts, nil
|
||||
}
|
||||
|
||||
@@ -127,12 +139,16 @@ func RunNucleiArgsAndGetErrors(debug bool, env []string, extra ...string) ([]str
|
||||
cmd.Args = append(cmd.Args, "-allow-local-file-access")
|
||||
cmd.Args = append(cmd.Args, "-nc") // disable color
|
||||
cmd.Env = append(cmd.Env, ExtraEnvVars...)
|
||||
data, err := cmd.CombinedOutput()
|
||||
dataOutput, err := cmd.CombinedOutput()
|
||||
if debug {
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(string(dataOutput))
|
||||
}
|
||||
var data string
|
||||
if len(dataOutput) > 0 {
|
||||
data = strings.TrimSpace(conversion.String(dataOutput))
|
||||
}
|
||||
results := []string{}
|
||||
for _, v := range strings.Split(string(data), "\n") {
|
||||
for _, v := range strings.Split(data, "\n") {
|
||||
line := strings.TrimSpace(v)
|
||||
switch {
|
||||
case strings.HasPrefix(line, "[ERR]"):
|
||||
@@ -164,20 +180,24 @@ func RunNucleiArgsWithEnvAndGetResults(debug bool, env []string, extra ...string
|
||||
} else {
|
||||
cmd.Args = append(cmd.Args, "-silent")
|
||||
}
|
||||
data, err := cmd.Output()
|
||||
if debug {
|
||||
fmt.Println(string(data))
|
||||
dataOutput, err := cmd.Output()
|
||||
var data string
|
||||
if len(dataOutput) > 0 {
|
||||
data = strings.TrimSpace(conversion.String(dataOutput))
|
||||
}
|
||||
if len(data) < 1 && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), string(data))
|
||||
if debug {
|
||||
fmt.Println(data)
|
||||
}
|
||||
var parts []string
|
||||
items := strings.Split(string(data), "\n")
|
||||
items := strings.Split(data, "\n")
|
||||
for _, i := range items {
|
||||
if i != "" {
|
||||
parts = append(parts, i)
|
||||
}
|
||||
}
|
||||
if (data == "" || len(parts) == 0) && err != nil {
|
||||
return nil, fmt.Errorf("%v: %v", err.Error(), data)
|
||||
}
|
||||
return parts, nil
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -76,7 +76,6 @@ var DefaultOptions = &types.Options{
|
||||
InteractionsPollDuration: 5,
|
||||
GitHubTemplateRepo: []string{},
|
||||
GitHubToken: "",
|
||||
ResponseReadTimeout: time.Second * 5,
|
||||
}
|
||||
|
||||
// TemplateInfo contains info for a mock executed template.
|
||||
@@ -90,17 +89,17 @@ type TemplateInfo struct {
|
||||
func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protocols.ExecutorOptions {
|
||||
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
|
||||
executerOpts := &protocols.ExecutorOptions{
|
||||
TemplateID: info.ID,
|
||||
TemplateInfo: info.Info,
|
||||
TemplatePath: info.Path,
|
||||
Output: NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
TemplateID: info.ID,
|
||||
TemplateInfo: info.Info,
|
||||
TemplatePath: info.Path,
|
||||
Output: NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
}
|
||||
executerOpts.CreateTemplateCtxStore()
|
||||
return executerOpts
|
||||
|
||||
@@ -27,15 +27,15 @@ func setup() {
|
||||
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
|
||||
|
||||
executerOpts = protocols.ExecutorOptions{
|
||||
Output: testutils.NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
Parser: templates.NewParser(),
|
||||
Output: testutils.NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
Parser: templates.NewParser(),
|
||||
}
|
||||
workflowLoader, err := workflow.NewLoader(&executerOpts)
|
||||
if err != nil {
|
||||
|
||||
+73
-5
@@ -278,8 +278,6 @@ type Options struct {
|
||||
SNI string
|
||||
// InputFileMode specifies the mode of input file (jsonl, burp, openapi, swagger, etc)
|
||||
InputFileMode string
|
||||
// DialerTimeout sets the timeout for network requests.
|
||||
DialerTimeout time.Duration
|
||||
// DialerKeepAlive sets the keep alive duration for network requests.
|
||||
DialerKeepAlive time.Duration
|
||||
// Interface to use for network scan
|
||||
@@ -292,8 +290,6 @@ type Options struct {
|
||||
ResponseReadSize int
|
||||
// ResponseSaveSize is the maximum size of response to save
|
||||
ResponseSaveSize int
|
||||
// ResponseReadTimeout is response read timeout in seconds
|
||||
ResponseReadTimeout time.Duration
|
||||
// Health Check
|
||||
HealthCheck bool
|
||||
// Time to wait between each input read operation before closing the stream
|
||||
@@ -406,6 +402,79 @@ type Options struct {
|
||||
HttpApiEndpoint string
|
||||
// ListTemplateProfiles lists all available template profiles
|
||||
ListTemplateProfiles bool
|
||||
// timeouts contains various types of timeouts used in nuclei
|
||||
// these timeouts are derived from dial-timeout (-timeout) with known multipliers
|
||||
// This is internally managed and does not need to be set by user by explicitly setting
|
||||
// this overrides the default/derived one
|
||||
timeouts *Timeouts
|
||||
}
|
||||
|
||||
// SetTimeouts sets the timeout variants to use for the executor
|
||||
func (opts *Options) SetTimeouts(t *Timeouts) {
|
||||
opts.timeouts = t
|
||||
}
|
||||
|
||||
// GetTimeouts returns the timeout variants to use for the executor
|
||||
func (eo *Options) GetTimeouts() *Timeouts {
|
||||
if eo.timeouts != nil {
|
||||
// redundant but apply to avoid any potential issues
|
||||
eo.timeouts.ApplyDefaults()
|
||||
return eo.timeouts
|
||||
}
|
||||
// set timeout variant value
|
||||
eo.timeouts = NewTimeoutVariant(eo.Timeout)
|
||||
eo.timeouts.ApplyDefaults()
|
||||
return eo.timeouts
|
||||
}
|
||||
|
||||
// Timeouts is a struct that contains all the timeout variants for nuclei
|
||||
// dialer timeout is used to derive other timeouts
|
||||
type Timeouts struct {
|
||||
// DialTimeout for fastdialer (default 10s)
|
||||
DialTimeout time.Duration
|
||||
// Tcp(Network Protocol) Read From Connection Timeout (default 5s)
|
||||
TcpReadTimeout time.Duration
|
||||
// Http Response Header Timeout (default 10s)
|
||||
// this timeout prevents infinite hangs started by server if any
|
||||
// this is temporarily overridden when using @timeout request annotation
|
||||
HttpResponseHeaderTimeout time.Duration
|
||||
// HttpTimeout for http client (default -> 3 x dial-timeout = 30s)
|
||||
HttpTimeout time.Duration
|
||||
// JsCompilerExec timeout/deadline (default -> 2 x dial-timeout = 20s)
|
||||
JsCompilerExecutionTimeout time.Duration
|
||||
// CodeExecutionTimeout for code execution (default -> 3 x dial-timeout = 30s)
|
||||
CodeExecutionTimeout time.Duration
|
||||
}
|
||||
|
||||
// NewTimeoutVariant creates a new timeout variant with the given dial timeout in seconds
|
||||
func NewTimeoutVariant(dialTimeoutSec int) *Timeouts {
|
||||
tv := &Timeouts{
|
||||
DialTimeout: time.Duration(dialTimeoutSec) * time.Second,
|
||||
}
|
||||
tv.ApplyDefaults()
|
||||
return tv
|
||||
}
|
||||
|
||||
// ApplyDefaults applies default values to timeout variants when missing
|
||||
func (tv *Timeouts) ApplyDefaults() {
|
||||
if tv.DialTimeout == 0 {
|
||||
tv.DialTimeout = 10 * time.Second
|
||||
}
|
||||
if tv.TcpReadTimeout == 0 {
|
||||
tv.TcpReadTimeout = 5 * time.Second
|
||||
}
|
||||
if tv.HttpResponseHeaderTimeout == 0 {
|
||||
tv.HttpResponseHeaderTimeout = 10 * time.Second
|
||||
}
|
||||
if tv.HttpTimeout == 0 {
|
||||
tv.HttpTimeout = 3 * tv.DialTimeout
|
||||
}
|
||||
if tv.JsCompilerExecutionTimeout == 0 {
|
||||
tv.JsCompilerExecutionTimeout = 2 * tv.DialTimeout
|
||||
}
|
||||
if tv.CodeExecutionTimeout == 0 {
|
||||
tv.CodeExecutionTimeout = 3 * tv.DialTimeout
|
||||
}
|
||||
}
|
||||
|
||||
// ShouldLoadResume resume file
|
||||
@@ -444,7 +513,6 @@ func DefaultOptions() *Options {
|
||||
MaxHostError: 30,
|
||||
ResponseReadSize: 10 * unitutils.Mega,
|
||||
ResponseSaveSize: unitutils.Mega,
|
||||
ResponseReadTimeout: 5 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user