wsc

package
v0.749.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package wsc decodes Wi-Fi Simple Config (WSC / WPS) credential blobs — the TLV structure carried as the `application/vnd.wfa.wsc` MIME type.

This is the payload behind a "tap-to-connect" Wi-Fi NFC tag (an NDEF MIME record) and the Credential carried in WPS Registrar protocol messages (M7/M8). Decoding it recovers the provisioned network's SSID, authentication / encryption types, and — the operative field for a pentest — the network key (the PSK). PromptZero's ndef package surfaces such a record's MIME type but did not parse the payload; this fills that gap and is also exposed standalone (a WPS exchange carries the same blob outside NDEF).

Wrap-vs-native: native. The WSC attribute format is a flat sequence of big-endian (type:2, length:2, value) TLVs; the Credential attribute (0x100E) nests the same TLV grammar. No third-party dependency is warranted for fixed binary parsing. The attribute IDs and the authentication / encryption flag values are taken verbatim from the Wi-Fi Simple Config spec as published in hostap's src/wps/wps_defs.h (ATTR_* / WPS_AUTH_* / WPS_ENCR_*) — verified against that source, not recalled.

Covered: the Credential attribute and its standard sub-attributes (SSID, Authentication Type, Encryption Type, Network Key, MAC Address, Network Index), plus any top-level non-Credential attributes surfaced raw. Deferred: WSC Version 2 vendor-extension subelements (0x1049 WFA vendor extension) are surfaced raw (type + length), not interpreted — their internal subelement framing is vendor-specific; and the M7/M8 encrypted-settings attribute (0x1018) is AES-encrypted under a session key we do not have, so it is reported as present-but-encrypted rather than guessed at. No confidently-wrong output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	SSID          string   `json:"ssid,omitempty"`
	SSIDHex       string   `json:"ssid_hex,omitempty"`
	AuthTypeRaw   uint16   `json:"auth_type_raw"`
	AuthType      []string `json:"auth_type,omitempty"`
	EncrTypeRaw   uint16   `json:"encr_type_raw"`
	EncrType      []string `json:"encr_type,omitempty"`
	NetworkKey    string   `json:"network_key,omitempty"`
	NetworkKeyHex string   `json:"network_key_hex,omitempty"`
	MACAddress    string   `json:"mac_address,omitempty"`
	NetworkIndex  *int     `json:"network_index,omitempty"`
	Notes         []string `json:"notes,omitempty"`
}

Credential is one decoded WSC Credential attribute (a provisioned network). NetworkKey is the recovered PSK — the operative field.

type RawAttr

type RawAttr struct {
	Type   string `json:"type"`
	Length int    `json:"length"`
	Value  string `json:"value_hex,omitempty"`
}

RawAttr is a top-level attribute that is not a Credential, surfaced without interpretation.

type Result

type Result struct {
	Credentials []Credential `json:"credentials"`
	OtherAttrs  []RawAttr    `json:"other_attributes,omitempty"`
	Notes       []string     `json:"notes,omitempty"`
}

Result is the decoded WSC blob.

func Decode

func Decode(b []byte) (*Result, error)

Decode walks a WSC attribute blob and returns the decoded credentials.

func DecodeHex

func DecodeHex(s string) (*Result, error)

DecodeHex decodes a WSC blob supplied as a hex string (':' / '-' / whitespace separators ignored).

Jump to

Keyboard shortcuts

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