file

package
v3.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 34 Imported by: 3

Documentation

Overview

Package file implements the nuclei file protocol for local and remote SMB paths.

Local paths use os.Open / directory walks as before. Remote targets use the shared smbsession stack (issue #6142 / #4707):

nuclei -t file-template.yaml -target '\\fs01\share\secret.txt'
nuclei -t file-template.yaml -target 'smb://user:pass@fs01/share/'

Template auth (when not embedded in the URL):

file:
  - extensions: [all]
    smb-user: auditor
    smb-password: secret
    # smb-domain: CORP
    # smb-hash: <nthash>
    # smb-port: 445

Index

Constants

This section is empty.

Variables

View Source
var RequestPartDefinitions = map[string]string{
	"template-id":       "ID of the template executed",
	"template-info":     "Info Block of the template executed",
	"template-path":     "Path of the template executed",
	"matched":           "Matched is the input which was matched upon",
	"path":              "Path is the path of file on local filesystem",
	"type":              "Type is the type of request made",
	"raw,body,all,data": "Raw contains the raw file contents",
}

RequestPartDefinitions contains a mapping of request part definitions and their description. Multiple definitions are separated by commas. Definitions not having a name (generated on runtime) are prefixed & suffixed by <>.

Functions

func IsSMBPath added in v3.11.1

func IsSMBPath(input string) bool

IsSMBPath reports whether input looks like a remote SMB target rather than a local path.

Types

type FileMatch

type FileMatch struct {
	Data      string
	Line      int
	ByteIndex int
	Match     bool
	Extract   bool
	Expr      string
	Raw       string
}

type Request

type Request struct {
	// Operators for the current request go here.
	operators.Operators `yaml:",inline"`
	// description: |
	//   Extensions is the list of extensions or mime types to perform matching on.
	// examples:
	//   - value: '[]string{".txt", ".go", ".json"}'
	Extensions []string `` /* 148-byte string literal not displayed */
	// description: |
	//   DenyList is the list of file, directories, mime types or extensions to deny during matching.
	//
	//   By default, it contains some non-interesting extensions that are hardcoded
	//   in nuclei.
	// examples:
	//   - value: '[]string{".avi", ".mov", ".mp3"}'
	DenyList []string `` /* 199-byte string literal not displayed */

	// ID is the optional id of the request
	ID string `` /* 126-byte string literal not displayed */

	// description: |
	//   MaxSize is the maximum size of the file to run request on.
	//
	//   By default, nuclei will process 1 GB of content and not go more than that.
	//   It can be set to much lower or higher depending on use.
	//   If set to "no" then all content will be processed
	// examples:
	//   - value: "\"5Mb\""
	MaxSize string `` /* 157-byte string literal not displayed */

	// description: |
	//   elaborates archives
	Archive bool `` /* 142-byte string literal not displayed */

	// description: |
	//   enables mime types check
	MimeType bool `` /* 140-byte string literal not displayed */

	CompiledOperators *operators.Operators `yaml:"-" json:"-"`

	// description: |
	//   NoRecursive specifies whether to not do recursive checks if folders are provided.
	NoRecursive bool `` /* 184-byte string literal not displayed */

	// description: |
	//   SMBUser authenticates to remote SMB shares when the file input is a UNC
	//   or smb:// path (issue #6142). Guest/anon: empty password.
	// examples:
	//   - value: "\"auditor\""
	SMBUser string `yaml:"smb-user,omitempty" json:"smb-user,omitempty" jsonschema:"title=SMB username,description=Username for SMB file targets"`
	// description: |
	//   SMBPassword is the password for SMB file targets.
	SMBPassword string `` /* 133-byte string literal not displayed */
	// description: |
	//   SMBDomain is the optional NTLM domain / workgroup.
	SMBDomain string `` /* 127-byte string literal not displayed */
	// description: |
	//   SMBHash enables pass-the-hash (overrides smb-password when set).
	SMBHash string `yaml:"smb-hash,omitempty" json:"smb-hash,omitempty" jsonschema:"title=SMB NT hash,description=NT hash for SMB pass-the-hash"`
	// description: |
	//   SMBPort overrides the default SMB port (445) for UNC targets.
	SMBPort int `yaml:"smb-port,omitempty" json:"smb-port,omitempty" jsonschema:"title=SMB port,description=TCP port for SMB (default 445)"`
	// contains filtered or unexported fields
}

Request contains a File matching mechanism for local disk operations.

func (*Request) Compile

func (request *Request) Compile(options *protocols.ExecutorOptions) error

Compile compiles the protocol request for further execution.

func (*Request) ExecuteWithResults

func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata, previous output.InternalEvent, callback protocols.OutputEventCallback) error

ExecuteWithResults executes the protocol requests and returns results instead of writing them.

func (*Request) Extract

func (request *Request) Extract(data map[string]interface{}, extractor *extractors.Extractor) map[string]struct{}

Extract performs extracting operation for an extractor on model and returns true or false.

func (*Request) GetCompiledOperators

func (request *Request) GetCompiledOperators() []*operators.Operators

func (*Request) GetID

func (request *Request) GetID() string

GetID returns the unique ID of the request if any.

func (*Request) MakeResultEvent

func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent

MakeResultEvent creates a result event from internal wrapped event Deprecated: unused in stream mode, must be present for interface compatibility

func (*Request) MakeResultEventItem

func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent

MakeResultEventItem Deprecated: unused in stream mode, must be present for interface compatibility

func (*Request) Match

func (request *Request) Match(data map[string]interface{}, matcher *matchers.Matcher) (bool, []string)

Match matches a generic data response again a given matcher

func (*Request) Requests

func (request *Request) Requests() int

Requests returns the total number of requests the YAML rule will perform

func (*Request) Type

func (request *Request) Type() templateTypes.ProtocolType

Type returns the type of the protocol request

func (*Request) UpdateOptions added in v3.4.8

func (r *Request) UpdateOptions(opts *protocols.ExecutorOptions)

UpdateOptions replaces this request's options with a new copy

type SMBTarget added in v3.11.1

type SMBTarget struct {
	Host     string
	Port     int
	Share    string
	Path     string // share-relative; "." for share root / directory listing
	User     string
	Password string
	Domain   string
}

SMBTarget is a parsed UNC or smb:// path suitable for the file protocol bridge.

Accepted forms (issue #6142):

\\host\share\path\to\file
//host/share/path/to/file
smb://host/share/path/to/file
smb://user:pass@host/share/path
smb://domain;user:pass@host/share/path

func ParseSMBTarget added in v3.11.1

func ParseSMBTarget(input string) (*SMBTarget, error)

ParseSMBTarget parses an SMB UNC or smb:// URL into an SMBTarget.

func (*SMBTarget) Display added in v3.11.1

func (t *SMBTarget) Display() string

Display returns a stable UNC-like string for events/logs (never embeds password).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL