Documentation
¶
Overview ¶
Package http exposes an httpx-shaped HTTP client for nuclei JavaScript templates (require('nuclei/http')).
Dial, TLS, and host-policy reuse the scan's fastdialer via protocolstate. The YAML httpclientpool is not used here to avoid an import cycle with the JS compiler; connection reuse still goes through fastdialer.
Index ¶
- func NegotiateNTLM() string
- func NewClient(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object
- type Client
- func (c *Client) Get(ctx context.Context, rawURL string) (*Response, error)
- func (c *Client) Head(ctx context.Context, rawURL string) (*Response, error)
- func (c *Client) Post(ctx context.Context, rawURL, body string) (*Response, error)
- func (c *Client) Request(ctx context.Context, method, rawURL, body string) (*Response, error)
- func (c *Client) SetHeader(key, value string)
- type NTLMInfo
- type Options
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NegotiateNTLM ¶
func NegotiateNTLM() string
NegotiateNTLM returns a base64 Type-1 NTLM negotiate message suitable for an Authorization header (without the "NTLM " prefix). @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); client.SetHeader('Authorization', 'NTLM ' + http.NegotiateNTLM()); const resp = client.Get('https://exchange.acme.local/ews/'); ```
Types ¶
type Client ¶
type Client struct {
TimeoutSeconds int
FollowRedirects bool
MaxRedirects int
MaxBodyBytes int
DisableCookie bool
// contains filtered or unexported fields
}
Client is an HTTP client for nuclei JS templates. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Get('https://example.com'); log(resp.StatusCode + ' ' + resp.Body); ```
func (*Client) Get ¶
Get performs an HTTP GET. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Get('https://example.com'); ```
func (*Client) Head ¶
Head performs an HTTP HEAD. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Head('https://example.com'); ```
func (*Client) Post ¶
Post performs an HTTP POST with the given body string. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Post('https://example.com/login', 'user=a&pass=b'); ```
func (*Client) Request ¶
Request performs an HTTP request with the given method and optional body. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Request('PUT', 'https://example.com/item', '{"a":1}'); ```
type NTLMInfo ¶
type NTLMInfo struct {
MessageType int
TargetName string
NetBIOSDomainName string
NetBIOSComputerName string
DNSDomainName string
DNSComputerName string
DNSTreeName string
ProductVersion string
Timestamp uint64
UnixTimestamp int64
}
NTLMInfo holds fields decoded from an NTLM Type-2 challenge (Burp ntlm-challenge-decoder / nmap-style AV pairs). @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://exchange.acme.local/ews/'); const info = http.DecodeNTLM(resp.GetHeader('WWW-Authenticate')); log(info.DNSComputerName + ' ' + info.DNSDomainName); ```
func DecodeNTLM ¶
DecodeNTLM decodes an NTLM SSP blob from a WWW-Authenticate / Authorization header value or raw base64. Accepts prefixes "NTLM " and "Negotiate ". Only Type-2 (challenge) messages populate TargetInfo fields. @example ```javascript const http = require('nuclei/http'); const info = http.DecodeNTLM('NTLM TlRMTVNTUAACAAAA...'); ```
type Options ¶
type Options struct {
// TimeoutSeconds is the overall request timeout. 0 uses 30s.
TimeoutSeconds int
// MaxRedirects caps redirects when following (default 10).
MaxRedirects int
// MaxBodyBytes caps response body reads (default 5MiB). 0 uses default.
MaxBodyBytes int
// DisableRedirects turns off redirect following (on by default).
DisableRedirects bool
// DisableCookie disables the per-client cookie jar.
DisableCookie bool
}
Options configures a Client. All fields are optional. @example ```javascript const http = require('nuclei/http'); const opts = new http.Options(); opts.TimeoutSeconds = 15; opts.MaxRedirects = 5; const client = new http.Client(opts); ```
type Response ¶
type Response struct {
StatusCode int
URL string
Body string
Headers map[string]string
// contains filtered or unexported fields
}
Response is an HTTP response returned by Client methods. @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); log(resp.StatusCode); log(resp.GetHeader('Content-Type')); ```
func Get ¶
Get is a package-level GET using a default client (redirects + cookies on). @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); ```
func Head ¶
Head is a package-level HEAD using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Head('https://example.com'); ```
func Post ¶
Post is a package-level POST using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Post('https://example.com/login', 'user=a&pass=b'); ```
func Request ¶
Request is a package-level request using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Request('OPTIONS', 'https://example.com', ”); ```
func (*Response) GetHeader ¶
GetHeader returns the first value for a header (case-insensitive), or "". @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); const ct = resp.GetHeader('content-type'); ```