Documentation
¶
Overview ¶
Package memcached implements fingerprinting for Memcached distributed memory cache servers.
Memcached Wire Protocol Detection ¶
This plugin implements Memcached fingerprinting using the text (ASCII) protocol to ensure compatibility across all Memcached versions from 1.4.x to 1.6.x+.
Detection Strategy:
PHASE 1 - DETECTION (determines if the service is Memcached):
PRIMARY PATH: version command
- Send: version\r\n
- Expected: VERSION <version>\r\n
- Works on ALL Memcached versions (1.0+ to 1.6.x+)
- Directly provides version string (100% confidence)
SECONDARY PATH (FALLBACK): stats command
- Send: stats\r\n
- Expected: STAT <key> <value>\r\n ... END\r\n
- Contains "STAT version <version>" line
- Works on ALL Memcached versions
PHASE 2 - ENRICHMENT (extracts version information):
After Memcached is detected, version is already extracted from the detection response.
No additional enrichment needed (unlike Redis INFO or MongoDB buildInfo).
Memcached Text Protocol:
version Command:
Request: version\r\n Response: VERSION <version>\r\n Example: Request: version\r\n Response: VERSION 1.6.22\r\n
stats Command (Fallback):
Request: stats\r\n
Response: STAT <name> <value>\r\n
STAT <name> <value>\r\n
...
END\r\n
Example:
Request: stats\r\n
Response: STAT pid 1162\r\n
STAT uptime 5022\r\n
STAT version 1.6.22\r\n
...
END\r\n
Error Responses:
- ERROR\r\n - Unknown command (indicates NOT Memcached)
- CLIENT_ERROR <error>\r\n - Invalid command format
- SERVER_ERROR <error>\r\n - Server error
Version Compatibility Matrix:
- Memcached 1.4.x: Text + Binary protocols, UDP enabled
- Memcached 1.5.x: Text + Binary protocols, UDP disabled by default, TLS added
- Memcached 1.6.x: Text + Meta protocols, Binary deprecated, extstore support
Note: The text protocol (including version and stats commands) is supported across all versions and will be maintained indefinitely per Memcached project.
Index ¶
- Constants
- func DetectMemcached(conn net.Conn, timeout time.Duration) (string, bool, error)
- type MEMCACHEDPlugin
- func (p *MEMCACHEDPlugin) Name() string
- func (p *MEMCACHEDPlugin) PortPriority(port uint16) bool
- func (p *MEMCACHEDPlugin) Priority() int
- func (p *MEMCACHEDPlugin) Run(conn net.Conn, timeout time.Duration, target plugins.Target) (*plugins.Service, error)
- func (p *MEMCACHEDPlugin) Type() plugins.Protocol
Constants ¶
const DEFAULT_PORT = 11211
Memcached default port
const MEMCACHED = "memcached"
Variables ¶
This section is empty.
Functions ¶
func DetectMemcached ¶
DetectMemcached performs Memcached fingerprinting using the text protocol.
Detection Strategy:
- DETECTION PHASE: Use version command to detect Memcached and extract version - PRIMARY PATH: Send "version\r\n" command Works on ALL Memcached versions (1.0+ to 1.6.x+) Directly provides version string (100% confidence)
- FALLBACK: If version command fails, try stats command - Send "stats\r\n" command - Extract version from "STAT version <version>" line
Parameters:
- conn: Network connection to the Memcached server
- timeout: Timeout duration for network operations
Returns:
- string: Version string if detected, empty string otherwise
- bool: true if this appears to be Memcached
- error: Error details if detection failed
Types ¶
type MEMCACHEDPlugin ¶
type MEMCACHEDPlugin struct{}
func (*MEMCACHEDPlugin) Name ¶
func (p *MEMCACHEDPlugin) Name() string
func (*MEMCACHEDPlugin) PortPriority ¶
func (p *MEMCACHEDPlugin) PortPriority(port uint16) bool
func (*MEMCACHEDPlugin) Priority ¶
func (p *MEMCACHEDPlugin) Priority() int
func (*MEMCACHEDPlugin) Type ¶
func (p *MEMCACHEDPlugin) Type() plugins.Protocol