mongodb

package
v1.4.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_REPLY = 1
	OP_QUERY = 2004
	OP_MSG   = 2013
)

MongoDB wire protocol opcodes

View Source
const MONGODB = "mongodb"

Variables

This section is empty.

Functions

func DetectMongoDB

func DetectMongoDB(conn net.Conn, timeout time.Duration) (mongoDBMetadata, bool, error)

DetectMongoDB performs MongoDB fingerprinting using a layered fallback approach. It attempts detection using both OP_QUERY (universal) and OP_MSG (MongoDB 3.6+) protocols to ensure compatibility across all MongoDB versions from ancient to unreleased.

Detection Strategy:

  1. DETECTION PHASE: Use hello/isMaster commands to detect MongoDB and extract metadata - PRIMARY PATH (OP_QUERY): Try OP_QUERY + "hello", then OP_QUERY + "isMaster" Works on ALL MongoDB versions, including 5.1+ (handshake exception) Extracts: version, maxWireVersion, minWireVersion, serverType - SECONDARY PATH (OP_MSG): Try OP_MSG + "hello", then OP_MSG + "isMaster" Works on MongoDB 3.6+ only Extracts: version, maxWireVersion, minWireVersion, serverType
  2. ENRICHMENT PHASE: If version not found in hello/isMaster, try buildInfo - Attempts buildInfo with both OP_QUERY and OP_MSG protocols - If buildInfo fails (e.g., requires auth), still returns MongoDB detection

Parameters:

  • conn: Network connection to the MongoDB server
  • timeout: Timeout duration for network operations

Returns:

  • mongoDBMetadata: Enriched metadata (version, wire versions, server type)
  • bool: true if this appears to be MongoDB
  • error: Error details if detection failed

Types

type MONGODBPlugin

type MONGODBPlugin struct{}

func (*MONGODBPlugin) Name

func (p *MONGODBPlugin) Name() string

func (*MONGODBPlugin) PortPriority

func (p *MONGODBPlugin) PortPriority(port uint16) bool

func (*MONGODBPlugin) Priority

func (p *MONGODBPlugin) Priority() int

func (*MONGODBPlugin) Run

func (p *MONGODBPlugin) Run(conn net.Conn, timeout time.Duration, target plugins.Target) (*plugins.Service, error)

func (*MONGODBPlugin) Type

func (p *MONGODBPlugin) Type() plugins.Protocol

Jump to

Keyboard shortcuts

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